/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: Jelmer Vernooij
  • Date: 2011-02-08 15:41:44 UTC
  • mfrom: (5651.4.1 repo-format-registry)
  • mto: This revision was merged to the branch mainline in revision 5658.
  • Revision ID: jelmer@samba.org-20110208154144-h8mm2hrk87de4w2s
Merge repo format registry branch.

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 TestCaseWithTransport
33
33
from bzrlib.uncommit import uncommit
34
34
from bzrlib.workingtree import WorkingTree
35
35
 
36
36
 
37
 
class TestPull(ExternalBase):
 
37
class TestPull(TestCaseWithTransport):
38
38
 
39
39
    def example_branch(self, path='.'):
40
40
        tree = self.make_branch_and_tree(path)
142
142
        self.run_bzr('pull -r 4')
143
143
        self.assertEqual(a.revision_history(), b.revision_history())
144
144
 
 
145
    def test_pull_tags(self):
 
146
        """Tags are updated by pull, and revisions named in those tags are
 
147
        fetched.
 
148
        """
 
149
        # Make a source, sprout a target off it
 
150
        builder = self.make_branch_builder('source')
 
151
        builder.build_commit(message="Rev 1", rev_id='rev-1')
 
152
        source = builder.get_branch()
 
153
        target_bzrdir = source.bzrdir.sprout('target')
 
154
        # Add a non-ancestry tag to source
 
155
        builder.build_commit(message="Rev 2", rev_id='rev-2')
 
156
        source.tags.set_tag('tag-a', 'rev-2')
 
157
        source.set_last_revision_info(1, 'rev-1')
 
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
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', ''))