/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-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
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.path2id('')),  # common details
 
397
            ((b'', b'', tree.get_root_id()),  # 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.path2id('')),  # common details
 
410
            ((b'', b'', tree.get_root_id()),  # 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.path2id('')),  # common details
 
430
            ((b'', b'', tree.get_root_id()),  # 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.path2id('')),  # common details
 
449
            ((b'', b'', tree.get_root_id()),  # 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.path2id('')),  # common details
 
466
            ((b'', b'', tree.get_root_id()),  # 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.path2id('')),  # common details
 
484
            ((b'', b'', tree.get_root_id()),  # 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.path2id('')),  # common details
 
511
            ((b'', b'', tree.get_root_id()),  # 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.path2id('')),  # common details
 
576
            ((b'', b'', tree.get_root_id()),  # 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.path2id('')
 
902
            root_id = tree1.get_root_id()
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.path2id('')
 
1048
            root_id = tree2.get_root_id()
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.path2id('')
 
1119
            root_id = tree2.get_root_id()
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
 
        with tree1.lock_write():
 
1340
        tree1.lock_write()
 
1341
        try:
1341
1342
            tree1.add(['b'], [b'b-id'])
1342
 
            root_id = tree1.path2id('')
 
1343
            root_id = tree1.get_root_id()
1343
1344
            inv = tree1.root_inventory
1344
1345
            state = dirstate.DirState.initialize('dirstate')
1345
1346
            try:
1357
1358
                self.assertEqual(expected_result1, values)
1358
1359
            finally:
1359
1360
                state.unlock()
 
1361
        finally:
 
1362
            tree1.unlock()
1360
1363
 
1361
1364
 
1362
1365
class TestDirStateHashUpdates(TestCaseWithDirState):
1823
1826
class InstrumentedDirState(dirstate.DirState):
1824
1827
    """An DirState with instrumented sha1 functionality."""
1825
1828
 
1826
 
    def __init__(self, path, sha1_provider, worth_saving_limit=0,
1827
 
                 use_filesystem_for_exec=True):
1828
 
        super(InstrumentedDirState, self).__init__(
1829
 
            path, sha1_provider, worth_saving_limit=worth_saving_limit,
1830
 
            use_filesystem_for_exec=use_filesystem_for_exec)
 
1829
    def __init__(self, path, sha1_provider, worth_saving_limit=0):
 
1830
        super(InstrumentedDirState, self).__init__(path, sha1_provider,
 
1831
                                                   worth_saving_limit=worth_saving_limit)
1831
1832
        self._time_offset = 0
1832
1833
        self._log = []
1833
1834
        # member is dynamically set in DirState.__init__ to turn on trace
2564
2565
            basis_tree.root_inventory)
2565
2566
        state.update_basis_by_delta(delta, b'target')
2566
2567
        state._validate()
2567
 
        dirstate_tree = workingtree_4.DirStateRevisionTree(
2568
 
            state, b'target', _Repo(), None)
 
2568
        dirstate_tree = workingtree_4.DirStateRevisionTree(state,
 
2569
                                                           b'target', _Repo())
2569
2570
        # The target now that delta has been applied should match the
2570
2571
        # RevisionTree
2571
2572
        self.assertEqual([], list(dirstate_tree.iter_changes(target_tree)))