362
337
def look_up(self, name, url):
364
339
directories.register('foo:', FooService, 'Testing directory service')
365
self.addCleanup(directories.remove, 'foo:')
340
self.addCleanup(lambda: directories.remove('foo:'))
366
341
self.run_bzr('pull foo:bar -d target')
367
342
self.assertEqual(source_last, target.last_revision())
369
def test_pull_verbose_defaults_to_long(self):
370
tree = self.example_branch('source')
371
target = self.make_branch_and_tree('target')
372
out = self.run_bzr('pull -v source -d target')[0]
373
self.assertContainsRe(out,
374
r'revno: 1\ncommitter: .*\nbranch nick: source')
375
self.assertNotContainsRe(out, r'\n {4}1 .*\n {6}setup\n')
377
def test_pull_verbose_uses_default_log(self):
378
tree = self.example_branch('source')
379
target = self.make_branch_and_tree('target')
380
target_config = target.branch.get_config()
381
target_config.set_user_option('log_format', 'short')
382
out = self.run_bzr('pull -v source -d target')[0]
383
self.assertContainsRe(out, r'\n {4}1 .*\n {6}setup\n')
384
self.assertNotContainsRe(
385
out, r'revno: 1\ncommitter: .*\nbranch nick: source')
387
def test_pull_smart_stacked_streaming_acceptance(self):
388
"""'bzr pull -r 123' works on stacked, smart branches, even when the
389
revision specified by the revno is only present in the fallback
392
See <https://launchpad.net/bugs/380314>
394
self.setup_smart_server_with_call_log()
395
# Make a stacked-on branch with two commits so that the
396
# revision-history can't be determined just by looking at the parent
397
# field in the revision in the stacked repo.
398
parent = self.make_branch_and_tree('parent', format='1.9')
399
parent.commit(message='first commit')
400
parent.commit(message='second commit')
401
local = parent.bzrdir.sprout('local').open_workingtree()
402
local.commit(message='local commit')
403
local.branch.create_clone_on_transport(
404
self.get_transport('stacked'), stacked_on=self.get_url('parent'))
405
empty = self.make_branch_and_tree('empty', format='1.9')
406
self.reset_smart_call_log()
407
self.run_bzr(['pull', '-r', '1', self.get_url('stacked')],
409
# This figure represent the amount of work to perform this use case. It
410
# is entirely ok to reduce this number if a test fails due to rpc_count
411
# being too low. If rpc_count increases, more network roundtrips have
412
# become necessary for this use case. Please do not adjust this number
413
# upwards without agreement from bzr's network support maintainers.
414
self.assertLength(19, self.hpss_calls)
415
remote = Branch.open('stacked')
416
self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
418
def test_pull_cross_format_warning(self):
419
"""You get a warning for probably slow cross-format pulls.
421
# this is assumed to be going through InterDifferingSerializer
422
from_tree = self.make_branch_and_tree('from', format='2a')
423
to_tree = self.make_branch_and_tree('to', format='1.14-rich-root')
424
from_tree.commit(message='first commit')
425
out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
426
self.assertContainsRe(err,
427
"(?m)Doing on-the-fly conversion")
429
def test_pull_cross_format_warning_no_IDS(self):
430
"""You get a warning for probably slow cross-format pulls.
432
# this simulates what would happen across the network, where
433
# interdifferingserializer is not active
435
debug.debug_flags.add('IDS_never')
436
# TestCase take care of restoring them
438
from_tree = self.make_branch_and_tree('from', format='2a')
439
to_tree = self.make_branch_and_tree('to', format='1.14-rich-root')
440
from_tree.commit(message='first commit')
441
out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
442
self.assertContainsRe(err,
443
"(?m)Doing on-the-fly conversion")
445
def test_pull_cross_format_from_network(self):
446
self.setup_smart_server_with_call_log()
447
from_tree = self.make_branch_and_tree('from', format='2a')
448
to_tree = self.make_branch_and_tree('to', format='1.14-rich-root')
449
self.assertIsInstance(from_tree.branch, remote.RemoteBranch)
450
from_tree.commit(message='first commit')
451
out, err = self.run_bzr(['pull', '-d', 'to',
452
from_tree.branch.bzrdir.root_transport.base])
453
self.assertContainsRe(err,
454
"(?m)Doing on-the-fly conversion")
456
def test_pull_to_experimental_format_warning(self):
457
"""You get a warning for pulling into experimental formats.
459
from_tree = self.make_branch_and_tree('from', format='development-subtree')
460
to_tree = self.make_branch_and_tree('to', format='development-subtree')
461
from_tree.commit(message='first commit')
462
out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
463
self.assertContainsRe(err,
464
"(?m)Fetching into experimental format")
466
def test_pull_cross_to_experimental_format_warning(self):
467
"""You get a warning for pulling into experimental formats.
469
from_tree = self.make_branch_and_tree('from', format='2a')
470
to_tree = self.make_branch_and_tree('to', format='development-subtree')
471
from_tree.commit(message='first commit')
472
out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
473
self.assertContainsRe(err,
474
"(?m)Fetching into experimental format")
476
def test_pull_show_base(self):
477
"""bzr pull supports --show-base
479
see https://bugs.launchpad.net/bzr/+bug/202374"""
480
# create two trees with conflicts, setup conflict, check that
481
# conflicted file looks correct
482
a_tree = self.example_branch('a')
483
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
485
f = open(pathjoin('a', 'hello'),'wt')
490
f = open(pathjoin('b', 'hello'),'wt')
494
out,err=self.run_bzr(['pull','-d','b','a','--show-base'])
496
# check for message here
497
self.assertEqual(err,
498
' M hello\nText conflict in hello\n1 conflicts encountered.\n')
500
self.assertEqualDiff('<<<<<<< TREE\n'
501
'fie||||||| BASE-REVISION\n'
503
'fee>>>>>>> MERGE-SOURCE\n',
504
open(pathjoin('b', 'hello')).read())
506
def test_pull_show_base_working_tree_only(self):
507
"""--show-base only allowed if there's a working tree
509
see https://bugs.launchpad.net/bzr/+bug/202374"""
510
# create a branch, see that --show-base fails
511
self.make_branch('from')
512
self.make_branch('to')
513
out=self.run_bzr(['pull','-d','to','from','--show-base'],retcode=3)
514
self.assertEqual(out,
515
('','bzr: ERROR: Need working tree for --show-base.\n'))
517
def test_pull_tag_conflicts(self):
518
"""pulling tags with conflicts will change the exit code"""
519
# create a branch, see that --show-base fails
520
from_tree = self.make_branch_and_tree('from')
521
from_tree.branch.tags.set_tag("mytag", "somerevid")
522
to_tree = self.make_branch_and_tree('to')
523
to_tree.branch.tags.set_tag("mytag", "anotherrevid")
524
out = self.run_bzr(['pull','-d','to','from'],retcode=1)
525
self.assertEqual(out,
526
('No revisions to pull.\nConflicting tags:\n mytag\n', ''))