~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2012-03-13 17:25:29 UTC
  • mfrom: (6499 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6501.
  • Revision ID: v.ladeuil+lp@free.fr-20120313172529-i0suyjnepsor25i7
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for branch.push behaviour."""
18
18
 
19
19
from cStringIO import StringIO
20
 
import os
21
20
 
22
21
from testtools.matchers import (
23
22
    Equals,
26
25
 
27
26
from bzrlib import (
28
27
    branch,
29
 
    bzrdir,
30
28
    check,
 
29
    controldir,
31
30
    errors,
32
31
    push,
33
32
    symbol_versioning,
35
34
    vf_repository,
36
35
    )
37
36
from bzrlib.branch import Branch
38
 
from bzrlib.bzrdir import BzrDir
 
37
from bzrlib.controldir import ControlDir
39
38
from bzrlib.memorytree import MemoryTree
40
39
from bzrlib.revision import NULL_REVISION
41
40
from bzrlib.smart.repository import SmartServerRepositoryGetParentMap
61
60
        mine.merge_from_branch(other.branch)
62
61
        mine.commit('merge my change', rev_id='P2')
63
62
        result = mine.branch.push(other.branch)
64
 
        self.assertEqual(['P1', 'P2'], other.branch.revision_history())
 
63
        self.assertEqual('P2', other.branch.last_revision())
65
64
        # result object contains some structured data
66
65
        self.assertEqual(result.old_revid, 'M1')
67
66
        self.assertEqual(result.new_revid, 'P2')
86
85
        mine.merge_from_branch(other.branch)
87
86
        mine.commit('merge other', rev_id='P2')
88
87
        mine.branch.push(target.branch)
89
 
        self.assertEqual(['P1', 'P2'], target.branch.revision_history())
 
88
        self.assertEqual('P2', target.branch.last_revision())
90
89
 
91
90
    def test_push_to_checkout_updates_master(self):
92
91
        """Pushing into a checkout updates the checkout and the master branch"""
104
103
        rev2 = other.commit('other commit')
105
104
        # now push, which should update both checkout and master.
106
105
        other.branch.push(checkout.branch)
107
 
        self.assertEqual([rev1, rev2], checkout.branch.revision_history())
108
 
        self.assertEqual([rev1, rev2], master_tree.branch.revision_history())
 
106
        self.assertEqual(rev2, checkout.branch.last_revision())
 
107
        self.assertEqual(rev2, master_tree.branch.last_revision())
109
108
 
110
109
    def test_push_raises_specific_error_on_master_connection_error(self):
111
110
        master_tree = self.make_to_branch_and_tree('master')
119
118
        other = other_bzrdir.open_workingtree()
120
119
        # move the branch out of the way on disk to cause a connection
121
120
        # error.
122
 
        os.rename('master', 'master_gone')
 
121
        master_tree.bzrdir.destroy_branch()
123
122
        # try to push, which should raise a BoundBranchConnectionFailure.
124
123
        self.assertRaises(errors.BoundBranchConnectionFailure,
125
124
                other.branch.push, checkout.branch)
159
158
            return
160
159
        try:
161
160
            tree = a_branch.bzrdir.create_workingtree()
 
161
        except errors.UnsupportedOperation:
 
162
            self.assertFalse(a_branch.bzrdir._format.supports_workingtrees)
 
163
            tree = a_branch.create_checkout('repo/tree', lightweight=True)
162
164
        except errors.NotLocalUrl:
163
165
            if self.vfs_transport_factory is test_server.LocalURLServer:
164
166
                # the branch is colocated on disk, we cannot create a checkout.
165
167
                # hopefully callers will expect this.
166
 
                local_controldir = bzrdir.BzrDir.open(self.get_vfs_only_url('repo/tree'))
 
168
                local_controldir = controldir.ControlDir.open(self.get_vfs_only_url('repo/tree'))
167
169
                tree = local_controldir.create_workingtree()
168
170
            else:
169
171
                tree = a_branch.create_checkout('repo/tree', lightweight=True)
277
279
        # remote graph any further.
278
280
        bzr_core_trace = Equals(
279
281
            ['Repository.insert_stream_1.19', 'Repository.insert_stream_1.19',
280
 
             'get', 'Branch.set_last_revision_info', 'Branch.unlock'])
 
282
             'Branch.set_last_revision_info', 'Branch.unlock'])
281
283
        bzr_loom_trace = Equals(
282
284
            ['Repository.insert_stream_1.19', 'Repository.insert_stream_1.19',
283
 
             'get', 'Branch.set_last_revision_info', 'get', 'Branch.unlock'])
 
285
             'Branch.set_last_revision_info', 'get', 'Branch.unlock'])
284
286
        self.assertThat(calls_after_insert_stream,
285
287
            MatchesAny(bzr_core_trace, bzr_loom_trace))
286
288
 
347
349
            # remotebranches can't be bound.  Let's instead make a new local
348
350
            # branch of the default type, which does allow binding.
349
351
            # See https://bugs.launchpad.net/bzr/+bug/112020
350
 
            local = BzrDir.create_branch_convenience('local2')
 
352
            local = ControlDir.create_branch_convenience('local2')
351
353
            local.bind(target)
352
354
        source = self.make_from_branch('source')
353
355
        Branch.hooks.install_named_hook('post_push',
367
369
        target.add('')
368
370
        rev1 = target.commit('rev 1')
369
371
        target.unlock()
370
 
        sourcedir = target.bzrdir.clone(self.get_url('source'))
 
372
        sourcedir = target.branch.bzrdir.clone(self.get_url('source'))
371
373
        source = MemoryTree.create_on_branch(sourcedir.open_branch())
372
374
        rev2 = source.commit('rev 2')
373
375
        Branch.hooks.install_named_hook('post_push',