/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_branch/test_push.py

  • Committer: Martin Pool
  • Date: 2011-04-01 03:07:34 UTC
  • mfrom: (5609.29.3 2.3)
  • mto: (5609.29.4 2.3)
  • mto: This revision was merged to the branch mainline in revision 5755.
  • Revision ID: mbp@canonical.com-20110401030734-wip8a66uf8aphgud
merge up to bzr 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
24
24
    builtins,
25
25
    bzrdir,
26
26
    check,
27
 
    debug,
28
27
    errors,
29
28
    memorytree,
30
29
    push,
31
 
    repository,
32
30
    revision,
 
31
    symbol_versioning,
33
32
    tests,
34
33
    transport,
35
34
    )
36
35
from bzrlib.smart import (
37
36
    client,
38
 
    server,
39
 
    repository as _mod_smart_repo,
40
37
    )
41
38
from bzrlib.tests import (
42
39
    per_branch,
61
58
        self.assertEqual(result.old_revid, 'M1')
62
59
        self.assertEqual(result.new_revid, 'P2')
63
60
        # and it can be treated as an integer for compatibility
64
 
        self.assertEqual(int(result), 0)
 
61
        self.assertEqual(self.applyDeprecated(
 
62
            symbol_versioning.deprecated_in((2, 3, 0)),
 
63
            result.__int__),
 
64
            0)
65
65
 
66
66
    def test_push_merged_indirect(self):
67
67
        # it should be possible to do a push from one branch into another
114
114
        self.assertRaises(errors.BoundBranchConnectionFailure,
115
115
                other.branch.push, checkout.branch)
116
116
 
 
117
    def test_push_new_tag_to_bound_branch(self):
 
118
        master = self.make_branch('master')
 
119
        bound = self.make_branch('bound')
 
120
        try:
 
121
            bound.bind(master)
 
122
        except errors.UpgradeRequired:
 
123
            raise tests.TestNotApplicable(
 
124
                'Format does not support bound branches')
 
125
        other = bound.bzrdir.sprout('other').open_branch()
 
126
        try:
 
127
            other.tags.set_tag('new-tag', 'some-rev')
 
128
        except errors.TagsNotSupported:
 
129
            raise tests.TestNotApplicable('Format does not support tags')
 
130
        other.push(bound)
 
131
        self.assertEqual({'new-tag': 'some-rev'}, bound.tags.get_tag_dict())
 
132
        self.assertEqual({'new-tag': 'some-rev'}, master.tags.get_tag_dict())
 
133
 
117
134
    def test_push_uses_read_lock(self):
118
135
        """Push should only need a read lock on the source side."""
119
136
        source = self.make_branch_and_tree('source')
170
187
        self.assertEqual(tree.branch.last_revision(),
171
188
                         to_branch.last_revision())
172
189
 
 
190
    def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
 
191
        # See https://bugs.launchpad.net/bzr/+bug/465517
 
192
        t = self.get_transport('target')
 
193
        t.ensure_base()
 
194
        bzrdir = self.bzrdir_format.initialize_on_transport(t)
 
195
        try:
 
196
            bzrdir.open_branch()
 
197
        except errors.NotBranchError:
 
198
            pass
 
199
        else:
 
200
            raise tests.TestNotApplicable('older formats can\'t have a repo'
 
201
                                          ' without a branch')
 
202
        try:
 
203
            source = self.make_branch_builder('source',
 
204
                                              format=self.bzrdir_format)
 
205
        except errors.UninitializableFormat:
 
206
            raise tests.TestNotApplicable('cannot initialize this format')
 
207
        source.start_series()
 
208
        source.build_snapshot('A', None, [
 
209
            ('add', ('', 'root-id', 'directory', None))])
 
210
        source.build_snapshot('B', ['A'], [])
 
211
        source.build_snapshot('C', ['A'], [])
 
212
        source.finish_series()
 
213
        b = source.get_branch()
 
214
        # Note: We can't read lock the source branch. Some formats take a write
 
215
        # lock to 'set_push_location', which breaks
 
216
        self.addCleanup(b.lock_write().unlock)
 
217
        repo = bzrdir.create_repository()
 
218
        # This means 'push the source branch into this dir'
 
219
        bzrdir.push_branch(b)
 
220
        self.addCleanup(repo.lock_read().unlock)
 
221
        # We should have pushed 'C', but not 'B', since it isn't in the
 
222
        # ancestry
 
223
        self.assertEqual([('A',), ('C',)], sorted(repo.revisions.keys()))
 
224
 
173
225
    def test_push_overwrite_of_non_tip_with_stop_revision(self):
174
226
        """Combining the stop_revision and overwrite options works.
175
227
 
329
381
 
330
382
    def setUp(self):
331
383
        # Skip some scenarios that don't apply to these tests.
332
 
        if (self.transport_server is not None and
333
 
            issubclass(self.transport_server, server.SmartTCPServer)):
 
384
        if (self.transport_server is not None
 
385
            and issubclass(self.transport_server,
 
386
                           test_server.SmartTCPServer_for_testing)):
334
387
            raise tests.TestNotApplicable(
335
388
                'Does not apply when remote backing branch is also '
336
389
                'a smart branch')