~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_graph.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-10 22:41:46 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080710224146-pmkkzgc4vbxhgrsr
The insertion ordering into the weave has an impact on conflicts.

Basically, when A has ancestors B and C which have overlapping changes,
inserting B before C will implicitly sort its lines earlier in the weave.
If A resolves the conflict by preserving this ordering, then switching that
ordering later will make those lines look like they originated in A, rather
than in B and C. (Because diff can't track moved lines yet.)

So bring in some explicit ordering constraints which are likely to fit the
real world workflow. Specifically, prefer to add the left-hand parents before
the right-hand parents. Since that is how the merge was done.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1312
1312
        self.assertFindDistance(6, graph, 'g', [('i', 8)])
1313
1313
 
1314
1314
 
 
1315
class TestFindMergeOrder(TestGraphBase):
 
1316
 
 
1317
    def assertMergeOrder(self, expected, graph, tip, base_revisions):
 
1318
        self.assertEqual(expected, graph.find_merge_order(tip, base_revisions))
 
1319
 
 
1320
    def test_parents(self):
 
1321
        graph = self.make_graph(ancestry_1)
 
1322
        self.assertMergeOrder(['rev3', 'rev2b'], graph, 'rev4',
 
1323
                                                        ['rev3', 'rev2b'])
 
1324
        self.assertMergeOrder(['rev3', 'rev2b'], graph, 'rev4',
 
1325
                                                        ['rev2b', 'rev3'])
 
1326
 
 
1327
    def test_ancestors(self):
 
1328
        graph = self.make_graph(ancestry_1)
 
1329
        self.assertMergeOrder(['rev1', 'rev2b'], graph, 'rev4',
 
1330
                                                        ['rev1', 'rev2b'])
 
1331
        self.assertMergeOrder(['rev1', 'rev2b'], graph, 'rev4',
 
1332
                                                        ['rev2b', 'rev1'])
 
1333
 
 
1334
    def test_shortcut_one_ancestor(self):
 
1335
        # When we have enough info, we can stop searching
 
1336
        graph = self.make_breaking_graph(ancestry_1, ['rev3', 'rev2b', 'rev4'])
 
1337
        # Single ancestors shortcut right away
 
1338
        self.assertMergeOrder(['rev3'], graph, 'rev4', ['rev3'])
 
1339
 
 
1340
    def test_shortcut_after_one_ancestor(self):
 
1341
        graph = self.make_breaking_graph(ancestry_1, ['rev2a', 'rev2b'])
 
1342
        self.assertMergeOrder(['rev3', 'rev1'], graph, 'rev4', ['rev1', 'rev3'])
 
1343
 
 
1344
 
1315
1345
class TestCachingParentsProvider(tests.TestCase):
1316
1346
 
1317
1347
    def setUp(self):