~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Packman
  • Date: 2012-01-05 09:50:04 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6426.
  • Revision ID: martin.packman@canonical.com-20120105095004-mia9xb7y0efmto0v
Merge bzr.dev to resolve conflicts in bzrlib.builtins

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for InterBranch.pull behaviour."""
18
18
 
19
 
import os
20
 
 
21
19
from bzrlib.branch import Branch
22
20
from bzrlib.bzrdir import BzrDir
23
21
from bzrlib import errors
42
40
        parent.merge_from_branch(mine.branch)
43
41
        parent.commit('merge my change', rev_id='P2')
44
42
        mine.pull(parent.branch)
45
 
        self.assertEqual(['P1', 'P2'], mine.branch.revision_history())
 
43
        self.assertEqual('P2', mine.branch.last_revision())
46
44
 
47
45
    def test_pull_merged_indirect(self):
48
46
        # it should be possible to do a pull from one branch into another
59
57
        parent.merge_from_branch(other.branch)
60
58
        parent.commit('merge other', rev_id='P2')
61
59
        mine.pull(parent.branch)
62
 
        self.assertEqual(['P1', 'P2'], mine.branch.revision_history())
 
60
        self.assertEqual('P2', mine.branch.last_revision())
63
61
 
64
62
    def test_pull_updates_checkout_and_master(self):
65
63
        """Pulling into a checkout updates the checkout and the master branch"""
70
68
        rev2 = other.commit('other commit')
71
69
        # now pull, which should update both checkout and master.
72
70
        checkout.branch.pull(other.branch)
73
 
        self.assertEqual([rev1, rev2], checkout.branch.revision_history())
74
 
        self.assertEqual([rev1, rev2], master_tree.branch.revision_history())
 
71
        self.assertEqual(rev2, checkout.branch.last_revision())
 
72
        self.assertEqual(rev2, master_tree.branch.last_revision())
75
73
 
76
74
    def test_pull_raises_specific_error_on_master_connection_error(self):
77
75
        master_tree = self.make_from_branch_and_tree('master')
79
77
        other = self.sprout_to(master_tree.branch.bzrdir, 'other').open_branch()
80
78
        # move the branch out of the way on disk to cause a connection
81
79
        # error.
82
 
        os.rename('master', 'master_gone')
 
80
        master_tree.branch.bzrdir.destroy_branch()
83
81
        # try to pull, which should raise a BoundBranchConnectionFailure.
84
82
        self.assertRaises(errors.BoundBranchConnectionFailure,
85
83
                checkout.branch.pull, other)
99
97
        self.assertEqual('P1', result.old_revid)
100
98
        self.assertEqual(2, result.new_revno)
101
99
        self.assertEqual('M1', result.new_revid)
102
 
        self.assertEqual(None, result.tag_conflicts)
 
100
        self.assertEqual([], result.tag_conflicts)
103
101
 
104
102
    def test_pull_overwrite(self):
105
103
        tree_a = self.make_from_branch_and_tree('tree_a')
112
110
                          tree_a.branch.pull, tree_b.branch,
113
111
                          overwrite=False, stop_revision='rev2b')
114
112
        # It should not have updated the branch tip, but it should have fetched
115
 
        # the revision
 
113
        # the revision if the repository supports "invisible" revisions.
116
114
        self.assertEqual('rev2a', tree_a.branch.last_revision())
117
 
        self.assertTrue(tree_a.branch.repository.has_revision('rev2b'))
 
115
        if tree_a.branch.repository._format.supports_unreferenced_revisions:
 
116
            self.assertTrue(tree_a.branch.repository.has_revision('rev2b'))
118
117
        tree_a.branch.pull(tree_b.branch, overwrite=True,
119
118
                           stop_revision='rev2b')
120
119
        self.assertEqual('rev2b', tree_a.branch.last_revision())
121
 
        self.assertEqual(tree_b.branch.revision_history(),
122
 
                         tree_a.branch.revision_history())
 
120
        self.assertEqual(tree_b.branch.last_revision(),
 
121
                         tree_a.branch.last_revision())
123
122
 
124
123
 
125
124
class TestPullHook(TestCaseWithInterBranch):