33
33
from bzrlib.branch import Branch
34
from bzrlib.clone import copy_branch
34
35
from bzrlib.errors import BzrCommandError
35
36
from bzrlib.osutils import has_symlinks
36
37
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
265
266
output = self.runbzr('diff -r last:3..last:1', backtick=1)
266
267
self.assert_('\n+baz' in output)
269
def test_diff_branches(self):
270
self.build_tree(['branch1/', 'branch1/file', 'branch2/'])
271
branch = Branch.initialize('branch1')
273
branch.commit('add file')
274
copy_branch(branch, 'branch2')
275
print >> open('branch2/file', 'w'), 'new content'
276
branch2 = Branch.open('branch2')
277
branch2.commit('update file')
278
# should open branch1 and diff against branch2,
279
output = self.run_bzr_captured(['diff', '-r', 'branch:branch2', 'branch1'])
280
self.assertEquals(("=== modified file 'file'\n"
285
"+contents of branch1/file\n"
268
288
def test_branch(self):
269
289
"""Branch from one branch to another."""
344
364
assert os.path.exists('sub/a.txt.OTHER')
345
365
assert os.path.exists('sub/a.txt.BASE')
347
def test_merge_with_missing_file(self):
348
"""Merge handles missing file conflicts"""
352
print >> file('sub/a.txt', 'wb'), "hello"
353
print >> file('b.txt', 'wb'), "hello"
354
print >> file('sub/c.txt', 'wb'), "hello"
357
self.runbzr(('commit', '-m', 'added a'))
358
self.runbzr('branch . ../b')
359
print >> file('sub/a.txt', 'ab'), "there"
360
print >> file('b.txt', 'ab'), "there"
361
print >> file('sub/c.txt', 'ab'), "there"
362
self.runbzr(('commit', '-m', 'Added there'))
363
os.unlink('sub/a.txt')
364
os.unlink('sub/c.txt')
367
self.runbzr(('commit', '-m', 'Removed a.txt'))
369
print >> file('sub/a.txt', 'ab'), "something"
370
print >> file('b.txt', 'ab'), "something"
371
print >> file('sub/c.txt', 'ab'), "something"
372
self.runbzr(('commit', '-m', 'Modified a.txt'))
373
self.runbzr('merge ../a/')
374
assert os.path.exists('sub/a.txt.THIS')
375
assert os.path.exists('sub/a.txt.BASE')
377
self.runbzr('merge ../b/')
378
assert os.path.exists('sub/a.txt.OTHER')
379
assert os.path.exists('sub/a.txt.BASE')
381
367
def test_pull(self):
382
368
"""Pull changes from one branch to another."""
728
714
runbzr('remove d2/link1')
729
715
assert self.capture('unknowns') == 'd2/link1\n'
730
716
runbzr(['commit', '-m', '5: remove d2/link1'])
717
# try with the rm alias
718
runbzr('add d2/link1')
719
runbzr(['commit', '-m', '6: add d2/link1'])
720
runbzr('rm d2/link1')
721
assert self.capture('unknowns') == 'd2/link1\n'
722
runbzr(['commit', '-m', '7: remove d2/link1'])
734
726
runbzr('rename d2/link3 d1/link3new')
735
727
assert self.capture('unknowns') == 'd2/link1\n'
736
runbzr(['commit', '-m', '6: remove d2/link1, move/rename link3'])
728
runbzr(['commit', '-m', '8: remove d2/link1, move/rename link3'])
738
730
runbzr(['check'])
771
763
assert listdir_sorted("d2")== [ "link3" ]
774
runbzr(['export', '-r', '6', 'exp6.tmp'])
766
runbzr(['export', '-r', '8', 'exp6.tmp'])
775
767
chdir("exp6.tmp")
776
assert listdir_sorted(".") == [ "d1", "d2", "link2" ]
768
self.assertEqual(listdir_sorted("."), [ "d1", "d2", "link2"])
777
769
assert listdir_sorted("d1") == [ "link3new" ]
778
770
assert listdir_sorted("d2") == []
779
771
assert os.readlink("d1/link3new") == "NOWHERE3"