40
41
self.run_bzr('mkdir', 'foo', retcode=3)
42
43
from bzrlib.diff import compare_trees
43
from bzrlib.branch import Branch
44
wt = WorkingTree.open('.')
46
delta = compare_trees(b.basis_tree(), b.working_tree())
46
delta = compare_trees(wt.basis_tree(), wt)
48
48
self.log('delta.added = %r' % delta.added)
67
67
from bzrlib.diff import compare_trees
68
from bzrlib.branch import Branch
68
wt = WorkingTree.open('.')
71
delta = compare_trees(b.basis_tree(), b.working_tree())
70
delta = compare_trees(wt.basis_tree(), wt)
73
72
self.log('delta.added = %r' % delta.added)
95
94
self.failUnless(os.path.isdir('a/b/dir'))
97
96
from bzrlib.diff import compare_trees
99
b_a = Branch.open('a')
100
b_b = Branch.open('a/b')
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)
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)
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)
117
def test_working_tree_add_in_unversioned(self):
118
"""Try to add a file in an unversioned directory.
120
"bzr add" adds the parent as necessary, but simple working tree add
123
from bzrlib.branch import Branch
124
from bzrlib.errors import NotVersionedError
125
from bzrlib.workingtree import WorkingTree
127
b = Branch.initialize(u'.')
129
self.build_tree(['foo/',
132
self.assertRaises(NotVersionedError,
133
WorkingTree(b.base, b).add,
97
wt = WorkingTree.open('.')
98
wt_a = WorkingTree.open('a')
99
wt_b = WorkingTree.open('a/b')
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)
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)
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)
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')
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))
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')
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')
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')