27
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
28
# Note: Please don't add new tests here, it's too big and bulky. Instead add
29
# them into small suites for the particular function that's tested.
27
32
from cStringIO import StringIO
67
72
self.assert_(os.path.exists('subdir1'))
68
73
self.assert_(os.path.exists('subdir1/.bzr'))
70
self.runbzr('init subdir2/nothere', retcode=2)
75
self.runbzr('init subdir2/nothere', retcode=3)
72
77
os.mkdir('subdir2')
73
78
self.runbzr('init subdir2')
74
self.runbzr('init subdir2', retcode=1)
79
self.runbzr('init subdir2', retcode=3)
76
81
self.runbzr('init subdir2/subsubdir1')
77
82
self.assert_(os.path.exists('subdir2/subsubdir1/.bzr'))
107
112
if bzr_email is not None:
108
113
os.environ['BZREMAIL'] = bzr_email
115
def test_nick_command(self):
116
"""bzr nick for viewing, setting nicknames"""
120
nick = self.runbzr("nick",backtick=True)
121
self.assertEqual(nick, 'me.dev\n')
122
nick = self.runbzr("nick moo")
123
nick = self.runbzr("nick",backtick=True)
124
self.assertEqual(nick, 'moo\n')
110
127
def test_invalid_commands(self):
111
self.runbzr("pants", retcode=1)
112
self.runbzr("--pants off", retcode=1)
113
self.runbzr("diff --message foo", retcode=1)
128
self.runbzr("pants", retcode=3)
129
self.runbzr("--pants off", retcode=3)
130
self.runbzr("diff --message foo", retcode=3)
115
132
def test_empty_commit(self):
116
133
self.runbzr("init")
117
134
self.build_tree(['hello.txt'])
118
self.runbzr("commit -m empty", retcode=1)
135
self.runbzr("commit -m empty", retcode=3)
119
136
self.runbzr("add hello.txt")
120
self.runbzr("commit -m added")
137
self.runbzr("commit -m added")
122
139
def test_empty_commit_message(self):
123
140
self.runbzr("init")
124
141
file('foo.c', 'wt').write('int main() {}')
125
142
self.runbzr(['add', 'foo.c'])
126
self.runbzr(["commit", "-m", ""] , retcode=1)
143
self.runbzr(["commit", "-m", ""] , retcode=3)
128
145
def test_other_branch_commit(self):
129
146
# this branch is to ensure consistent behaviour, whether we're run
140
157
self.runbzr(['add', 'branch/foo.c'])
141
158
self.runbzr(['add', 'branch'])
142
159
# can't commit files in different trees; sane error
143
self.runbzr('commit -m newstuff branch/foo.c .', retcode=1)
160
self.runbzr('commit -m newstuff branch/foo.c .', retcode=3)
144
161
self.runbzr('commit -m newstuff branch/foo.c')
145
162
self.runbzr('commit -m newstuff branch')
146
self.runbzr('commit -m newstuff branch', retcode=1)
163
self.runbzr('commit -m newstuff branch', retcode=3)
149
166
def test_ignore_patterns(self):
225
242
self.runbzr('revert')
245
def test_status(self):
247
self.build_tree(['hello.txt'])
248
result = self.runbzr("status")
249
self.assert_("unknown:\n hello.txt\n" in result, result)
250
self.runbzr("add hello.txt")
251
result = self.runbzr("status")
252
self.assert_("added:\n hello.txt\n" in result, result)
253
self.runbzr("commit -m added")
254
result = self.runbzr("status -r 0..1")
255
self.assert_("added:\n hello.txt\n" in result, result)
256
self.build_tree(['world.txt'])
257
result = self.runbzr("status -r 0")
258
self.assert_("added:\n hello.txt\n" \
259
"unknown:\n world.txt\n" in result, result)
229
261
def test_mv_modes(self):
230
262
"""Test two modes of operation for mv"""
306
338
self.assert_('\n+hello world!' in output)
307
339
output = self.runbzr('diff -r last:3..last:1', backtick=1, retcode=1)
308
340
self.assert_('\n+baz' in output)
341
file('moo', 'wb').write('moo')
342
self.runbzr('add moo')
310
346
def test_diff_branches(self):
311
347
self.build_tree(['branch1/', 'branch1/file', 'branch2/'])
323
359
self.assertEquals(("=== modified file 'file'\n"
326
362
"@@ -1,1 +1,1 @@\n"
328
364
"+contents of branch1/file\n"
329
365
"\n", ''), output)
366
output = self.run_bzr_captured(['diff', 'branch2', 'branch1'],
368
self.assertEqualDiff(("=== modified file 'file'\n"
373
"+contents of branch1/file\n"
331
377
def test_branch(self):
332
378
"""Branch from one branch to another."""
363
409
file('hello', 'wt').write('quuux')
364
410
# We can't merge when there are in-tree changes
365
self.runbzr('merge ../b', retcode=1)
411
self.runbzr('merge ../b', retcode=3)
366
412
self.runbzr(['commit', '-m', "Like an epidemic of u's"])
367
413
self.runbzr('merge ../b -r last:1..last:1 --merge-type blooof',
369
415
self.runbzr('merge ../b -r last:1..last:1 --merge-type merge3')
370
416
self.runbzr('revert --no-backup')
371
417
self.runbzr('merge ../b -r last:1..last:1 --merge-type weave')
427
473
self.example_branch()
428
self.runbzr('pull', retcode=1)
429
self.runbzr('missing', retcode=1)
474
self.runbzr('pull', retcode=3)
475
self.runbzr('missing', retcode=3)
430
476
self.runbzr('missing .')
431
477
self.runbzr('missing')
432
478
self.runbzr('pull')
433
self.runbzr('pull /', retcode=1)
479
self.runbzr('pull /', retcode=3)
434
480
self.runbzr('pull')
451
497
self.runbzr('commit -m blah3 --unchanged')
453
self.runbzr('pull ../a', retcode=1)
499
self.runbzr('pull ../a', retcode=3)
455
501
self.runbzr('branch b overwriteme')
456
502
os.chdir('overwriteme')
490
536
open('a', 'wb').write('hello\n')
492
538
# Can't supply both
493
bzr('ls --verbose --null', retcode=1)
539
bzr('ls --verbose --null', retcode=3)
496
542
ls_equals('? a\n', '--verbose')
584
630
self.runbzr('init')
585
631
self.runbzr('commit -m unchanged --unchanged')
586
self.runbzr('pull', retcode=1)
587
self.runbzr('merge', retcode=1)
632
self.runbzr('pull', retcode=3)
633
self.runbzr('merge', retcode=3)
588
634
self.runbzr('branch . ../b')
590
636
self.runbzr('pull')
629
675
def test_unknown_command(self):
630
676
"""Handling of unknown command."""
631
677
out, err = self.run_bzr_captured(['fluffy-badger'],
633
679
self.assertEquals(out, '')
634
680
err.index('unknown command')
636
def test_conflicts(self):
637
"""Handling of merge conflicts"""
682
def create_conflicts(self):
683
"""Create a conflicted tree"""
640
686
file('hello', 'wb').write("hi world")
654
700
file('question', 'wb').write("What do you get when you multiply six"
656
702
self.runbzr('commit -m this')
704
def test_remerge(self):
705
"""Remerge command works as expected"""
706
self.create_conflicts()
707
self.runbzr('merge ../other --show-base', retcode=1)
708
conflict_text = file('hello').read()
709
assert '|||||||' in conflict_text
710
assert 'hi world' in conflict_text
711
self.runbzr('remerge', retcode=1)
712
conflict_text = file('hello').read()
713
assert '|||||||' not in conflict_text
714
assert 'hi world' not in conflict_text
715
os.unlink('hello.OTHER')
716
self.runbzr('remerge hello --merge-type weave', retcode=1)
717
assert os.path.exists('hello.OTHER')
718
file_id = self.runbzr('file-id hello')
719
file_id = self.runbzr('file-id hello.THIS', retcode=3)
720
self.runbzr('remerge --merge-type weave', retcode=1)
721
assert os.path.exists('hello.OTHER')
722
assert not os.path.exists('hello.BASE')
723
assert '|||||||' not in conflict_text
724
assert 'hi world' not in conflict_text
725
self.runbzr('remerge . --merge-type weave --show-base', retcode=3)
726
self.runbzr('remerge . --merge-type weave --reprocess', retcode=3)
727
self.runbzr('remerge . --show-base --reprocess', retcode=3)
728
self.runbzr('remerge hello --show-base', retcode=1)
729
self.runbzr('remerge hello --reprocess', retcode=1)
730
self.runbzr('resolve --all')
731
self.runbzr('commit -m done',)
732
self.runbzr('remerge', retcode=3)
735
def test_conflicts(self):
736
"""Handling of merge conflicts"""
737
self.create_conflicts()
657
738
self.runbzr('merge ../other --show-base', retcode=1)
658
739
conflict_text = file('hello').read()
659
740
self.assert_('<<<<<<<' in conflict_text)
674
755
self.runbzr('resolve hello')
675
756
result = self.runbzr('conflicts', backtick=1)
676
757
self.assertEquals(result, "question\n")
677
self.runbzr('commit -m conflicts', retcode=1)
758
self.runbzr('commit -m conflicts', retcode=3)
678
759
self.runbzr('resolve --all')
679
760
result = self.runbzr('conflicts', backtick=1)
680
761
self.runbzr('commit -m conflicts')
724
805
self.example_branch()
726
807
# with no push target, fail
727
self.runbzr('push', retcode=1)
808
self.runbzr('push', retcode=3)
728
809
# with an explicit target work
729
810
self.runbzr('push ../output-branch')
730
811
# with an implicit target work
744
825
self.runbzr('commit --unchanged -m unchanged')
745
826
os.chdir('../my-branch')
746
827
# cannot push now
747
self.runbzr('push', retcode=1)
828
self.runbzr('push', retcode=3)
748
829
# and there are difference
749
830
self.runbzr('missing ../output-branch', retcode=1)
831
self.runbzr('missing --verbose ../output-branch', retcode=1)
750
832
# but we can force a push
751
833
self.runbzr('push --overwrite')
752
834
# nothing missing
753
835
self.runbzr('missing ../output-branch')
755
837
# pushing to a new dir with no parent should fail
756
self.runbzr('push ../missing/new-branch', retcode=1)
838
self.runbzr('push ../missing/new-branch', retcode=3)
757
839
# unless we provide --create-prefix
758
840
self.runbzr('push --create-prefix ../missing/new-branch')
759
841
# nothing missing
825
907
runbzr("help st")
827
909
runbzr("help commands")
828
runbzr("help slartibartfast", 1)
910
runbzr("help slartibartfast", 3)
830
912
out = capture("help ci")
831
913
out.index('aliases: ')
833
915
progress("can't rename unversioned file")
834
runbzr("rename test.txt new-test.txt", 1)
916
runbzr("rename test.txt new-test.txt", 3)
836
918
progress("adding a file")
852
934
progress("more complex renames")
854
runbzr("rename hello.txt sub1", 1)
855
runbzr("rename hello.txt sub1/hello.txt", 1)
856
runbzr("move hello.txt sub1", 1)
936
runbzr("rename hello.txt sub1", 3)
937
runbzr("rename hello.txt sub1/hello.txt", 3)
938
runbzr("move hello.txt sub1", 3)
858
940
runbzr("add sub1")
859
941
runbzr("rename sub1 sub2")
913
995
runbzr('log -v --forward')
914
runbzr('log -m', retcode=1)
996
runbzr('log -m', retcode=3)
915
997
log_out = capture('log -m commit')
916
998
self.assert_("this is my new commit\n and" in log_out)
917
999
self.assert_("rename nested" not in log_out)
1058
1140
branch.commit('add file', rev_id='A')
1059
1141
url = self.get_remote_url('branch/file')
1060
1142
output = self.capture('log %s' % url)
1061
self.assertEqual(7, len(output.split('\n')))
1143
self.assertEqual(8, len(output.split('\n')))