/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

Merge test-run support.

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(
149
 
            builder)
 
148
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(builder)
150
149
        source.get_config_stack().set('branch.fetch_tags', True)
151
150
        target_bzrdir = source.controldir.sprout('target')
152
151
        source.tags.set_tag('tag-a', rev2)
245
244
        # test pull for failure without parent set
246
245
        out = self.run_bzr('pull', retcode=3, working_dir='branch_b')
247
246
        self.assertEqual(out,
248
 
                         ('', 'brz: ERROR: No pull location known or specified.\n'))
 
247
                ('', 'brz: ERROR: No pull location known or specified.\n'))
249
248
        # test implicit --remember when no parent set, this pull conflicts
250
249
        self.build_tree(['branch_b/d'])
251
250
        tree_b.add('d')
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())
274
273
                         branch_b.get_parent())
275
274
 
276
275
    def test_pull_bundle(self):
277
 
        from breezy.bzr.testament import Testament
 
276
        from breezy.testament import Testament
278
277
        # Build up 2 trees and prepare for a pull
279
278
        tree_a = self.make_branch_and_tree('branch_a')
280
279
        with open('branch_a/a', 'wb') as f:
296
295
        self.assertEqual(out,
297
296
                         'Now on revision 2.\n')
298
297
        self.assertEqual(err,
299
 
                         ' M  a\nAll changes applied successfully.\n')
 
298
                ' M  a\nAll changes applied successfully.\n')
300
299
 
301
300
        self.assertEqualDiff(tree_a.branch.last_revision(),
302
301
                             tree_b.branch.last_revision())
349
348
        source.commit('commit 1')
350
349
        target = source.controldir.sprout('target').open_workingtree()
351
350
        source_last = source.commit('commit 2')
352
 
 
353
351
        class FooService(object):
354
352
            """A directory service that always returns source"""
355
353
 
356
 
            def look_up(self, name, url, purpose=None):
 
354
            def look_up(self, name, url):
357
355
                return 'source'
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')],
410
 
                     working_dir='empty')
 
408
            working_dir='empty')
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')
427
425
        from_tree.commit(message='first commit')
428
426
        out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
429
427
        self.assertContainsRe(err,
430
 
                              "(?m)Doing on-the-fly conversion")
 
428
            "(?m)Doing on-the-fly conversion")
431
429
 
432
430
    def test_pull_cross_format_warning_no_IDS(self):
433
431
        """You get a warning for probably slow cross-format pulls.
443
441
        from_tree.commit(message='first commit')
444
442
        out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
445
443
        self.assertContainsRe(err,
446
 
                              "(?m)Doing on-the-fly conversion")
 
444
            "(?m)Doing on-the-fly conversion")
447
445
 
448
446
    def test_pull_cross_format_from_network(self):
449
447
        self.setup_smart_server_with_call_log()
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")
458
456
 
459
457
    def test_pull_to_experimental_format_warning(self):
460
458
        """You get a warning for pulling into experimental formats.
461
459
        """
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")
469
466
 
470
467
    def test_pull_cross_to_experimental_format_warning(self):
471
468
        """You get a warning for pulling into experimental formats.
475
472
        from_tree.commit(message='first commit')
476
473
        out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
477
474
        self.assertContainsRe(err,
478
 
                              "(?m)Fetching into experimental format")
 
475
            "(?m)Fetching into experimental format")
479
476
 
480
477
    def test_pull_show_base(self):
481
478
        """brz pull supports --show-base
493
490
        with open(osutils.pathjoin('b', 'hello'), 'wt') as f:
494
491
            f.write('fie')
495
492
 
496
 
        out, err = self.run_bzr(['pull', '-d', 'b', 'a', '--show-base'])
 
493
        out, err=self.run_bzr(['pull', '-d', 'b', 'a', '--show-base'])
497
494
 
498
495
        # check for message here
499
496
        self.assertEqual(
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', ''))
529
526
 
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', ''))
539
536
 
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', ''))
552
549
 
553
550
        self.assertEqual(to_tree.branch.tags.lookup_tag('mytag'),
554
 
                         b'somerevid')
 
551
                          'somerevid')
555
552
        self.assertEqual(to_tree.branch.last_revision(), revid1)
556
553
 
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', ''))
567
564
 
568
565
 
569
566
class TestPullOutput(script.TestCaseWithTransportAndScript):