/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/intertree_implementations/test_compare.py

  • Committer: Marius Kruger
  • Date: 2007-08-12 08:15:15 UTC
  • mfrom: (2695 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2979.
  • Revision ID: amanic@gmail.com-20070812081515-vgekipfhohcuj6rn
merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
867
867
            specific_files=specific_files, require_versioned=False,
868
868
            want_unversioned=True))
869
869
 
 
870
    def test_similar_filenames(self):
 
871
        """Test when we have a few files with similar names."""
 
872
        tree1 = self.make_branch_and_tree('tree1')
 
873
        tree2 = self.make_branch_and_tree('tree2')
 
874
        tree2.set_root_id(tree1.get_root_id())
 
875
 
 
876
        # The trees are actually identical, but they happen to contain
 
877
        # similarly named files.
 
878
        self.build_tree(['tree1/a/',
 
879
                         'tree1/a/b/',
 
880
                         'tree1/a/b/c/',
 
881
                         'tree1/a/b/c/d/',
 
882
                         'tree1/a-c/',
 
883
                         'tree1/a-c/e/',
 
884
                         'tree2/a/',
 
885
                         'tree2/a/b/',
 
886
                         'tree2/a/b/c/',
 
887
                         'tree2/a/b/c/d/',
 
888
                         'tree2/a-c/',
 
889
                         'tree2/a-c/e/',
 
890
                        ])
 
891
        tree1.add(['a', 'a/b', 'a/b/c', 'a/b/c/d', 'a-c', 'a-c/e'],
 
892
                  ['a-id', 'b-id', 'c-id', 'd-id', 'a-c-id', 'e-id'])
 
893
        tree2.add(['a', 'a/b', 'a/b/c', 'a/b/c/d', 'a-c', 'a-c/e'],
 
894
                  ['a-id', 'b-id', 'c-id', 'd-id', 'a-c-id', 'e-id'])
 
895
 
 
896
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
897
 
 
898
        self.assertEqual([], self.do_iter_changes(tree1, tree2,
 
899
                                                  want_unversioned=True))
 
900
        expected = sorted([
 
901
            self.unchanged(tree2, tree2.get_root_id()),
 
902
            self.unchanged(tree2, 'a-id'),
 
903
            self.unchanged(tree2, 'b-id'),
 
904
            self.unchanged(tree2, 'c-id'),
 
905
            self.unchanged(tree2, 'd-id'),
 
906
            self.unchanged(tree2, 'a-c-id'),
 
907
            self.unchanged(tree2, 'e-id'),
 
908
            ])
 
909
        self.assertEqual(expected,
 
910
                         self.do_iter_changes(tree1, tree2,
 
911
                                              want_unversioned=True,
 
912
                                              include_unchanged=True))
 
913
 
 
914
 
870
915
    def test_unversioned_subtree_only_emits_root(self):
871
916
        tree1 = self.make_branch_and_tree('tree1')
872
917
        tree2 = self.make_to_branch_and_tree('tree2')
1246
1291
                         self.do_iter_changes(tree1, tree2,
1247
1292
                                              require_versioned=False,
1248
1293
                                              want_unversioned=True))
 
1294
 
 
1295
    def test_rename_over_deleted(self):
 
1296
        tree1 = self.make_branch_and_tree('tree1')
 
1297
        tree2 = self.make_to_branch_and_tree('tree2')
 
1298
        root_id = tree1.get_root_id()
 
1299
        tree2.set_root_id(root_id)
 
1300
 
 
1301
        # The final changes should be:
 
1302
        #   touch a b c d
 
1303
        #   add a b c d
 
1304
        #   commit
 
1305
        #   rm a d
 
1306
        #   mv b a
 
1307
        #   mv c d
 
1308
        self.build_tree_contents([
 
1309
            ('tree1/a', 'a contents\n'),
 
1310
            ('tree1/b', 'b contents\n'),
 
1311
            ('tree1/c', 'c contents\n'),
 
1312
            ('tree1/d', 'd contents\n'),
 
1313
            ('tree2/a', 'b contents\n'),
 
1314
            ('tree2/d', 'c contents\n'),
 
1315
            ])
 
1316
        tree1.add(['a', 'b', 'c', 'd'], ['a-id', 'b-id', 'c-id', 'd-id'])
 
1317
        tree2.add(['a', 'd'], ['b-id', 'c-id'])
 
1318
 
 
1319
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
1320
 
 
1321
        expected = sorted([
 
1322
            self.deleted(tree1, 'a-id'),
 
1323
            self.deleted(tree1, 'd-id'),
 
1324
            self.renamed(tree1, tree2, 'b-id', False),
 
1325
            self.renamed(tree1, tree2, 'c-id', False),
 
1326
            ])
 
1327
        self.assertEqual(expected,
 
1328
                         self.do_iter_changes(tree1, tree2))
 
1329
 
 
1330
    def test_deleted_and_unknown(self):
 
1331
        """Test a file marked removed, but still present on disk."""
 
1332
        tree1 = self.make_branch_and_tree('tree1')
 
1333
        tree2 = self.make_to_branch_and_tree('tree2')
 
1334
        root_id = tree1.get_root_id()
 
1335
        tree2.set_root_id(root_id)
 
1336
 
 
1337
        # The final changes should be:
 
1338
        # bzr add a b c
 
1339
        # bzr rm --keep b
 
1340
        self.build_tree_contents([
 
1341
            ('tree1/a', 'a contents\n'),
 
1342
            ('tree1/b', 'b contents\n'),
 
1343
            ('tree1/c', 'c contents\n'),
 
1344
            ('tree2/a', 'a contents\n'),
 
1345
            ('tree2/b', 'b contents\n'),
 
1346
            ('tree2/c', 'c contents\n'),
 
1347
            ])
 
1348
        tree1.add(['a', 'b', 'c'], ['a-id', 'b-id', 'c-id'])
 
1349
        tree2.add(['a', 'c'], ['a-id', 'c-id'])
 
1350
 
 
1351
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
1352
 
 
1353
        expected = sorted([
 
1354
            self.deleted(tree1, 'b-id'),
 
1355
            self.unversioned(tree2, 'b'),
 
1356
            ])
 
1357
        self.assertEqual(expected,
 
1358
                         self.do_iter_changes(tree1, tree2,
 
1359
                                              want_unversioned=True))
 
1360
        expected = sorted([
 
1361
            self.deleted(tree1, 'b-id'),
 
1362
            ])
 
1363
        self.assertEqual(expected,
 
1364
                         self.do_iter_changes(tree1, tree2,
 
1365
                                              want_unversioned=False))
 
1366
 
 
1367
    def test_renamed_and_added(self):
 
1368
        """Test when we have renamed a file, and put another in its place."""
 
1369
        tree1 = self.make_branch_and_tree('tree1')
 
1370
        tree2 = self.make_to_branch_and_tree('tree2')
 
1371
        root_id = tree1.get_root_id()
 
1372
        tree2.set_root_id(root_id)
 
1373
 
 
1374
        # The final changes are:
 
1375
        # bzr add b c
 
1376
        # bzr mv b a
 
1377
        # bzr mv c d
 
1378
        # bzr add b c
 
1379
 
 
1380
        self.build_tree_contents([
 
1381
            ('tree1/b', 'b contents\n'),
 
1382
            ('tree1/c', 'c contents\n'),
 
1383
            ('tree2/a', 'b contents\n'),
 
1384
            ('tree2/b', 'new b contents\n'),
 
1385
            ('tree2/c', 'new c contents\n'),
 
1386
            ('tree2/d', 'c contents\n'),
 
1387
            ])
 
1388
        tree1.add(['b', 'c'], ['b1-id', 'c1-id'])
 
1389
        tree2.add(['a', 'b', 'c', 'd'], ['b1-id', 'b2-id', 'c2-id', 'c1-id'])
 
1390
 
 
1391
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
1392
 
 
1393
        expected = sorted([
 
1394
            self.renamed(tree1, tree2, 'b1-id', False),
 
1395
            self.renamed(tree1, tree2, 'c1-id', False),
 
1396
            self.added(tree2, 'b2-id'),
 
1397
            self.added(tree2, 'c2-id'),
 
1398
            ])
 
1399
        self.assertEqual(expected,
 
1400
                         self.do_iter_changes(tree1, tree2,
 
1401
                                              want_unversioned=True))
 
1402
 
 
1403
    def test_renamed_and_unknown(self):
 
1404
        """A file was moved on the filesystem, but not in bzr."""
 
1405
        tree1 = self.make_branch_and_tree('tree1')
 
1406
        tree2 = self.make_to_branch_and_tree('tree2')
 
1407
        root_id = tree1.get_root_id()
 
1408
        tree2.set_root_id(root_id)
 
1409
 
 
1410
        # The final changes are:
 
1411
        # bzr add a b
 
1412
        # mv a a2
 
1413
 
 
1414
        self.build_tree_contents([
 
1415
            ('tree1/a', 'a contents\n'),
 
1416
            ('tree1/b', 'b contents\n'),
 
1417
            ('tree2/a', 'a contents\n'),
 
1418
            ('tree2/b', 'b contents\n'),
 
1419
            ])
 
1420
        tree1.add(['a', 'b'], ['a-id', 'b-id'])
 
1421
        tree2.add(['a', 'b'], ['a-id', 'b-id'])
 
1422
        os.rename('tree2/a', 'tree2/a2')
 
1423
 
 
1424
        tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
 
1425
 
 
1426
        expected = sorted([
 
1427
            self.missing('a-id', 'a', 'a', tree2.get_root_id(), 'file'),
 
1428
            self.unversioned(tree2, 'a2'),
 
1429
            ])
 
1430
        self.assertEqual(expected,
 
1431
                         self.do_iter_changes(tree1, tree2,
 
1432
                                              want_unversioned=True))