214
214
test.runbzr('add goodbye')
215
215
test.runbzr('commit -m setup goodbye')
217
def test_export(self):
220
self.example_branch()
221
self.runbzr('export ../latest')
222
self.assertEqual(file('../latest/goodbye', 'rt').read(), 'baz')
223
self.runbzr('export ../first -r 1')
224
assert not os.path.exists('../first/goodbye')
225
self.assertEqual(file('../first/hello', 'rt').read(), 'foo')
226
self.runbzr('export ../first.gz -r 1')
227
self.assertEqual(file('../first.gz/hello', 'rt').read(), 'foo')
228
self.runbzr('export ../first.bz2 -r 1')
229
self.assertEqual(file('../first.bz2/hello', 'rt').read(), 'foo')
230
self.runbzr('export ../first.tar -r 1')
231
assert os.path.isfile('../first.tar')
232
from tarfile import TarFile
233
tf = TarFile('../first.tar')
234
assert 'first/hello' in tf.getnames(), tf.getnames()
235
self.assertEqual(tf.extractfile('first/hello').read(), 'foo')
236
self.runbzr('export ../first.tar.gz -r 1')
237
assert os.path.isfile('../first.tar.gz')
238
self.runbzr('export ../first.tbz2 -r 1')
239
assert os.path.isfile('../first.tbz2')
240
self.runbzr('export ../first.tar.bz2 -r 1')
241
assert os.path.isfile('../first.tar.bz2')
242
self.runbzr('export ../first.tar.tbz2 -r 1')
243
assert os.path.isfile('../first.tar.tbz2')
244
from bz2 import BZ2File
245
tf = TarFile('../first.tar.tbz2',
246
fileobj=BZ2File('../first.tar.tbz2', 'r'))
247
assert 'first.tar/hello' in tf.getnames(), tf.getnames()
248
self.assertEqual(tf.extractfile('first.tar/hello').read(), 'foo')
249
self.runbzr('export ../first2.tar -r 1 --root pizza')
250
tf = TarFile('../first2.tar')
251
assert 'pizza/hello' in tf.getnames(), tf.getnames()
217
253
def test_diff(self):
218
254
self.example_branch()
219
255
file('hello', 'wt').write('hello world!')
268
304
# assert a.pending_merges() == [b.last_revision()], "Assertion %s %s" \
269
305
# % (a.pending_merges(), b.last_revision())
307
def test_merge_with_missing_file(self):
308
"""Merge handles missing file conflicts"""
312
print >> file('sub/a.txt', 'wb'), "hello"
313
print >> file('b.txt', 'wb'), "hello"
314
print >> file('sub/c.txt', 'wb'), "hello"
317
self.runbzr(('commit', '-m', 'added a'))
318
self.runbzr('branch . ../b')
319
print >> file('sub/a.txt', 'ab'), "there"
320
print >> file('b.txt', 'ab'), "there"
321
print >> file('sub/c.txt', 'ab'), "there"
322
self.runbzr(('commit', '-m', 'Added there'))
323
os.unlink('sub/a.txt')
324
os.unlink('sub/c.txt')
327
self.runbzr(('commit', '-m', 'Removed a.txt'))
329
print >> file('sub/a.txt', 'ab'), "something"
330
print >> file('b.txt', 'ab'), "something"
331
print >> file('sub/c.txt', 'ab'), "something"
332
self.runbzr(('commit', '-m', 'Modified a.txt'))
333
self.runbzr('merge ../a/')
334
assert os.path.exists('sub/a.txt.THIS')
335
assert os.path.exists('sub/a.txt.BASE')
337
self.runbzr('merge ../b/')
338
assert os.path.exists('sub/a.txt.OTHER')
339
assert os.path.exists('sub/a.txt.BASE')
271
341
def test_pull(self):
272
342
"""Pull changes from one branch to another."""