/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 bzrlib/tests/blackbox/test_pull.py

  • Committer: Gordon Tyler
  • Date: 2011-09-09 12:42:32 UTC
  • mto: (6015.33.4 2.4)
  • mto: This revision was merged to the branch mainline in revision 6134.
  • Revision ID: gordon@doxxx.net-20110909124232-ip0bgx4tx6y5fya6
Use get_user_option in get_merge_tools so that quoted values are correctly unquoted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from bzrlib.branch import Branch
30
30
from bzrlib.directory_service import directories
31
31
from bzrlib.osutils import pathjoin
32
 
from bzrlib.tests.blackbox import ExternalBase
 
32
from bzrlib.tests import (
 
33
    fixtures,
 
34
    TestCaseWithTransport,
 
35
    )
33
36
from bzrlib.uncommit import uncommit
34
37
from bzrlib.workingtree import WorkingTree
35
38
 
36
39
 
37
 
class TestPull(ExternalBase):
 
40
class TestPull(TestCaseWithTransport):
38
41
 
39
42
    def example_branch(self, path='.'):
40
43
        tree = self.make_branch_and_tree(path)
142
145
        self.run_bzr('pull -r 4')
143
146
        self.assertEqual(a.revision_history(), b.revision_history())
144
147
 
 
148
    def test_pull_tags(self):
 
149
        """Tags are updated by pull, and revisions named in those tags are
 
150
        fetched.
 
151
        """
 
152
        # Make a source, sprout a target off it
 
153
        builder = self.make_branch_builder('source')
 
154
        source = fixtures.build_branch_with_non_ancestral_rev(builder)
 
155
        source.get_config().set_user_option('branch.fetch_tags', 'True')
 
156
        target_bzrdir = source.bzrdir.sprout('target')
 
157
        source.tags.set_tag('tag-a', 'rev-2')
 
158
        # Pull from source
 
159
        self.run_bzr('pull -d target source')
 
160
        target = target_bzrdir.open_branch()
 
161
        # The tag is present, and so is its revision.
 
162
        self.assertEqual('rev-2', target.tags.lookup_tag('tag-a'))
 
163
        target.repository.get_revision('rev-2')
145
164
 
146
165
    def test_overwrite_uptodate(self):
147
166
        # Make sure pull --overwrite overwrites
392
411
        # being too low. If rpc_count increases, more network roundtrips have
393
412
        # become necessary for this use case. Please do not adjust this number
394
413
        # upwards without agreement from bzr's network support maintainers.
395
 
        self.assertLength(18, self.hpss_calls)
 
414
        self.assertLength(19, self.hpss_calls)
396
415
        remote = Branch.open('stacked')
397
416
        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
398
417
    
453
472
        out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
454
473
        self.assertContainsRe(err,
455
474
            "(?m)Fetching into experimental format")
 
475
 
 
476
    def test_pull_show_base(self):
 
477
        """bzr pull supports --show-base
 
478
 
 
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()
 
484
 
 
485
        f = open(pathjoin('a', 'hello'),'wt')
 
486
        f.write('fee')
 
487
        f.close()
 
488
        a_tree.commit('fee')
 
489
 
 
490
        f = open(pathjoin('b', 'hello'),'wt')
 
491
        f.write('fie')
 
492
        f.close()
 
493
 
 
494
        out,err=self.run_bzr(['pull','-d','b','a','--show-base'])
 
495
 
 
496
        # check for message here
 
497
        self.assertEqual(err,
 
498
                         ' M  hello\nText conflict in hello\n1 conflicts encountered.\n')
 
499
 
 
500
        self.assertEqualDiff('<<<<<<< TREE\n'
 
501
                             'fie||||||| BASE-REVISION\n'
 
502
                             'foo=======\n'
 
503
                             'fee>>>>>>> MERGE-SOURCE\n',
 
504
                             open(pathjoin('b', 'hello')).read())
 
505
 
 
506
    def test_pull_show_base_working_tree_only(self):
 
507
        """--show-base only allowed if there's a working tree
 
508
 
 
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'))
 
516
 
 
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', ''))