/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/blackbox/test_pull.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-02 02:35:46 UTC
  • mfrom: (7309 work)
  • mto: This revision was merged to the branch mainline in revision 7319.
  • Revision ID: jelmer@jelmer.uk-20190602023546-lqco868tnv26d8ow
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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')])
50
50
        tree.add('hello')
51
51
        tree.commit(message='setup')
120
120
        """Pull some changes from one branch to another."""
121
121
        a_tree = self.example_branch('a')
122
122
        self.build_tree_contents([
123
 
            ('a/hello2',   b'foo'),
 
123
            ('a/hello2', b'foo'),
124
124
            ('a/goodbye2', b'baz')])
125
125
        a_tree.add('hello2')
126
126
        a_tree.commit(message="setup")
128
128
        a_tree.commit(message="setup")
129
129
 
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')
145
145
        """
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
            builder)
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'])
250
251
        tree_b.add('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())
274
275
 
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')
299
300
 
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')
 
352
 
351
353
        class FooService(object):
352
354
            """A directory service that always returns source"""
353
355
 
354
 
            def look_up(self, name, url):
 
356
            def look_up(self, name, url, purpose=None):
355
357
                return 'source'
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')],
408
 
            working_dir='empty')
 
410
                     working_dir='empty')
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")
429
431
 
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")
445
447
 
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")
456
458
 
457
459
    def test_pull_to_experimental_format_warning(self):
458
460
        """You get a warning for pulling into experimental formats.
459
461
        """
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")
466
469
 
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")
476
479
 
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:
491
494
            f.write('fie')
492
495
 
493
 
        out, err=self.run_bzr(['pull', '-d', 'b', 'a', '--show-base'])
 
496
        out, err = self.run_bzr(['pull', '-d', 'b', 'a', '--show-base'])
494
497
 
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', ''))
526
529
 
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', ''))
536
539
 
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', ''))
549
552
 
550
553
        self.assertEqual(to_tree.branch.tags.lookup_tag('mytag'),
551
 
                          b'somerevid')
 
554
                         b'somerevid')
552
555
        self.assertEqual(to_tree.branch.last_revision(), revid1)
553
556
 
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', ''))
564
567
 
565
568
 
566
569
class TestPullOutput(script.TestCaseWithTransportAndScript):