本文整理汇总了C++中MergeResult::addMergeKey方法的典型用法代码示例。如果您正苦于以下问题:C++ MergeResult::addMergeKey方法的具体用法?C++ MergeResult::addMergeKey怎么用?C++ MergeResult::addMergeKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MergeResult
的用法示例。
在下文中一共展示了MergeResult::addMergeKey方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolveConflict
void NewKeyStrategy::resolveConflict (const MergeTask & task, Key & conflictKey, MergeResult & result)
{
ConflictOperation ourOperation = getOurConflictOperation (conflictKey);
ConflictOperation theirOperation = getTheirConflictOperation (conflictKey);
string ourLookup = rebasePath (conflictKey, task.mergeRoot, task.ourParent);
string theirLookup = rebasePath (conflictKey, task.mergeRoot, task.theirParent);
// TODO: this is a subset of the automergestrategy
// the automergestrategy could be split up into several smaller strategies
switch (ourOperation)
{
case CONFLICT_SAME:
if (theirOperation == CONFLICT_ADD)
{
Key source = task.theirs.lookup (theirLookup);
copyKeyValue (source, conflictKey);
result.resolveConflict (conflictKey);
result.addMergeKey (conflictKey);
}
break;
case CONFLICT_ADD:
if (theirOperation == CONFLICT_SAME)
{
Key source = task.ours.lookup (ourLookup);
copyKeyValue (source, conflictKey);
result.resolveConflict (conflictKey);
result.addMergeKey (conflictKey);
}
break;
default:
break;
}
}
示例2: resolveConflict
void OneSideStrategy::resolveConflict(const MergeTask& task, Key& conflictKey, MergeResult& result)
{
string lookupPath;
Key winningKey;
switch (winningSide)
{
case BASE:
lookupPath = rebasePath (conflictKey, task.mergeRoot, task.baseParent);
winningKey = task.base.lookup(lookupPath);
break;
case OURS:
lookupPath = rebasePath (conflictKey, task.mergeRoot, task.ourParent);
winningKey = task.ours.lookup(lookupPath);
break;
case THEIRS:
lookupPath = rebasePath (conflictKey, task.mergeRoot, task.theirParent);
winningKey = task.theirs.lookup(lookupPath);
break;
}
if (winningKey)
{
conflictKey.setString(winningKey.getString());
result.resolveConflict(conflictKey);
result.addMergeKey(conflictKey);
} else
{
result.resolveConflict(conflictKey);
result.removeMergeKey(conflictKey);
}
}
示例3: resolveConflict
void AutoMergeStrategy::resolveConflict(const MergeTask& task, Key& conflictKey, MergeResult& result)
{
ConflictOperation ourOperation = getOurConflictOperation(conflictKey);
ConflictOperation theirOperation = getTheirConflictOperation(conflictKey);
string ourLookup = rebasePath (conflictKey, task.mergeRoot, task.ourParent);
string theirLookup = rebasePath (conflictKey, task.mergeRoot, task.theirParent);
switch (ourOperation)
{
case SAME:
if (theirOperation == MODIFY || theirOperation == ADD)
{
Key source = task.theirs.lookup(theirLookup);
conflictKey.setString(source.getString());
result.resolveConflict(conflictKey);
result.addMergeKey(conflictKey);
}
if (theirOperation == DELETE)
{
result.resolveConflict(conflictKey);
}
break;
case MODIFY:
case ADD:
if (theirOperation == SAME)
{
Key source = task.ours.lookup(ourLookup);
conflictKey.setString(source.getString());
result.resolveConflict(conflictKey);
result.addMergeKey(conflictKey);
}
break;
case DELETE:
if (theirOperation == SAME)
{
result.resolveConflict(conflictKey);
}
break;
case META:
break;
}
}
示例4: result
TEST (MergeResult, CountsEqualKeysCorrectly)
{
Key mergedKey1 = Key ("user/test/config/key1", KEY_END);
Key mergedKey2 = Key ("user/test/config/key2", KEY_END);
Key mergedKey3 = Key ("user/test/config/key3", KEY_END);
Key conflictKey1 = Key ("user/test/config/key4", KEY_END);
KeySet conflicts;
conflicts.append (conflictKey1);
KeySet merged;
merged.append (mergedKey1);
merged.append (mergedKey2);
MergeResult result (conflicts, merged);
EXPECT_EQ (2, result.getNumberOfEqualKeys ()) << "Initially merged keys not counted";
result.resolveConflict (conflictKey1);
result.addMergeKey (conflictKey1);
EXPECT_EQ (2, result.getNumberOfEqualKeys ()) << "Resolved key is counted as equal key";
result.addMergeKey (mergedKey3);
EXPECT_EQ (3, result.getNumberOfEqualKeys ()) << "Merged key is not counted as equal key";
}
示例5: resolveConflict
void MetaMergeStrategy::resolveConflict(const MergeTask& task, Key& conflictKey, MergeResult& result)
{
conflictKey.rewindMeta();
Key currentMeta;
string baseLookup = rebasePath (conflictKey, task.mergeRoot, task.baseParent);
string ourLookup = rebasePath (conflictKey, task.mergeRoot, task.ourParent);
string theirLookup = rebasePath (conflictKey, task.mergeRoot, task.theirParent);
Key baseKey = task.base.lookup(baseLookup);
Key ourKey = task.ours.lookup(ourLookup);
Key theirKey = task.theirs.lookup(theirLookup);
Key root ("user/", KEY_END);
KeySet baseMeta = getMetaKeys (baseKey);
KeySet ourMeta = getMetaKeys (ourKey);
KeySet theirMeta = getMetaKeys (theirKey);
MergeTask metaTask(BaseMergeKeys (baseMeta, root), OurMergeKeys (ourMeta, root),
TheirMergeKeys (theirMeta, root), root);
MergeResult metaResult = innerMerger.mergeKeySet(metaTask);
KeySet mergedMeta = metaResult.getMergedKeys();
Key current;
mergedMeta.rewind();
while ((current = mergedMeta.next()))
{
string metaName = current.getName().substr(string("user/").length());
conflictKey.setMeta(metaName, current.getString());
}
ConflictOperation ourOperation = getOurConflictOperation(conflictKey);
ConflictOperation theirOperation = getTheirConflictOperation(conflictKey);
if (!metaResult.hasConflicts ())
{
if (ourOperation == CONFLICT_META && theirOperation == CONFLICT_META)
{
// TODO: addConflict deletes the key content
// without this strategy restoring the value the value would be lost
// this happens only for CONFLICT_META <--> CONFLICT_META conflicts
// add a test for this behaviour
copyKeyValue(ourKey, conflictKey);
result.resolveConflict (conflictKey);
result.addMergeKey (conflictKey);
}
}
}
示例6: resolveConflict
void OneSideValueStrategy::resolveConflict(const MergeTask& task, Key& conflictKey, MergeResult& result)
{
ConflictOperation ourOperation = getOurConflictOperation (conflictKey);
ConflictOperation theirOperation = getTheirConflictOperation (conflictKey);
string ourLookup = rebasePath (conflictKey, task.mergeRoot, task.ourParent);
string theirLookup = rebasePath (conflictKey, task.mergeRoot, task.theirParent);
// TODO: this is a subset of the onesidestrategy
// the onesidestrategy could be split up into several smaller strategies
if ((ourOperation == CONFLICT_SAME && theirOperation == CONFLICT_MODIFY) || (ourOperation == CONFLICT_MODIFY && theirOperation == CONFLICT_SAME))
{
string lookupPath;
Key winningKey;
switch (winningSide)
{
case BASE:
lookupPath = rebasePath (conflictKey, task.mergeRoot, task.baseParent);
winningKey = task.base.lookup (lookupPath);
break;
case OURS:
lookupPath = rebasePath (conflictKey, task.mergeRoot, task.ourParent);
winningKey = task.ours.lookup (lookupPath);
break;
case THEIRS:
lookupPath = rebasePath (conflictKey, task.mergeRoot, task.theirParent);
winningKey = task.theirs.lookup (lookupPath);
break;
}
if (winningKey)
{
conflictKey.setString (winningKey.getString ());
result.resolveConflict (conflictKey);
result.addMergeKey (conflictKey);
}
}
}
示例7: detectConflicts
void ThreeWayMerge::detectConflicts (const MergeTask & task, MergeResult & mergeResult, bool reverseConflictMeta = false)
{
Key our;
cursor_t savedCursor = task.ours.getCursor ();
task.ours.rewind ();
while ((our = task.ours.next ()))
{
string theirLookup = rebasePath (our, task.ourParent, task.theirParent);
Key theirLookupResult = task.theirs.lookup (theirLookup);
// we have to copy it to obtain owner etc...
Key mergeKey = rebaseKey (our, task.ourParent, task.mergeRoot);
if (keyDataEqual (our, theirLookupResult))
{
// keydata matches, see if metakeys match
if (keyMetaEqual (our, theirLookupResult))
{
if (task.ourParent.getFullName () == task.mergeRoot.getFullName ())
{
// the key was not rebased, we can reuse our (prevents that the key is rewritten)
mergeResult.addMergeKey (our);
}
else
{
// the key causes no merge conflict, but the merge result is below a new parent
mergeResult.addMergeKey (mergeKey);
}
}
else
{
// metakeys are different
mergeResult.addConflict (mergeKey, CONFLICT_META, CONFLICT_META);
}
}
else
{
string baseLookup = rebasePath (our, task.ourParent, task.baseParent);
Key baseLookupResult = task.base.lookup (baseLookup);
// check if the keys was newly added in ours
if (baseLookupResult)
{
// the key exists in base, check if the key still exists in theirs
if (theirLookupResult)
{
// check if only they modified it
if (!keyDataEqual (our, baseLookupResult) && keyDataEqual (theirLookupResult, baseLookupResult))
{
// the key was only modified in ours
addAsymmetricConflict (mergeResult, mergeKey, CONFLICT_MODIFY, CONFLICT_SAME,
reverseConflictMeta);
}
else
{
// check if both modified it
if (!keyDataEqual (our, baseLookupResult) &&
!keyDataEqual (theirLookupResult, baseLookupResult))
{
// the key was modified on both sides
mergeResult.addConflict (mergeKey, CONFLICT_MODIFY, CONFLICT_MODIFY);
}
}
}
else
{
// the key does not exist in theirs anymore, check if ours has modified it
if (keyDataEqual (our, baseLookupResult))
{
// the key was deleted in theirs, and not modified in ours
addAsymmetricConflict (mergeResult, mergeKey, CONFLICT_SAME, CONFLICT_DELETE,
reverseConflictMeta);
}
else
{
// the key was deleted in theirs, but modified in ours
addAsymmetricConflict (mergeResult, mergeKey, CONFLICT_MODIFY, CONFLICT_DELETE,
reverseConflictMeta);
}
}
}
else
{
// the key does not exist in base, check if the key was added in theirs
if (theirLookupResult)
{
// check if the key was added with the same value in theirs
if (keyDataEqual (mergeKey, theirLookupResult))
{
if (keyMetaEqual (our, theirLookupResult))
{
// the key was added on both sides with the same value
if (task.ourParent.getFullName () == task.mergeRoot.getFullName ())
{
// the key was not rebased, we can reuse our and prevent the sync flag being
// set
mergeResult.addMergeKey (our);
}
else
//.........这里部分代码省略.........
示例8: detectConflicts
void ThreeWayMerge::detectConflicts(const MergeTask& task, MergeResult& mergeResult, bool reverseConflictMeta = false)
{
Key our;
cursor_t savedCursor = task.ours.getCursor ();
task.ours.rewind ();
while ((our = task.ours.next ()))
{
if (our.getName() == task.ourParent.getName())
continue;
string theirLookup = rebasePath (our, task.ourParent, task.theirParent);
Key theirLookupResult = task.theirs.lookup (theirLookup);
// we have to copy it to obtain owner etc...
Key mergeKey = rebaseKey (our, task.ourParent, task.mergeRoot);
if (keyDataEqual (our, theirLookupResult))
{
// keydata matches, see if metakeys match
if (keyMetaEqual (our, theirLookupResult))
{
mergeResult.addMergeKey (mergeKey);
}
else
{
// metakeys are different
mergeResult.addConflict (mergeKey, META, META);
}
}
else
{
string baseLookup = rebasePath (our, task.ourParent, task.baseParent);
Key baseLookupResult = task.base.lookup (baseLookup);
// check if the keys was newly added in ours
if (baseLookupResult)
{
// the key exists in base, check if the key still exists in theirs
if (theirLookupResult)
{
// check if only they modified it
if (!keyDataEqual (our, baseLookupResult) && keyDataEqual (theirLookupResult, baseLookupResult))
{
// the key was only modified in ours
addAsymmetricConflict (mergeResult, mergeKey, MODIFY, SAME, reverseConflictMeta);
}
else
{
// check if both modified it
if (!keyDataEqual (our, baseLookupResult) && !keyDataEqual (theirLookupResult, baseLookupResult))
{
// the key was modified on both sides
mergeResult.addConflict (mergeKey, MODIFY, MODIFY);
}
}
}
else
{
// the key does not exist in theirs anymore, check if ours has modified it
if (keyDataEqual (our, baseLookupResult))
{
// the key was deleted in theirs, and not modified in ours
addAsymmetricConflict (mergeResult, mergeKey, SAME, DELETE, reverseConflictMeta);
}
else
{
// the key was deleted in theirs, but modified in ours
addAsymmetricConflict (mergeResult, mergeKey, MODIFY, DELETE, reverseConflictMeta);
}
}
}
else
{
// the key does not exist in base, check if the key was added in theirs
if (theirLookupResult)
{
// check if the key was added with the same value in theirs
if (keyDataEqual (mergeKey, theirLookupResult))
{
if (keyMetaEqual (our, theirLookupResult))
{
// the key was added on both sides with the same value
mergeResult.addMergeKey (mergeKey);
}
else
{
// metakeys are different
mergeResult.addConflict (mergeKey, META, META);
}
}
else
{
// the key was added on both sides with different values
mergeResult.addConflict (mergeKey, ADD, ADD);
}
}
else
{
// the key was only added to ours
//.........这里部分代码省略.........