207
207
test.runbzr('add goodbye')
208
208
test.runbzr('commit -m setup goodbye')
210
def test_export(self):
213
self.example_branch()
214
self.runbzr('export ../latest')
215
self.assertEqual(file('../latest/goodbye', 'rt').read(), 'baz')
216
self.runbzr('export ../first -r 1')
217
assert not os.path.exists('../first/goodbye')
218
self.assertEqual(file('../first/hello', 'rt').read(), 'foo')
219
self.runbzr('export ../first.gz -r 1')
220
self.assertEqual(file('../first.gz/hello', 'rt').read(), 'foo')
221
self.runbzr('export ../first.bz2 -r 1')
222
self.assertEqual(file('../first.bz2/hello', 'rt').read(), 'foo')
223
self.runbzr('export ../first.tar -r 1')
224
assert os.path.isfile('../first.tar')
225
from tarfile import TarFile
226
tf = TarFile('../first.tar')
227
assert 'first/hello' in tf.getnames(), tf.getnames()
228
self.assertEqual(tf.extractfile('first/hello').read(), 'foo')
229
self.runbzr('export ../first.tar.gz -r 1')
230
assert os.path.isfile('../first.tar.gz')
231
self.runbzr('export ../first.tbz2 -r 1')
232
assert os.path.isfile('../first.tbz2')
233
self.runbzr('export ../first.tar.bz2 -r 1')
234
assert os.path.isfile('../first.tar.bz2')
235
self.runbzr('export ../first.tar.tbz2 -r 1')
236
assert os.path.isfile('../first.tar.tbz2')
237
from bz2 import BZ2File
238
tf = TarFile('../first.tar.tbz2',
239
fileobj=BZ2File('../first.tar.tbz2', 'r'))
240
assert 'first.tar/hello' in tf.getnames(), tf.getnames()
241
self.assertEqual(tf.extractfile('first.tar/hello').read(), 'foo')
242
self.runbzr('export ../first2.tar -r 1 --root pizza')
243
tf = TarFile('../first2.tar')
244
assert 'pizza/hello' in tf.getnames(), tf.getnames()
210
246
def test_diff(self):
211
247
self.example_branch()
212
248
file('hello', 'wt').write('hello world!')
261
297
# assert a.pending_merges() == [b.last_revision()], "Assertion %s %s" \
262
298
# % (a.pending_merges(), b.last_revision())
300
def test_merge_with_missing_file(self):
301
"""Merge handles missing file conflicts"""
305
print >> file('sub/a.txt', 'wb'), "hello"
306
print >> file('b.txt', 'wb'), "hello"
307
print >> file('sub/c.txt', 'wb'), "hello"
310
self.runbzr(('commit', '-m', 'added a'))
311
self.runbzr('branch . ../b')
312
print >> file('sub/a.txt', 'ab'), "there"
313
print >> file('b.txt', 'ab'), "there"
314
print >> file('sub/c.txt', 'ab'), "there"
315
self.runbzr(('commit', '-m', 'Added there'))
316
os.unlink('sub/a.txt')
317
os.unlink('sub/c.txt')
320
self.runbzr(('commit', '-m', 'Removed a.txt'))
322
print >> file('sub/a.txt', 'ab'), "something"
323
print >> file('b.txt', 'ab'), "something"
324
print >> file('sub/c.txt', 'ab'), "something"
325
self.runbzr(('commit', '-m', 'Modified a.txt'))
326
self.runbzr('merge ../a/')
327
assert os.path.exists('sub/a.txt.THIS')
328
assert os.path.exists('sub/a.txt.BASE')
330
self.runbzr('merge ../b/')
331
assert os.path.exists('sub/a.txt.OTHER')
332
assert os.path.exists('sub/a.txt.BASE')
264
334
def test_pull(self):
265
335
"""Pull changes from one branch to another."""