35
35
def test_mkdir(self):
36
36
"""Basic 'bzr mkdir' operation"""
37
from bzrlib.commands import run_bzr
40
run_bzr(['mkdir', 'foo'])
39
self.run_bzr('mkdir', 'foo')
41
40
self.assert_(os.path.isdir('foo'))
43
self.assertRaises(OSError, run_bzr, ['mkdir', 'foo'])
42
self.run_bzr('mkdir', 'foo', retcode=2)
45
44
from bzrlib.diff import compare_trees
46
45
from bzrlib.branch import Branch
49
48
delta = compare_trees(b.basis_tree(), b.working_tree())
81
79
"bzr add" should add the parent(s) as necessary.
83
81
from bzrlib.branch import Branch
84
from bzrlib.commands import run_bzr
85
82
eq = self.assertEqual
87
b = Branch('.', init=True)
84
b = Branch.initialize('.')
89
86
self.build_tree(['inertiatic/', 'inertiatic/esp'])
90
87
eq(list(b.unknowns()), ['inertiatic'])
91
run_bzr(['add', 'inertiatic/esp'])
88
self.run_bzr('add', 'inertiatic/esp')
92
89
eq(list(b.unknowns()), [])
94
91
# Multiple unversioned parents
95
92
self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt'])
96
93
eq(list(b.unknowns()), ['veil'])
97
run_bzr(['add', 'veil/cerpin/taxt'])
94
self.run_bzr('add', 'veil/cerpin/taxt')
98
95
eq(list(b.unknowns()), [])
100
97
# Check whacky paths work
101
98
self.build_tree(['cicatriz/', 'cicatriz/esp'])
102
99
eq(list(b.unknowns()), ['cicatriz'])
103
run_bzr(['add', 'inertiatic/../cicatriz/esp'])
100
self.run_bzr('add', 'inertiatic/../cicatriz/esp')
104
101
eq(list(b.unknowns()), [])
106
103
def test_add_in_versioned(self):
109
106
"bzr add" should do this happily.
111
108
from bzrlib.branch import Branch
112
from bzrlib.commands import run_bzr
113
109
eq = self.assertEqual
115
b = Branch('.', init=True)
111
b = Branch.initialize('.')
117
113
self.build_tree(['inertiatic/', 'inertiatic/esp'])
118
114
eq(list(b.unknowns()), ['inertiatic'])
119
run_bzr(['add', '--no-recurse', 'inertiatic'])
120
eq(list(b.unknowns()), ['inertiatic/esp'])
121
run_bzr(['add', 'inertiatic/esp'])
115
self.run_bzr('add', '--no-recurse', 'inertiatic')
116
eq(list(b.unknowns()), ['inertiatic'+os.sep+'esp'])
117
self.run_bzr('add', 'inertiatic/esp')
122
118
eq(list(b.unknowns()), [])
124
120
def test_subdir_add(self):
125
121
"""Add in subdirectory should add only things from there down"""
127
123
from bzrlib.branch import Branch
128
from bzrlib.commands import run_bzr
130
125
eq = self.assertEqual
131
126
ass = self.assert_
134
b = Branch('.', init=True)
129
b = Branch.initialize('.')
135
131
self.build_tree(['src/', 'README'])
137
133
eq(sorted(b.unknowns()),
138
134
['README', 'src'])
140
eq(run_bzr(['add', 'src']), 0)
136
self.run_bzr('add', 'src')
142
138
self.build_tree(['src/foo.c'])
145
eq(run_bzr(['add']), 0)
147
143
eq(sorted(b.unknowns()),
149
eq(len(b.inventory), 3)
145
eq(len(t.read_working_inventory()), 3)
152
eq(run_bzr(['add']), 0)
153
149
eq(list(b.unknowns()), [])
155
self.check_and_upgrade()
158
def check_and_upgrade(self):
153
def check_branch(self):
159
154
"""After all the above changes, run the check and upgrade commands.
161
156
The upgrade should be a no-op."""
163
158
debug('branch has %d revisions', b.revno())
165
160
debug('check branch...')
166
161
from bzrlib.check import check
169
debug('upgrade branch...')
170
from bzrlib.upgrade import upgrade
173
debug('check branch...')
174
from bzrlib.check import check
197
184
for fn in ('a/one', 'b/two', 'top'):
198
185
file(fn, 'w').write('new contents')
187
debug('start selective subdir commit')
200
188
run_bzr('commit', 'a', '-m', 'commit a only')
202
old = b.revision_tree(b.lookup_revision(1))
203
new = b.revision_tree(b.lookup_revision(2))
190
old = b.revision_tree(b.get_rev_id(1))
191
new = b.revision_tree(b.get_rev_id(2))
205
193
eq(new.get_file_by_path('b/two').read(), 'old contents')
206
194
eq(new.get_file_by_path('top').read(), 'old contents')
210
198
# commit from here should do nothing
211
199
run_bzr('commit', '.', '-m', 'commit subdir only', '--unchanged')
212
v3 = b.revision_tree(b.lookup_revision(3))
200
v3 = b.revision_tree(b.get_rev_id(3))
213
201
eq(v3.get_file_by_path('b/two').read(), 'old contents')
214
202
eq(v3.get_file_by_path('top').read(), 'old contents')
215
203
eq(v3.get_file_by_path('a/one').read(), 'new contents')
217
205
# commit in subdirectory commits whole tree
218
206
run_bzr('commit', '-m', 'commit whole tree from subdir')
219
v4 = b.revision_tree(b.lookup_revision(4))
207
v4 = b.revision_tree(b.get_rev_id(4))
220
208
eq(v4.get_file_by_path('b/two').read(), 'new contents')
221
209
eq(v4.get_file_by_path('top').read(), 'new contents')
223
211
# TODO: factor out some kind of assert_tree_state() method
214
if __name__ == '__main__':