data/VCardMerge.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "VCardMerge.h" | ||
| 2 | |||
| 3 | #include "VCardMergePlan.h" | ||
| 4 | |||
| 5 | namespace VCardMerge { | ||
| 6 | |||
| 7 | // Sprint 107 S107.2.5: the automatic merge is the plan with its default | ||
| 8 | // choices; the oracles (tests/test_merge_oracles.cpp) keep it identical to | ||
| 9 | // the Sprint 97 implementation. | ||
| 10 | 68 | Result merge(const QString &base, const QString &ours, const QString &theirs) { | |
| 11 | 68 | Result result; | |
| 12 |
1/1✓ Branch 2 → 3 taken 68 times.
|
68 | const Merge::Plan plan = VCardMergePlan::analyze(base, ours, theirs); |
| 13 |
2/2✓ Branch 3 → 4 taken 4 times.
✓ Branch 3 → 12 taken 64 times.
|
68 | if (!plan.comparable) { |
| 14 | 4 | result.error = plan.error; | |
| 15 |
1/1✓ Branch 8 → 9 taken 4 times.
|
8 | result.conflicts << QStringLiteral("unreadable"); |
| 16 | 4 | return result; | |
| 17 | } | ||
| 18 |
2/2✓ Branch 19 → 14 taken 325 times.
✓ Branch 19 → 20 taken 64 times.
|
389 | for (const Merge::Item &item : plan.items) |
| 19 |
2/2✓ Branch 15 → 16 taken 47 times.
✓ Branch 15 → 17 taken 278 times.
|
325 | if (item.state == Merge::State::Conflict) |
| 20 |
1/1✓ Branch 16 → 17 taken 47 times.
|
47 | result.conflicts << item.name; |
| 21 |
2/2✓ Branch 21 → 22 taken 34 times.
✓ Branch 21 → 23 taken 30 times.
|
64 | if (!result.conflicts.isEmpty()) |
| 22 | 34 | return result; | |
| 23 |
1/1✓ Branch 24 → 25 taken 30 times.
|
30 | const VCardMergePlan::Applied applied = VCardMergePlan::apply(plan); |
| 24 |
1/2✗ Branch 26 → 27 not taken.
✓ Branch 26 → 29 taken 30 times.
|
30 | if (!applied.ok) { |
| 25 | ✗ | result.error = applied.error; | |
| 26 | ✗ | return result; | |
| 27 | } | ||
| 28 | 30 | result.ok = true; | |
| 29 | 30 | result.merged = applied.text; | |
| 30 | 30 | return result; | |
| 31 | 68 | } | |
| 32 | |||
| 33 | } // namespace VCardMerge | ||
| 34 |