~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_push.py

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib import (
23
23
    branch,
24
24
    builtins,
25
 
    bzrdir,
 
25
    controldir,
26
26
    check,
27
27
    errors,
28
28
    memorytree,
53
53
        mine.merge_from_branch(other.branch)
54
54
        mine.commit('merge my change', rev_id='P2')
55
55
        result = mine.branch.push(other.branch)
56
 
        self.assertEqual(['P1', 'P2'], other.branch.revision_history())
 
56
        self.assertEqual('P2', other.branch.last_revision())
57
57
        # result object contains some structured data
58
58
        self.assertEqual(result.old_revid, 'M1')
59
59
        self.assertEqual(result.new_revid, 'P2')
60
 
        # and it can be treated as an integer for compatibility
61
 
        self.assertEqual(self.applyDeprecated(
62
 
            symbol_versioning.deprecated_in((2, 3, 0)),
63
 
            result.__int__),
64
 
            0)
65
60
 
66
61
    def test_push_merged_indirect(self):
67
62
        # it should be possible to do a push from one branch into another
78
73
        mine.merge_from_branch(other.branch)
79
74
        mine.commit('merge other', rev_id='P2')
80
75
        mine.branch.push(target.branch)
81
 
        self.assertEqual(['P1', 'P2'], target.branch.revision_history())
 
76
        self.assertEqual('P2', target.branch.last_revision())
82
77
 
83
78
    def test_push_to_checkout_updates_master(self):
84
79
        """Pushing into a checkout updates the checkout and the master branch"""
95
90
        rev2 = other.commit('other commit')
96
91
        # now push, which should update both checkout and master.
97
92
        other.branch.push(checkout.branch)
98
 
        self.assertEqual([rev1, rev2], checkout.branch.revision_history())
99
 
        self.assertEqual([rev1, rev2], master_tree.branch.revision_history())
 
93
        self.assertEqual(rev2, checkout.branch.last_revision())
 
94
        self.assertEqual(rev2, master_tree.branch.last_revision())
100
95
 
101
96
    def test_push_raises_specific_error_on_master_connection_error(self):
102
97
        master_tree = self.make_branch_and_tree('master')
157
152
        except (errors.IncompatibleFormat, errors.UninitializableFormat):
158
153
            # This Branch format cannot create shared repositories
159
154
            return
 
155
        if not repo._format.supports_nesting_repositories:
 
156
            return
160
157
        # This is a little bit trickier because make_branch_and_tree will not
161
158
        # re-use a shared repository.
162
159
        a_bzrdir = self.make_bzrdir('repo/tree')
171
168
            if self.vfs_transport_factory is test_server.LocalURLServer:
172
169
                # the branch is colocated on disk, we cannot create a checkout.
173
170
                # hopefully callers will expect this.
174
 
                local_controldir= bzrdir.BzrDir.open(
 
171
                local_controldir = controldir.ControlDir.open(
175
172
                    self.get_vfs_only_url('repo/tree'))
176
173
                tree = local_controldir.create_workingtree()
177
174
            else:
251
248
        self.addCleanup(repo.lock_read().unlock)
252
249
        # We should have pushed 'C', but not 'B', since it isn't in the
253
250
        # ancestry
254
 
        self.assertEqual([('A',), ('C',)], sorted(repo.revisions.keys()))
 
251
        self.assertEqual(['A', 'C'], sorted(repo.all_revision_ids()))
255
252
 
256
253
    def test_push_with_default_stacking_does_not_create_broken_branch(self):
257
254
        """Pushing a new standalone branch works even when there's a default
353
350
            # remotebranches can't be bound.  Let's instead make a new local
354
351
            # branch of the default type, which does allow binding.
355
352
            # See https://bugs.launchpad.net/bzr/+bug/112020
356
 
            local = bzrdir.BzrDir.create_branch_convenience('local2')
 
353
            local = controldir.ControlDir.create_branch_convenience('local2')
357
354
            local.bind(target)
358
355
        source = self.make_branch('source')
359
356
        branch.Branch.hooks.install_named_hook(
424
421
    def test_empty_branch_api(self):
425
422
        """The branch_obj.push API should make a limited number of HPSS calls.
426
423
        """
427
 
        t = transport.get_transport(self.smart_server.get_url()).clone('target')
 
424
        t = transport.get_transport_from_url(self.smart_server.get_url()).clone('target')
428
425
        target = branch.Branch.open_from_transport(t)
429
426
        self.empty_branch.push(target)
430
427
        self.assertEqual(