本文整理汇总了C++中MergeResult::resolveConflict方法的典型用法代码示例。如果您正苦于以下问题:C++ MergeResult::resolveConflict方法的具体用法?C++ MergeResult::resolveConflict怎么用?C++ MergeResult::resolveConflict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MergeResult
的用法示例。
在下文中一共展示了MergeResult::resolveConflict方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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;
}
}
示例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: Key
TEST (MergeResult, ResolveConflictIgnoresOtherMeta)
{
MergeResult result;
Key conflictKey = Key ("user/test/config/key1", KEY_VALUE, "testvalue", KEY_META, "order", "10", KEY_META, "noconflict/data",
"testvalue", KEY_END);
result.resolveConflict (conflictKey);
EXPECT_EQ ("10", conflictKey.getMeta<string> ("order"));
EXPECT_EQ ("testvalue", conflictKey.getMeta<string> ("noconflict/data"));
}
示例5: result
TEST (MergeResult, ResolveConflictRemovesKeyFromConflicts)
{
Key conflictKey = Key ("user/test/config/key1", KEY_VALUE, "testvalue", KEY_END);
KeySet conflicts;
conflicts.append (conflictKey);
KeySet merged;
MergeResult result (conflicts, merged);
result.resolveConflict (conflictKey);
EXPECT_EQ (0, result.getConflictSet ().size ());
}
示例6: 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);
}
}
}
示例7: 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);
}
}
}