~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-22 22:25:42 UTC
  • mto: (3697.7.4 1.7)
  • mto: This revision was merged to the branch mainline in revision 3748.
  • Revision ID: john@arbash-meinel.com-20080722222542-r4so03343ba2me68
Switch the lca_trees to be in 'find_merge_order'.

We don't *have* to use that order, but it means we guarantee the lca ordering,
rather than just guessing.
One alternative that would be a bit faster is just simple lexicographical ordering.

Also handle when one of the LCA trees doesn't have an entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1166
1166
        merger = self.make_Merger(self.setup_criss_cross_graph(), 'E-id')
1167
1167
        self.assertEqual('A-id', merger.base_rev_id)
1168
1168
        self.assertTrue(merger._is_criss_cross)
1169
 
        self.assertEqual(['B-id', 'C-id'], sorted(merger._lca_trees.keys()))
 
1169
        self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
 
1170
                                            for t in merger._lca_trees])
1170
1171
 
1171
1172
    def test_no_criss_cross_passed_to_merge_type(self):
1172
1173
        class LCATreesMerger(LoggingMerger):
1182
1183
        merger = self.make_Merger(self.setup_criss_cross_graph(), 'E-id')
1183
1184
        merger.merge_type = _mod_merge.Merge3Merger
1184
1185
        merge_obj = merger.make_merger()
1185
 
        self.assertEqual(['B-id', 'C-id'], sorted(merge_obj._lca_trees.keys()))
 
1186
        self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
 
1187
                                            for t in merger._lca_trees])
1186
1188
 
1187
1189
    def test_criss_cross_not_supported_merge_type(self):
1188
1190
        class NoLCATreesMerger(LoggingMerger):
1227
1229
            [('modify', ('a-id', 'a\nB\nb\nC\nc\n'))])
1228
1230
        merge_obj = self.make_merge_obj(builder, 'E-id')
1229
1231
 
1230
 
        self.assertEqual(['B-id', 'C-id'], sorted(merge_obj._lca_trees.keys()))
 
1232
        self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
 
1233
                                            for t in merge_obj._lca_trees])
1231
1234
        self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
1232
1235
        entries = list(merge_obj._entries_lca())
1233
1236
 
1268
1271
        builder.build_snapshot('F-id', ['D-id', 'E-id'], [])
1269
1272
        merge_obj = self.make_merge_obj(builder, 'G-id')
1270
1273
 
1271
 
        self.assertEqual(['D-id', 'E-id'], sorted(merge_obj._lca_trees.keys()))
 
1274
        self.assertEqual(['D-id', 'E-id'], [t.get_revision_id()
 
1275
                                            for t in merge_obj._lca_trees])
1272
1276
        self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
1273
1277
        entries = list(merge_obj._entries_lca())
1274
1278
        root_id = 'a-root-id'
1283
1287
        builder.build_snapshot('A-id', None,
1284
1288
            [('add', (u'', 'a-root-id', 'directory', None)),
1285
1289
             ('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
 
1290
        builder.build_snapshot('B-id', ['A-id'],
 
1291
            [('modify', ('a-id', 'a\nB\nb\nc\n'))])
1286
1292
        builder.build_snapshot('C-id', ['A-id'],
1287
1293
            [('modify', ('a-id', 'a\nb\nC\nc\n'))])
1288
 
        builder.build_snapshot('B-id', ['A-id'],
1289
 
            [('modify', ('a-id', 'a\nB\nb\nc\n'))])
1290
1294
        builder.build_snapshot('E-id', ['C-id', 'B-id'],
1291
1295
            [('modify', ('a-id', 'a\nB\nb\nC\nc\nE\n'))])
1292
1296
        builder.build_snapshot('D-id', ['B-id', 'C-id'],
1293
1297
            [('unversion', 'a-id')])
1294
1298
        merge_obj = self.make_merge_obj(builder, 'E-id')
1295
1299
 
1296
 
        self.assertEqual(['B-id', 'C-id'], sorted(merge_obj._lca_trees.keys()))
 
1300
        self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
 
1301
                                            for t in merge_obj._lca_trees])
1297
1302
        self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
1298
1303
 
1299
1304
        entries = list(merge_obj._entries_lca())
1304
1309
                           ((False, [False, False]), False, None)),
1305
1310
                         ], entries)
1306
1311
 
 
1312
    def test_not_in_one_lca(self):
 
1313
        builder = self.get_builder()
 
1314
        builder.build_snapshot('A-id', None,
 
1315
            [('add', (u'', 'a-root-id', 'directory', None))])
 
1316
        builder.build_snapshot('B-id', ['A-id'], [])
 
1317
        builder.build_snapshot('C-id', ['A-id'],
 
1318
            [('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
 
1319
        builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
 
1320
        builder.build_snapshot('D-id', ['B-id', 'C-id'],
 
1321
            [('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
 
1322
        merge_obj = self.make_merge_obj(builder, 'E-id')
 
1323
 
 
1324
        self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
 
1325
                                            for t in merge_obj._lca_trees])
 
1326
        self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
 
1327
 
 
1328
        entries = list(merge_obj._entries_lca())
 
1329
        root_id = 'a-root-id'
 
1330
        self.assertEqual([('a-id', True,
 
1331
                           ((None, [None, root_id]), root_id, root_id),
 
1332
                           ((None, [None, u'a']), u'a', u'a'),
 
1333
                           ((None, [None, False]), False, False)),
 
1334
                         ], entries)
 
1335
 
1307
1336
    # TODO: cases to test
1308
1337
    #       simple criss-cross LCAS identical, BASE different
1309
1338
    #       x-x changed from BASE but identical for all LCAs and tips
1311
1340
    #       x-x OTHER deletes the file
1312
1341
    #       x-x OTHER introduces the file
1313
1342
    #       x-x LCAs differ, one in ancestry of other for a given file
 
1343
    #       x-x file missing in LCA