~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

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 import TestCaseWithTransport
 
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
 
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
        target_bzrdir = source.bzrdir.sprout('target')
 
156
        source.tags.set_tag('tag-a', 'rev-2')
 
157
        # Pull from source
 
158
        self.run_bzr('pull -d target source')
 
159
        target = target_bzrdir.open_branch()
 
160
        # The tag is present, and so is its revision.
 
161
        self.assertEqual('rev-2', target.tags.lookup_tag('tag-a'))
 
162
        target.repository.get_revision('rev-2')
145
163
 
146
164
    def test_overwrite_uptodate(self):
147
165
        # Make sure pull --overwrite overwrites
453
471
        out, err = self.run_bzr(['pull', '-d', 'to', 'from'])
454
472
        self.assertContainsRe(err,
455
473
            "(?m)Fetching into experimental format")
 
474
 
 
475
    def test_pull_show_base(self):
 
476
        """bzr pull supports --show-base
 
477
 
 
478
        see https://bugs.launchpad.net/bzr/+bug/202374"""
 
479
        # create two trees with conflicts, setup conflict, check that
 
480
        # conflicted file looks correct
 
481
        a_tree = self.example_branch('a')
 
482
        b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
 
483
 
 
484
        f = open(pathjoin('a', 'hello'),'wt')
 
485
        f.write('fee')
 
486
        f.close()
 
487
        a_tree.commit('fee')
 
488
 
 
489
        f = open(pathjoin('b', 'hello'),'wt')
 
490
        f.write('fie')
 
491
        f.close()
 
492
 
 
493
        out,err=self.run_bzr(['pull','-d','b','a','--show-base'])
 
494
 
 
495
        # check for message here
 
496
        self.assertEqual(err,
 
497
                         ' M  hello\nText conflict in hello\n1 conflicts encountered.\n')
 
498
 
 
499
        self.assertEqualDiff('<<<<<<< TREE\n'
 
500
                             'fie||||||| BASE-REVISION\n'
 
501
                             'foo=======\n'
 
502
                             'fee>>>>>>> MERGE-SOURCE\n',
 
503
                             open(pathjoin('b', 'hello')).read())
 
504
 
 
505
    def test_pull_show_base_working_tree_only(self):
 
506
        """--show-base only allowed if there's a working tree
 
507
 
 
508
        see https://bugs.launchpad.net/bzr/+bug/202374"""
 
509
        # create a branch, see that --show-base fails
 
510
        self.make_branch('from')
 
511
        self.make_branch('to')
 
512
        out=self.run_bzr(['pull','-d','to','from','--show-base'],retcode=3)
 
513
        self.assertEqual(out,
 
514
                         ('','bzr: ERROR: Need working tree for --show-base.\n'))
 
515
 
 
516
    def test_pull_tag_conflicts(self):
 
517
        """pulling tags with conflicts will change the exit code"""
 
518
        # create a branch, see that --show-base fails
 
519
        from_tree = self.make_branch_and_tree('from')
 
520
        from_tree.branch.tags.set_tag("mytag", "somerevid")
 
521
        to_tree = self.make_branch_and_tree('to')
 
522
        to_tree.branch.tags.set_tag("mytag", "anotherrevid")
 
523
        out = self.run_bzr(['pull','-d','to','from'],retcode=1)
 
524
        self.assertEqual(out,
 
525
            ('No revisions to pull.\nConflicting tags:\n    mytag\n', ''))