~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_unversion.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-03-07 10:45:44 UTC
  • mfrom: (2321.1.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070307104544-59e3e6358e4bdb29
(robertc) Merge dirstate and subtrees. (Robert Collins, Martin Pool, Aaaron Bentley, John A Meinel, James Westby)

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
        # the changes should have persisted to disk - reopen the workingtree
53
53
        # to be sure.
54
54
        tree = tree.bzrdir.open_workingtree()
 
55
        tree.lock_read()
55
56
        self.assertFalse(tree.has_id('a-id'))
56
57
        self.assertFalse(tree.has_id('b-id'))
57
58
        self.assertTrue(tree.has_id('c-id'))
58
59
        self.assertTrue(tree.has_filename('a'))
59
60
        self.assertTrue(tree.has_filename('b'))
60
61
        self.assertTrue(tree.has_filename('c'))
61
 
        
 
62
        tree.unlock()
 
63
 
62
64
    def test_unversion_subtree(self):
63
65
        """Unversioning the root of a subtree unversions the entire subtree."""
64
66
        tree = self.make_branch_and_tree('.')
74
76
        self.assertTrue(tree.has_filename('a/b'))
75
77
        self.assertTrue(tree.has_filename('c'))
76
78
        tree.unlock()
 
79
 
 
80
    def test_unversion_subtree_and_children(self):
 
81
        """Passing a child id will raise NoSuchId.
 
82
 
 
83
        This is because the parent directory will have already been removed.
 
84
        """
 
85
        tree = self.make_branch_and_tree('.')
 
86
        self.build_tree(['a/', 'a/b', 'a/c', 'd'])
 
87
        tree.add(['a', 'a/b', 'a/c', 'd'], ['a-id', 'b-id', 'c-id', 'd-id'])
 
88
        tree.lock_write()
 
89
        try:
 
90
            tree.unversion(['b-id', 'a-id'])
 
91
            self.assertFalse(tree.has_id('a-id'))
 
92
            self.assertFalse(tree.has_id('b-id'))
 
93
            self.assertFalse(tree.has_id('c-id'))
 
94
            self.assertTrue(tree.has_id('d-id'))
 
95
            # The files are still on disk
 
96
            self.assertTrue(tree.has_filename('a'))
 
97
            self.assertTrue(tree.has_filename('a/b'))
 
98
            self.assertTrue(tree.has_filename('a/c'))
 
99
            self.assertTrue(tree.has_filename('d'))
 
100
        finally:
 
101
            tree.unlock()