253
252
out = self.run_bzr('pull ../branch_a', retcode=3,
254
253
working_dir='branch_b')
255
254
self.assertEqual(out,
256
('', 'brz: ERROR: These branches have diverged.'
257
' Use the missing command to see how.\n'
258
'Use the merge command to reconcile them.\n'))
255
('', 'brz: ERROR: These branches have diverged.'
256
' Use the missing command to see how.\n'
257
'Use the merge command to reconcile them.\n'))
259
258
tree_b = tree_b.controldir.open_workingtree()
260
259
branch_b = tree_b.branch
261
260
self.assertEqual(parent, branch_b.get_parent())
349
348
source.commit('commit 1')
350
349
target = source.controldir.sprout('target').open_workingtree()
351
350
source_last = source.commit('commit 2')
353
351
class FooService(object):
354
352
"""A directory service that always returns source"""
356
def look_up(self, name, url, purpose=None):
354
def look_up(self, name, url):
358
356
directories.register('foo:', FooService, 'Testing directory service')
359
357
self.addCleanup(directories.remove, 'foo:')
407
405
empty = self.make_branch_and_tree('empty', format='1.9')
408
406
self.reset_smart_call_log()
409
407
self.run_bzr(['pull', '-r', '1', self.get_url('stacked')],
411
409
# This figure represent the amount of work to perform this use case. It
412
410
# is entirely ok to reduce this number if a test fails due to rpc_count
413
411
# being too low. If rpc_count increases, more network roundtrips have
414
412
# become necessary for this use case. Please do not adjust this number
415
413
# upwards without agreement from bzr's network support maintainers.
416
self.assertLength(20, self.hpss_calls)
414
self.assertLength(19, self.hpss_calls)
417
415
self.assertLength(1, self.hpss_connections)
418
416
remote = branch.Branch.open('stacked')
419
417
self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
452
450
self.assertIsInstance(from_tree.branch, remote.RemoteBranch)
453
451
from_tree.commit(message='first commit')
454
452
out, err = self.run_bzr(['pull', '-d', 'to',
455
from_tree.branch.controldir.root_transport.base])
453
from_tree.branch.controldir.root_transport.base])
456
454
self.assertContainsRe(err,
457
"(?m)Doing on-the-fly conversion")
455
"(?m)Doing on-the-fly conversion")
459
457
def test_pull_to_experimental_format_warning(self):
460
458
"""You get a warning for pulling into experimental formats.
462
from_tree = self.make_branch_and_tree(
463
'from', format='development-subtree')
460
from_tree = self.make_branch_and_tree('from', format='development-subtree')
464
461
to_tree = self.make_branch_and_tree('to', format='development-subtree')
465
462
from_tree.commit(message='first commit')
466
463
out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
467
464
self.assertContainsRe(err,
468
"(?m)Fetching into experimental format")
465
"(?m)Fetching into experimental format")
470
467
def test_pull_cross_to_experimental_format_warning(self):
471
468
"""You get a warning for pulling into experimental formats.
520
517
"""pulling tags with conflicts will change the exit code"""
521
518
# create a branch, see that --show-base fails
522
519
from_tree = self.make_branch_and_tree('from')
523
from_tree.branch.tags.set_tag("mytag", b"somerevid")
520
from_tree.branch.tags.set_tag("mytag", "somerevid")
524
521
to_tree = self.make_branch_and_tree('to')
525
to_tree.branch.tags.set_tag("mytag", b"anotherrevid")
522
to_tree.branch.tags.set_tag("mytag", "anotherrevid")
526
523
out = self.run_bzr(['pull', '-d', 'to', 'from'], retcode=1)
527
524
self.assertEqual(out,
528
('No revisions to pull.\nConflicting tags:\n mytag\n', ''))
525
('No revisions to pull.\nConflicting tags:\n mytag\n', ''))
530
527
def test_pull_tag_notification(self):
531
528
"""pulling tags with conflicts will change the exit code"""
532
529
# create a branch, see that --show-base fails
533
530
from_tree = self.make_branch_and_tree('from')
534
from_tree.branch.tags.set_tag("mytag", b"somerevid")
531
from_tree.branch.tags.set_tag("mytag", "somerevid")
535
532
to_tree = self.make_branch_and_tree('to')
536
533
out = self.run_bzr(['pull', '-d', 'to', 'from'])
537
534
self.assertEqual(out,
538
('1 tag(s) updated.\n', ''))
535
('1 tag(s) updated.\n', ''))
540
537
def test_overwrite_tags(self):
541
538
"""--overwrite-tags only overwrites tags, not revisions."""
542
539
from_tree = self.make_branch_and_tree('from')
543
from_tree.branch.tags.set_tag("mytag", b"somerevid")
540
from_tree.branch.tags.set_tag("mytag", "somerevid")
544
541
to_tree = self.make_branch_and_tree('to')
545
to_tree.branch.tags.set_tag("mytag", b"anotherrevid")
542
to_tree.branch.tags.set_tag("mytag", "anotherrevid")
546
543
revid1 = to_tree.commit('my commit')
547
544
out = self.run_bzr(['pull', '-d', 'to', 'from'], retcode=1)
548
545
self.assertEqual(out,
549
('No revisions to pull.\nConflicting tags:\n mytag\n', ''))
546
('No revisions to pull.\nConflicting tags:\n mytag\n', ''))
550
547
out = self.run_bzr(['pull', '-d', 'to', '--overwrite-tags', 'from'])
551
548
self.assertEqual(out, ('1 tag(s) updated.\n', ''))
553
550
self.assertEqual(to_tree.branch.tags.lookup_tag('mytag'),
555
552
self.assertEqual(to_tree.branch.last_revision(), revid1)
557
554
def test_pull_tag_overwrite(self):
558
555
"""pulling tags with --overwrite only reports changed tags."""
559
556
# create a branch, see that --show-base fails
560
557
from_tree = self.make_branch_and_tree('from')
561
from_tree.branch.tags.set_tag("mytag", b"somerevid")
558
from_tree.branch.tags.set_tag("mytag", "somerevid")
562
559
to_tree = self.make_branch_and_tree('to')
563
to_tree.branch.tags.set_tag("mytag", b"somerevid")
560
to_tree.branch.tags.set_tag("mytag", "somerevid")
564
561
out = self.run_bzr(['pull', '--overwrite', '-d', 'to', 'from'])
565
562
self.assertEqual(out,
566
('No revisions or tags to pull.\n', ''))
563
('No revisions or tags to pull.\n', ''))
569
566
class TestPullOutput(script.TestCaseWithTransportAndScript):