45
45
def example_branch(self, path='.'):
46
46
tree = self.make_branch_and_tree(path)
47
47
self.build_tree_contents([
48
(osutils.pathjoin(path, 'hello'), b'foo'),
48
(osutils.pathjoin(path, 'hello'), b'foo'),
49
49
(osutils.pathjoin(path, 'goodbye'), b'baz')])
51
51
tree.commit(message='setup')
128
128
a_tree.commit(message="setup")
130
130
b_tree = a_tree.controldir.sprout(
131
'b', revision_id=a_tree.branch.get_rev_id(1)).open_workingtree()
131
'b', revision_id=a_tree.branch.get_rev_id(1)).open_workingtree()
132
132
self.run_bzr('pull -r 2', working_dir='b')
133
133
a = branch.Branch.open('a')
134
134
b = branch.Branch.open('b')
146
146
# Make a source, sprout a target off it
147
147
builder = self.make_branch_builder('source')
148
source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(builder)
148
source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(
149
150
source.get_config_stack().set('branch.fetch_tags', True)
150
151
target_bzrdir = source.controldir.sprout('target')
151
152
source.tags.set_tag('tag-a', rev2)
244
245
# test pull for failure without parent set
245
246
out = self.run_bzr('pull', retcode=3, working_dir='branch_b')
246
247
self.assertEqual(out,
247
('', 'brz: ERROR: No pull location known or specified.\n'))
248
('', 'brz: ERROR: No pull location known or specified.\n'))
248
249
# test implicit --remember when no parent set, this pull conflicts
249
250
self.build_tree(['branch_b/d'])
252
253
out = self.run_bzr('pull ../branch_a', retcode=3,
253
254
working_dir='branch_b')
254
255
self.assertEqual(out,
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'))
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'))
258
259
tree_b = tree_b.controldir.open_workingtree()
259
260
branch_b = tree_b.branch
260
261
self.assertEqual(parent, branch_b.get_parent())
273
274
branch_b.get_parent())
275
276
def test_pull_bundle(self):
276
from breezy.testament import Testament
277
from breezy.bzr.testament import Testament
277
278
# Build up 2 trees and prepare for a pull
278
279
tree_a = self.make_branch_and_tree('branch_a')
279
280
with open('branch_a/a', 'wb') as f:
295
296
self.assertEqual(out,
296
297
'Now on revision 2.\n')
297
298
self.assertEqual(err,
298
' M a\nAll changes applied successfully.\n')
299
' M a\nAll changes applied successfully.\n')
300
301
self.assertEqualDiff(tree_a.branch.last_revision(),
301
302
tree_b.branch.last_revision())
348
349
source.commit('commit 1')
349
350
target = source.controldir.sprout('target').open_workingtree()
350
351
source_last = source.commit('commit 2')
351
353
class FooService(object):
352
354
"""A directory service that always returns source"""
354
def look_up(self, name, url):
356
def look_up(self, name, url, purpose=None):
356
358
directories.register('foo:', FooService, 'Testing directory service')
357
359
self.addCleanup(directories.remove, 'foo:')
405
407
empty = self.make_branch_and_tree('empty', format='1.9')
406
408
self.reset_smart_call_log()
407
409
self.run_bzr(['pull', '-r', '1', self.get_url('stacked')],
409
411
# This figure represent the amount of work to perform this use case. It
410
412
# is entirely ok to reduce this number if a test fails due to rpc_count
411
413
# being too low. If rpc_count increases, more network roundtrips have
425
427
from_tree.commit(message='first commit')
426
428
out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
427
429
self.assertContainsRe(err,
428
"(?m)Doing on-the-fly conversion")
430
"(?m)Doing on-the-fly conversion")
430
432
def test_pull_cross_format_warning_no_IDS(self):
431
433
"""You get a warning for probably slow cross-format pulls.
441
443
from_tree.commit(message='first commit')
442
444
out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
443
445
self.assertContainsRe(err,
444
"(?m)Doing on-the-fly conversion")
446
"(?m)Doing on-the-fly conversion")
446
448
def test_pull_cross_format_from_network(self):
447
449
self.setup_smart_server_with_call_log()
450
452
self.assertIsInstance(from_tree.branch, remote.RemoteBranch)
451
453
from_tree.commit(message='first commit')
452
454
out, err = self.run_bzr(['pull', '-d', 'to',
453
from_tree.branch.controldir.root_transport.base])
455
from_tree.branch.controldir.root_transport.base])
454
456
self.assertContainsRe(err,
455
"(?m)Doing on-the-fly conversion")
457
"(?m)Doing on-the-fly conversion")
457
459
def test_pull_to_experimental_format_warning(self):
458
460
"""You get a warning for pulling into experimental formats.
460
from_tree = self.make_branch_and_tree('from', format='development-subtree')
462
from_tree = self.make_branch_and_tree(
463
'from', format='development-subtree')
461
464
to_tree = self.make_branch_and_tree('to', format='development-subtree')
462
465
from_tree.commit(message='first commit')
463
466
out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
464
467
self.assertContainsRe(err,
465
"(?m)Fetching into experimental format")
468
"(?m)Fetching into experimental format")
467
470
def test_pull_cross_to_experimental_format_warning(self):
468
471
"""You get a warning for pulling into experimental formats.
472
475
from_tree.commit(message='first commit')
473
476
out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
474
477
self.assertContainsRe(err,
475
"(?m)Fetching into experimental format")
478
"(?m)Fetching into experimental format")
477
480
def test_pull_show_base(self):
478
481
"""brz pull supports --show-base
490
493
with open(osutils.pathjoin('b', 'hello'), 'wt') as f:
493
out, err=self.run_bzr(['pull', '-d', 'b', 'a', '--show-base'])
496
out, err = self.run_bzr(['pull', '-d', 'b', 'a', '--show-base'])
495
498
# check for message here
496
499
self.assertEqual(
522
525
to_tree.branch.tags.set_tag("mytag", b"anotherrevid")
523
526
out = self.run_bzr(['pull', '-d', 'to', 'from'], retcode=1)
524
527
self.assertEqual(out,
525
('No revisions to pull.\nConflicting tags:\n mytag\n', ''))
528
('No revisions to pull.\nConflicting tags:\n mytag\n', ''))
527
530
def test_pull_tag_notification(self):
528
531
"""pulling tags with conflicts will change the exit code"""
532
535
to_tree = self.make_branch_and_tree('to')
533
536
out = self.run_bzr(['pull', '-d', 'to', 'from'])
534
537
self.assertEqual(out,
535
('1 tag(s) updated.\n', ''))
538
('1 tag(s) updated.\n', ''))
537
540
def test_overwrite_tags(self):
538
541
"""--overwrite-tags only overwrites tags, not revisions."""
543
546
revid1 = to_tree.commit('my commit')
544
547
out = self.run_bzr(['pull', '-d', 'to', 'from'], retcode=1)
545
548
self.assertEqual(out,
546
('No revisions to pull.\nConflicting tags:\n mytag\n', ''))
549
('No revisions to pull.\nConflicting tags:\n mytag\n', ''))
547
550
out = self.run_bzr(['pull', '-d', 'to', '--overwrite-tags', 'from'])
548
551
self.assertEqual(out, ('1 tag(s) updated.\n', ''))
550
553
self.assertEqual(to_tree.branch.tags.lookup_tag('mytag'),
552
555
self.assertEqual(to_tree.branch.last_revision(), revid1)
554
557
def test_pull_tag_overwrite(self):
560
563
to_tree.branch.tags.set_tag("mytag", b"somerevid")
561
564
out = self.run_bzr(['pull', '--overwrite', '-d', 'to', 'from'])
562
565
self.assertEqual(out,
563
('No revisions or tags to pull.\n', ''))
566
('No revisions or tags to pull.\n', ''))
566
569
class TestPullOutput(script.TestCaseWithTransportAndScript):