~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_versioning.py

Merge in bzrdir work to enable checkout improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib.branch import Branch
27
27
from bzrlib.trace import mutter
28
28
from bzrlib.osutils import pathjoin
 
29
from bzrlib.workingtree import WorkingTree
29
30
 
30
31
 
31
32
class TestVersioning(TestCaseInTempDir):
40
41
        self.run_bzr('mkdir', 'foo', retcode=3)
41
42
 
42
43
        from bzrlib.diff import compare_trees
43
 
        from bzrlib.branch import Branch
44
 
        b = Branch.open(u'.')
 
44
        wt = WorkingTree('.')
45
45
        
46
 
        delta = compare_trees(b.basis_tree(), b.working_tree())
 
46
        delta = compare_trees(wt.basis_tree(), wt)
47
47
 
48
48
        self.log('delta.added = %r' % delta.added)
49
49
 
65
65
        os.chdir('..')
66
66
 
67
67
        from bzrlib.diff import compare_trees
68
 
        from bzrlib.branch import Branch
69
 
        b = Branch.open(u'.')
 
68
        wt = WorkingTree('.')
70
69
        
71
 
        delta = compare_trees(b.basis_tree(), b.working_tree())
 
70
        delta = compare_trees(wt.basis_tree(), wt)
72
71
 
73
72
        self.log('delta.added = %r' % delta.added)
74
73
 
95
94
        self.failUnless(os.path.isdir('a/b/dir'))
96
95
 
97
96
        from bzrlib.diff import compare_trees
98
 
        b = Branch.open(u'.')
99
 
        b_a = Branch.open('a')
100
 
        b_b = Branch.open('a/b')
101
 
        
102
 
        delta = compare_trees(b.basis_tree(), b.working_tree())
103
 
        self.assertEquals(len(delta.added), 1)
104
 
        self.assertEquals(delta.added[0][0], 'dir')
105
 
        self.failIf(delta.modified)
106
 
 
107
 
        delta = compare_trees(b_a.basis_tree(), b_a.working_tree())
108
 
        self.assertEquals(len(delta.added), 1)
109
 
        self.assertEquals(delta.added[0][0], 'dir')
110
 
        self.failIf(delta.modified)
111
 
 
112
 
        delta = compare_trees(b_b.basis_tree(), b_b.working_tree())
113
 
        self.assertEquals(len(delta.added), 1)
114
 
        self.assertEquals(delta.added[0][0], 'dir')
115
 
        self.failIf(delta.modified)
116
 
 
117
 
    def test_working_tree_add_in_unversioned(self):
118
 
        """Try to add a file in an unversioned directory.
119
 
 
120
 
        "bzr add" adds the parent as necessary, but simple working tree add
121
 
        doesn't do that.
122
 
        """
123
 
        from bzrlib.branch import Branch
124
 
        from bzrlib.errors import NotVersionedError
125
 
        from bzrlib.workingtree import WorkingTree
126
 
 
127
 
        b = Branch.initialize(u'.')
128
 
 
129
 
        self.build_tree(['foo/',
130
 
                         'foo/hello'])
131
 
 
132
 
        self.assertRaises(NotVersionedError,
133
 
                          WorkingTree(b.base, b).add,
134
 
                          'foo/hello')
135
 
        
136
 
        self.check_branch()
 
97
        wt = WorkingTree('.')
 
98
        wt_a = WorkingTree('a')
 
99
        wt_b = WorkingTree('a/b')
 
100
        
 
101
        delta = compare_trees(wt.basis_tree(), wt)
 
102
        self.assertEquals(len(delta.added), 1)
 
103
        self.assertEquals(delta.added[0][0], 'dir')
 
104
        self.failIf(delta.modified)
 
105
 
 
106
        delta = compare_trees(wt_a.basis_tree(), wt_a)
 
107
        self.assertEquals(len(delta.added), 1)
 
108
        self.assertEquals(delta.added[0][0], 'dir')
 
109
        self.failIf(delta.modified)
 
110
 
 
111
        delta = compare_trees(wt_b.basis_tree(), wt_b)
 
112
        self.assertEquals(len(delta.added), 1)
 
113
        self.assertEquals(delta.added[0][0], 'dir')
 
114
        self.failIf(delta.modified)
137
115
 
138
116
    def check_branch(self):
139
117
        """After all the above changes, run the check and upgrade commands.
171
149
        mutter('start selective subdir commit')
172
150
        run_bzr('commit', 'a', '-m', 'commit a only')
173
151
        
174
 
        old = b.revision_tree(b.get_rev_id(1))
175
 
        new = b.revision_tree(b.get_rev_id(2))
 
152
        old = b.repository.revision_tree(b.get_rev_id(1))
 
153
        new = b.repository.revision_tree(b.get_rev_id(2))
176
154
        
177
155
        eq(new.get_file_by_path('b/two').read(), 'old contents')
178
156
        eq(new.get_file_by_path('top').read(), 'old contents')
181
159
        os.chdir('a')
182
160
        # commit from here should do nothing
183
161
        run_bzr('commit', '.', '-m', 'commit subdir only', '--unchanged')
184
 
        v3 = b.revision_tree(b.get_rev_id(3))
 
162
        v3 = b.repository.revision_tree(b.get_rev_id(3))
185
163
        eq(v3.get_file_by_path('b/two').read(), 'old contents')
186
164
        eq(v3.get_file_by_path('top').read(), 'old contents')
187
165
        eq(v3.get_file_by_path('a/one').read(), 'new contents')
188
166
                
189
167
        # commit in subdirectory commits whole tree
190
168
        run_bzr('commit', '-m', 'commit whole tree from subdir')
191
 
        v4 = b.revision_tree(b.get_rev_id(4))
 
169
        v4 = b.repository.revision_tree(b.get_rev_id(4))
192
170
        eq(v4.get_file_by_path('b/two').read(), 'new contents')        
193
171
        eq(v4.get_file_by_path('top').read(), 'new contents')
194
172