29
29
from bzrlib.branch import Branch
30
30
from bzrlib.directory_service import directories
31
31
from bzrlib.osutils import pathjoin
32
from bzrlib.tests import (
34
TestCaseWithTransport,
32
from bzrlib.tests import TestCaseWithTransport
36
33
from bzrlib.uncommit import uncommit
37
34
from bzrlib.workingtree import WorkingTree
145
142
self.run_bzr('pull -r 4')
146
143
self.assertEqual(a.revision_history(), b.revision_history())
148
def test_pull_tags(self):
149
"""Tags are updated by pull, and revisions named in those tags are
152
# Make a source, sprout a target off it
153
builder = self.make_branch_builder('source')
154
source = fixtures.build_branch_with_non_ancestral_rev(builder)
155
target_bzrdir = source.bzrdir.sprout('target')
156
source.tags.set_tag('tag-a', 'rev-2')
158
self.run_bzr('pull -d target source')
159
target = target_bzrdir.open_branch()
160
# The tag is present, and so is its revision.
161
self.assertEqual('rev-2', target.tags.lookup_tag('tag-a'))
162
target.repository.get_revision('rev-2')
164
146
def test_overwrite_uptodate(self):
165
147
# Make sure pull --overwrite overwrites
471
453
out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
472
454
self.assertContainsRe(err,
473
455
"(?m)Fetching into experimental format")
475
def test_pull_show_base(self):
476
"""bzr pull supports --show-base
478
see https://bugs.launchpad.net/bzr/+bug/202374"""
479
# create two trees with conflicts, setup conflict, check that
480
# conflicted file looks correct
481
a_tree = self.example_branch('a')
482
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
484
f = open(pathjoin('a', 'hello'),'wt')
489
f = open(pathjoin('b', 'hello'),'wt')
493
out,err=self.run_bzr(['pull','-d','b','a','--show-base'])
495
# check for message here
496
self.assertEqual(err,
497
' M hello\nText conflict in hello\n1 conflicts encountered.\n')
499
self.assertEqualDiff('<<<<<<< TREE\n'
500
'fie||||||| BASE-REVISION\n'
502
'fee>>>>>>> MERGE-SOURCE\n',
503
open(pathjoin('b', 'hello')).read())
505
def test_pull_show_base_working_tree_only(self):
506
"""--show-base only allowed if there's a working tree
508
see https://bugs.launchpad.net/bzr/+bug/202374"""
509
# create a branch, see that --show-base fails
510
self.make_branch('from')
511
self.make_branch('to')
512
out=self.run_bzr(['pull','-d','to','from','--show-base'],retcode=3)
513
self.assertEqual(out,
514
('','bzr: ERROR: Need working tree for --show-base.\n'))
516
def test_pull_tag_conflicts(self):
517
"""pulling tags with conflicts will change the exit code"""
518
# create a branch, see that --show-base fails
519
from_tree = self.make_branch_and_tree('from')
520
from_tree.branch.tags.set_tag("mytag", "somerevid")
521
to_tree = self.make_branch_and_tree('to')
522
to_tree.branch.tags.set_tag("mytag", "anotherrevid")
523
out = self.run_bzr(['pull','-d','to','from'],retcode=1)
524
self.assertEqual(out,
525
('No revisions to pull.\nConflicting tags:\n mytag\n', ''))