~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2007-03-28 07:08:42 UTC
  • mfrom: (2380 +trunk)
  • mto: (2018.5.146 hpss)
  • mto: This revision was merged to the branch mainline in revision 2414.
  • Revision ID: andrew.bennetts@canonical.com-20070328070842-r843houy668oxb9o
Merge from bzr.dev.

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()