~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: 2011-11-24 15:48:29 UTC
  • mfrom: (6289 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6337.
  • Revision ID: v.ladeuil+lp@free.fr-20111124154829-avowjpsxdl8yp2vz
merge trunk resolving conflicts

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,
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.
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',