142
142
self.runbzr(['add', 'foo.c'])
143
143
self.runbzr(["commit", "-m", ""] , retcode=3)
145
def test_remove_deleted(self):
147
self.build_tree(['a'])
148
self.runbzr(['add', 'a'])
149
self.runbzr(['commit', '-m', 'added a'])
151
self.runbzr(['remove', 'a'])
145
153
def test_other_branch_commit(self):
146
154
# this branch is to ensure consistent behaviour, whether we're run
147
155
# inside a branch, or not.
347
355
self.build_tree(['branch1/', 'branch1/file', 'branch2/'])
348
356
branch = Branch.initialize('branch1')
349
357
branch.add(['file'])
350
branch.commit('add file')
358
branch.working_tree().commit('add file')
351
359
copy_branch(branch, 'branch2')
352
360
print >> open('branch2/file', 'w'), 'new content'
353
361
branch2 = Branch.open('branch2')
354
branch2.commit('update file')
362
branch2.working_tree().commit('update file')
355
363
# should open branch1 and diff against branch2,
356
364
output = self.run_bzr_captured(['diff', '-r', 'branch:branch2',
424
432
a = Branch.open('.')
425
433
b = Branch.open('../b')
426
434
a.get_revision_xml(b.last_revision())
427
self.log('pending merges: %s', a.pending_merges())
428
self.assertEquals(a.pending_merges(), [b.last_revision()])
435
self.log('pending merges: %s', a.working_tree().pending_merges())
436
self.assertEquals(a.working_tree().pending_merges(),
429
438
self.runbzr('commit -m merged')
430
439
self.runbzr('merge ../b -r last:1')
431
self.assertEqual(Branch.open('.').pending_merges(), [])
440
self.assertEqual(Branch.open('.').working_tree().pending_merges(), [])
434
442
def test_merge_with_missing_file(self):
435
443
"""Merge handles missing file conflicts"""
633
def test_pull_verbose(self):
634
"""Pull changes from one branch to another and watch the output."""
640
self.example_branch()
645
open('b', 'wb').write('else\n')
647
bzr(['commit', '-m', 'added b'])
650
out = bzr('pull --verbose ../b', backtick=True)
651
self.failIfEqual(out.find('Added Revisions:'), -1)
652
self.failIfEqual(out.find('message:\n added b'), -1)
653
self.failIfEqual(out.find('added b'), -1)
655
# Check that --overwrite --verbose prints out the removed entries
656
bzr('commit -m foo --unchanged')
658
bzr('commit -m baz --unchanged')
659
bzr('pull ../a', retcode=3)
660
out = bzr('pull --overwrite --verbose ../a', backtick=1)
662
remove_loc = out.find('Removed Revisions:')
663
self.failIfEqual(remove_loc, -1)
664
added_loc = out.find('Added Revisions:')
665
self.failIfEqual(added_loc, -1)
667
removed_message = out.find('message:\n baz')
668
self.failIfEqual(removed_message, -1)
669
self.failUnless(remove_loc < removed_message < added_loc)
671
added_message = out.find('message:\n foo')
672
self.failIfEqual(added_message, -1)
673
self.failUnless(added_loc < added_message)
626
675
def test_locations(self):
627
676
"""Using and remembering different locations"""
655
704
"""add command prints the names of added files."""
656
705
b = Branch.initialize('.')
657
706
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
658
out = self.run_bzr_captured(['add'], retcode = 0)[0]
707
out = self.run_bzr_captured(['add'], retcode=0)[0]
659
708
# the ordering is not defined at the moment
660
709
results = sorted(out.rstrip('\n').split('\n'))
661
710
self.assertEquals(['added dir',
667
716
"""add -q does not print the names of added files."""
668
717
b = Branch.initialize('.')
669
718
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
670
out = self.run_bzr_captured(['add', '-q'], retcode = 0)[0]
719
out = self.run_bzr_captured(['add', '-q'], retcode=0)[0]
671
720
# the ordering is not defined at the moment
672
721
results = sorted(out.rstrip('\n').split('\n'))
673
722
self.assertEquals([''], results)
766
815
import bzrlib.gpg
767
816
oldstrategy = bzrlib.gpg.GPGStrategy
768
817
branch = Branch.initialize('.')
769
branch.commit("base", allow_pointless=True, rev_id='A')
818
branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
771
820
# monkey patch gpg signing mechanism
772
821
from bzrlib.testament import Testament
781
830
import bzrlib.gpg
782
831
oldstrategy = bzrlib.gpg.GPGStrategy
783
832
branch = Branch.initialize('.')
784
branch.commit("base", allow_pointless=True, rev_id='A')
785
branch.commit("base", allow_pointless=True, rev_id='B')
786
branch.commit("base", allow_pointless=True, rev_id='C')
833
branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
834
branch.working_tree().commit("base", allow_pointless=True, rev_id='B')
835
branch.working_tree().commit("base", allow_pointless=True, rev_id='C')
788
837
# monkey patch gpg signing mechanism
789
838
from bzrlib.testament import Testament
841
890
# nothing missing
842
891
self.runbzr('missing ../missing/new-branch')
893
def test_external_command(self):
894
"""test that external commands can be run by setting the path"""
895
cmd_name = 'test-command'
896
output = 'Hello from test-command'
897
if sys.platform == 'win32':
903
oldpath = os.environ.get('BZRPATH', None)
908
if os.environ.has_key('BZRPATH'):
909
del os.environ['BZRPATH']
911
f = file(cmd_name, 'wb')
912
if sys.platform == 'win32':
913
f.write('@echo off\n')
915
f.write('#!/bin/sh\n')
916
f.write('echo Hello from test-command')
918
os.chmod(cmd_name, 0755)
920
# It should not find the command in the local
921
# directory by default, since it is not in my path
922
bzr(cmd_name, retcode=3)
924
# Now put it into my path
925
os.environ['BZRPATH'] = '.'
928
# The test suite does not capture stdout for external commands
929
# this is because you have to have a real file object
930
# to pass to Popen(stdout=FOO), and StringIO is not one of those.
931
# (just replacing sys.stdout does not change a spawned objects stdout)
932
#self.assertEquals(bzr(cmd_name), output)
934
# Make sure empty path elements are ignored
935
os.environ['BZRPATH'] = os.pathsep
937
bzr(cmd_name, retcode=3)
941
os.environ['BZRPATH'] = oldpath
845
944
def listdir_sorted(dir):
846
945
L = os.listdir(dir)
1127
1226
def test_branch(self):
1128
1227
os.mkdir('from')
1129
1228
branch = Branch.initialize('from')
1130
branch.commit('empty commit for nonsense', allow_pointless=True)
1229
branch.working_tree().commit('empty commit for nonsense', allow_pointless=True)
1131
1230
url = self.get_remote_url('from')
1132
1231
self.run_bzr('branch', url, 'to')
1133
1232
branch = Branch.open('to')
1137
1236
self.build_tree(['branch/', 'branch/file'])
1138
1237
branch = Branch.initialize('branch')
1139
1238
branch.add(['file'])
1140
branch.commit('add file', rev_id='A')
1239
branch.working_tree().commit('add file', rev_id='A')
1141
1240
url = self.get_remote_url('branch/file')
1142
1241
output = self.capture('log %s' % url)
1143
1242
self.assertEqual(8, len(output.split('\n')))