53
54
class TestCommands(ExternalBase):
55
def test_init_branch(self):
58
# Can it handle subdirectories as well?
59
self.runbzr('init subdir1')
60
self.assert_(os.path.exists('subdir1'))
61
self.assert_(os.path.exists('subdir1/.bzr'))
63
self.runbzr('init subdir2/nothere', retcode=3)
66
self.runbzr('init subdir2')
67
self.runbzr('init subdir2', retcode=3)
69
self.runbzr('init subdir2/subsubdir1')
70
self.assert_(os.path.exists('subdir2/subsubdir1/.bzr'))
72
56
def test_whoami(self):
73
57
# this should always identify something, if only "john@localhost"
74
58
self.runbzr("whoami")
322
306
self.assertEqual('2', target.open_workingtree().last_revision())
323
307
self.assertTrue(target.open_branch().repository.has_revision('2'))
325
def test_merge(self):
326
from bzrlib.branch import Branch
330
self.example_branch()
332
self.runbzr('branch a b')
334
file('goodbye', 'wt').write('quux')
335
self.runbzr(['commit', '-m', "more u's are always good"])
338
file('hello', 'wt').write('quuux')
339
# We can't merge when there are in-tree changes
340
self.runbzr('merge ../b', retcode=3)
341
self.runbzr(['commit', '-m', "Like an epidemic of u's"])
342
self.runbzr('merge ../b -r last:1..last:1 --merge-type blooof',
344
self.runbzr('merge ../b -r last:1..last:1 --merge-type merge3')
345
self.runbzr('revert --no-backup')
346
self.runbzr('merge ../b -r last:1..last:1 --merge-type weave')
347
self.runbzr('revert --no-backup')
348
self.runbzr('merge ../b -r last:1..last:1 --reprocess')
349
self.runbzr('revert --no-backup')
350
self.runbzr('merge ../b -r last:1')
351
self.check_file_contents('goodbye', 'quux')
352
# Merging a branch pulls its revision into the tree
353
a = WorkingTree.open('.')
354
b = Branch.open('../b')
355
a.branch.repository.get_revision_xml(b.last_revision())
356
self.log('pending merges: %s', a.pending_merges())
357
self.assertEquals(a.pending_merges(),
359
self.runbzr('commit -m merged')
360
self.runbzr('merge ../b -r last:1')
361
self.assertEqual(a.pending_merges(), [])
363
def test_merge_with_missing_file(self):
364
"""Merge handles missing file conflicts"""
368
print >> file('sub/a.txt', 'wb'), "hello"
369
print >> file('b.txt', 'wb'), "hello"
370
print >> file('sub/c.txt', 'wb'), "hello"
373
self.runbzr(('commit', '-m', 'added a'))
374
self.runbzr('branch . ../b')
375
print >> file('sub/a.txt', 'ab'), "there"
376
print >> file('b.txt', 'ab'), "there"
377
print >> file('sub/c.txt', 'ab'), "there"
378
self.runbzr(('commit', '-m', 'Added there'))
379
os.unlink('sub/a.txt')
380
os.unlink('sub/c.txt')
383
self.runbzr(('commit', '-m', 'Removed a.txt'))
385
print >> file('sub/a.txt', 'ab'), "something"
386
print >> file('b.txt', 'ab'), "something"
387
print >> file('sub/c.txt', 'ab'), "something"
388
self.runbzr(('commit', '-m', 'Modified a.txt'))
389
self.runbzr('merge ../a/', retcode=1)
390
self.assert_(os.path.exists('sub/a.txt.THIS'))
391
self.assert_(os.path.exists('sub/a.txt.BASE'))
393
self.runbzr('merge ../b/', retcode=1)
394
self.assert_(os.path.exists('sub/a.txt.OTHER'))
395
self.assert_(os.path.exists('sub/a.txt.BASE'))
397
309
def test_inventory(self):
398
310
bzr = self.runbzr
399
311
def output_equals(value, *args):
738
650
assert '|||||||' not in conflict_text
739
651
assert 'hi world' not in conflict_text
740
652
self.runbzr('remerge . --merge-type weave --show-base', retcode=3)
741
self.runbzr('remerge . --merge-type weave --reprocess', retcode=3)
742
653
self.runbzr('remerge . --show-base --reprocess', retcode=3)
654
self.runbzr('remerge . --merge-type weave --reprocess', retcode=1)
743
655
self.runbzr('remerge hello --show-base', retcode=1)
744
656
self.runbzr('remerge hello --reprocess', retcode=1)
745
657
self.runbzr('resolve --all')
779
691
self.assert_('|||||||' not in conflict_text)
780
692
self.assert_('hi world' not in conflict_text)
781
693
result = self.runbzr('conflicts', backtick=1)
782
self.assertEquals(result, "hello\nquestion\n")
694
self.assertEquals(result, "Text conflict in hello\nText conflict in"
783
696
result = self.runbzr('status', backtick=1)
784
self.assert_("conflicts:\n hello\n question\n" in result, result)
697
self.assert_("conflicts:\n Text conflict in hello\n"
698
" Text conflict in question\n" in result, result)
785
699
self.runbzr('resolve hello')
786
700
result = self.runbzr('conflicts', backtick=1)
787
self.assertEquals(result, "question\n")
701
self.assertEquals(result, "Text conflict in question\n")
788
702
self.runbzr('commit -m conflicts', retcode=3)
789
703
self.runbzr('resolve --all')
790
704
result = self.runbzr('conflicts', backtick=1)