Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief Implementation of OneSideStrategy
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : *
8 : */
9 :
10 : #include <helper/keyhelper.hpp>
11 : #include <merging/onesidestrategy.hpp>
12 : #include <string>
13 :
14 : using namespace std;
15 : using namespace kdb::tools::helper;
16 :
17 : namespace kdb
18 : {
19 :
20 : namespace tools
21 : {
22 :
23 : namespace merging
24 : {
25 :
26 14 : void OneSideStrategy::resolveConflict (const MergeTask & task, Key & conflictKey, MergeResult & result)
27 : {
28 28 : string lookupPath;
29 28 : Key winningKey;
30 :
31 14 : switch (winningSide)
32 : {
33 : case BASE:
34 8 : lookupPath = rebasePath (conflictKey, task.mergeRoot, task.baseParent);
35 16 : winningKey = task.base.lookup (lookupPath);
36 4 : break;
37 : case OURS:
38 12 : lookupPath = rebasePath (conflictKey, task.mergeRoot, task.ourParent);
39 24 : winningKey = task.ours.lookup (lookupPath);
40 6 : break;
41 : case THEIRS:
42 8 : lookupPath = rebasePath (conflictKey, task.mergeRoot, task.theirParent);
43 16 : winningKey = task.theirs.lookup (lookupPath);
44 4 : break;
45 : }
46 :
47 14 : if (winningKey)
48 : {
49 14 : copyKeyValue (winningKey, conflictKey);
50 14 : result.resolveConflict (conflictKey);
51 14 : result.addMergeKey (conflictKey);
52 : }
53 : else
54 : {
55 0 : result.resolveConflict (conflictKey);
56 0 : result.removeMergeKey (conflictKey);
57 : }
58 14 : }
59 : } // namespace merging
60 : } // namespace tools
61 : } // namespace kdb
|