/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

Merge bzr.dev, update to use new hooks.

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
 
    builtins,
30
28
    bzrdir,
31
29
    check,
32
 
    debug,
33
30
    errors,
34
31
    push,
35
 
    repository,
36
32
    symbol_versioning,
37
33
    tests,
 
34
    vf_repository,
38
35
    )
39
36
from bzrlib.branch import Branch
40
37
from bzrlib.bzrdir import BzrDir
41
38
from bzrlib.memorytree import MemoryTree
42
39
from bzrlib.revision import NULL_REVISION
43
 
from bzrlib.smart import client, server
44
40
from bzrlib.smart.repository import SmartServerRepositoryGetParentMap
45
41
from bzrlib.tests.per_interbranch import (
46
42
    TestCaseWithInterBranch,
64
60
        mine.merge_from_branch(other.branch)
65
61
        mine.commit('merge my change', rev_id='P2')
66
62
        result = mine.branch.push(other.branch)
67
 
        self.assertEqual(['P1', 'P2'], other.branch.revision_history())
 
63
        self.assertEqual('P2', other.branch.last_revision())
68
64
        # result object contains some structured data
69
65
        self.assertEqual(result.old_revid, 'M1')
70
66
        self.assertEqual(result.new_revid, 'P2')
89
85
        mine.merge_from_branch(other.branch)
90
86
        mine.commit('merge other', rev_id='P2')
91
87
        mine.branch.push(target.branch)
92
 
        self.assertEqual(['P1', 'P2'], target.branch.revision_history())
 
88
        self.assertEqual('P2', target.branch.last_revision())
93
89
 
94
90
    def test_push_to_checkout_updates_master(self):
95
91
        """Pushing into a checkout updates the checkout and the master branch"""
107
103
        rev2 = other.commit('other commit')
108
104
        # now push, which should update both checkout and master.
109
105
        other.branch.push(checkout.branch)
110
 
        self.assertEqual([rev1, rev2], checkout.branch.revision_history())
111
 
        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())
112
108
 
113
109
    def test_push_raises_specific_error_on_master_connection_error(self):
114
110
        master_tree = self.make_to_branch_and_tree('master')
122
118
        other = other_bzrdir.open_workingtree()
123
119
        # move the branch out of the way on disk to cause a connection
124
120
        # error.
125
 
        os.rename('master', 'master_gone')
 
121
        master_tree.bzrdir.destroy_branch()
126
122
        # try to push, which should raise a BoundBranchConnectionFailure.
127
123
        self.assertRaises(errors.BoundBranchConnectionFailure,
128
124
                other.branch.push, checkout.branch)
162
158
            return
163
159
        try:
164
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)
165
164
        except errors.NotLocalUrl:
166
165
            if self.vfs_transport_factory is test_server.LocalURLServer:
167
166
                # the branch is colocated on disk, we cannot create a checkout.
204
203
        default for the branch), and will be stacked when the repo format
205
204
        allows (which means that the branch format isn't necessarly preserved).
206
205
        """
207
 
        if isinstance(self.branch_format_from, branch.BzrBranchFormat4):
208
 
            raise tests.TestNotApplicable('Not a metadir format.')
209
206
        if isinstance(self.branch_format_from, branch.BranchReferenceFormat):
210
207
            # This test could in principle apply to BranchReferenceFormat, but
211
208
            # make_branch_builder doesn't support it.
292
289
    def disableOptimisticGetParentMap(self):
293
290
        # Tweak some class variables to stop remote get_parent_map calls asking
294
291
        # for or receiving more data than the caller asked for.
295
 
        self.overrideAttr(repository.InterRepository,
 
292
        self.overrideAttr(vf_repository.InterVersionedFileRepository,
296
293
                          '_walk_to_common_revisions_batch_size', 1)
297
294
        self.overrideAttr(SmartServerRepositoryGetParentMap,
298
295
                            'no_extra_results', True)
372
369
        target.add('')
373
370
        rev1 = target.commit('rev 1')
374
371
        target.unlock()
375
 
        sourcedir = target.bzrdir.clone(self.get_url('source'))
 
372
        sourcedir = target.branch.bzrdir.clone(self.get_url('source'))
376
373
        source = MemoryTree.create_on_branch(sourcedir.open_branch())
377
374
        rev2 = source.commit('rev 2')
378
375
        Branch.hooks.install_named_hook('post_push',