/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 breezy/tests/test_dirstate.py

  • Committer: Jelmer Vernooij
  • Date: 2019-07-27 22:47:49 UTC
  • mfrom: (7377 work)
  • mto: This revision was merged to the branch mainline in revision 7378.
  • Revision ID: jelmer@jelmer.uk-20190727224749-rta5fv1sc4ivy6ko
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
394
394
        # There are no files on disk and no parents
395
395
        tree = self.make_branch_and_tree('tree')
396
396
        expected_result = ([], [
397
 
            ((b'', b'', tree.get_root_id()),  # common details
 
397
            ((b'', b'', tree.path2id('')),  # common details
398
398
             [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT),  # current tree
399
399
              ])])
400
400
        state = dirstate.DirState.from_tree(tree, 'dirstate')
407
407
        rev_id = tree.commit('first post')
408
408
        root_stat_pack = dirstate.pack_stat(os.stat(tree.basedir))
409
409
        expected_result = ([rev_id], [
410
 
            ((b'', b'', tree.get_root_id()),  # common details
 
410
            ((b'', b'', tree.path2id('')),  # common details
411
411
             [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT),  # current tree
412
412
              (b'd', b'', 0, False, rev_id),  # first parent details
413
413
              ])])
427
427
        rev_id2 = tree2.commit('second post', allow_pointless=True)
428
428
        tree.merge_from_branch(tree2.branch)
429
429
        expected_result = ([rev_id, rev_id2], [
430
 
            ((b'', b'', tree.get_root_id()),  # common details
 
430
            ((b'', b'', tree.path2id('')),  # common details
431
431
             [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT),  # current tree
432
432
              (b'd', b'', 0, False, rev_id),  # first parent details
433
433
              (b'd', b'', 0, False, rev_id),  # second parent details
446
446
        tree = self.make_branch_and_tree('tree')
447
447
        self.build_tree(['tree/unknown'])
448
448
        expected_result = ([], [
449
 
            ((b'', b'', tree.get_root_id()),  # common details
 
449
            ((b'', b'', tree.path2id('')),  # common details
450
450
             [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT),  # current tree
451
451
              ])])
452
452
        state = dirstate.DirState.from_tree(tree, 'dirstate')
463
463
        # There are files on disk and no parents
464
464
        tree = self.get_tree_with_a_file()
465
465
        expected_result = ([], [
466
 
            ((b'', b'', tree.get_root_id()),  # common details
 
466
            ((b'', b'', tree.path2id('')),  # common details
467
467
             [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT),  # current tree
468
468
              ]),
469
469
            ((b'', b'a file', b'a-file-id'),  # common
481
481
        # and length:
482
482
        self.build_tree_contents([('tree/a file', b'new content\n')])
483
483
        expected_result = ([rev_id], [
484
 
            ((b'', b'', tree.get_root_id()),  # common details
 
484
            ((b'', b'', tree.path2id('')),  # common details
485
485
             [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT),  # current tree
486
486
              (b'd', b'', 0, False, rev_id),  # first parent details
487
487
              ]),
508
508
        # and length again, giving us three distinct values:
509
509
        self.build_tree_contents([('tree/a file', b'new content\n')])
510
510
        expected_result = ([rev_id, rev_id2], [
511
 
            ((b'', b'', tree.get_root_id()),  # common details
 
511
            ((b'', b'', tree.path2id('')),  # common details
512
512
             [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT),  # current tree
513
513
              (b'd', b'', 0, False, rev_id),  # first parent details
514
514
              (b'd', b'', 0, False, rev_id),  # second parent details
573
573
        # get a state object
574
574
        # no parents, default tree content
575
575
        expected_result = ([], [
576
 
            ((b'', b'', tree.get_root_id()),  # common details
 
576
            ((b'', b'', tree.path2id('')),  # common details
577
577
             # current tree details, but new from_tree skips statting, it
578
578
             # uses set_state_from_inventory, and thus depends on the
579
579
             # inventory state.
899
899
            tree1.add(['a', 'a/b', 'a-b', 'a/b/foo', 'a-b/bar'],
900
900
                      [b'a-id', b'b-id', b'a-b-id', b'foo-id', b'bar-id'])
901
901
            tree1.commit('rev1', rev_id=b'rev1')
902
 
            root_id = tree1.get_root_id()
 
902
            root_id = tree1.path2id('')
903
903
            inv = tree1.root_inventory
904
904
        finally:
905
905
            tree1.unlock()
1045
1045
        tree2.lock_write()
1046
1046
        try:
1047
1047
            revid2 = tree2.commit('foo')
1048
 
            root_id = tree2.get_root_id()
 
1048
            root_id = tree2.path2id('')
1049
1049
        finally:
1050
1050
            tree2.unlock()
1051
1051
        state = dirstate.DirState.initialize('dirstate')
1116
1116
        try:
1117
1117
            tree2.put_file_bytes_non_atomic('a file', b'new file-content')
1118
1118
            revid2 = tree2.commit('foo')
1119
 
            root_id = tree2.get_root_id()
 
1119
            root_id = tree2.path2id('')
1120
1120
        finally:
1121
1121
            tree2.unlock()
1122
1122
        # check the layout in memory
1337
1337
        # incorrect absent in tree 1, and future changes go to pot.
1338
1338
        tree1 = self.make_branch_and_tree('tree1')
1339
1339
        self.build_tree(['tree1/b'])
1340
 
        tree1.lock_write()
1341
 
        try:
 
1340
        with tree1.lock_write():
1342
1341
            tree1.add(['b'], [b'b-id'])
1343
 
            root_id = tree1.get_root_id()
 
1342
            root_id = tree1.path2id('')
1344
1343
            inv = tree1.root_inventory
1345
1344
            state = dirstate.DirState.initialize('dirstate')
1346
1345
            try:
1358
1357
                self.assertEqual(expected_result1, values)
1359
1358
            finally:
1360
1359
                state.unlock()
1361
 
        finally:
1362
 
            tree1.unlock()
1363
1360
 
1364
1361
 
1365
1362
class TestDirStateHashUpdates(TestCaseWithDirState):