/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 breezy/tests/per_interbranch/test_push.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
from .. import test_server
48
48
 
49
49
 
50
 
# These tests are based on similar tests in 
 
50
# These tests are based on similar tests in
51
51
# breezy.tests.per_branch.test_push.
52
52
 
53
53
 
86
86
        mine = self.make_from_branch_and_tree('mine')
87
87
        p1 = mine.commit('1st post', allow_pointless=True)
88
88
        try:
89
 
            target = self.sprout_to(mine.controldir, 'target').open_workingtree()
 
89
            target = self.sprout_to(
 
90
                mine.controldir, 'target').open_workingtree()
90
91
        except errors.NoRoundtrippingSupport:
91
92
            raise tests.TestNotApplicable(
92
93
                'lossless push between %r and %r not supported' %
117
118
        rev1 = checkout.commit('master')
118
119
 
119
120
        try:
120
 
            other_bzrdir = self.sprout_from(master_tree.branch.controldir, 'other')
 
121
            other_bzrdir = self.sprout_from(
 
122
                master_tree.branch.controldir, 'other')
121
123
        except errors.NoRoundtrippingSupport:
122
124
            raise tests.TestNotApplicable(
123
125
                'lossless push between %r and %r not supported' %
144
146
        master_tree.controldir.destroy_branch()
145
147
        # try to push, which should raise a BoundBranchConnectionFailure.
146
148
        self.assertRaises(errors.BoundBranchConnectionFailure,
147
 
                other.branch.push, checkout.branch)
 
149
                          other.branch.push, checkout.branch)
148
150
 
149
151
    def test_push_uses_read_lock(self):
150
152
        """Push should only need a read lock on the source side."""
157
159
 
158
160
        try:
159
161
            with source.branch.lock_read(), target.lock_write():
160
 
                source.branch.push(target, stop_revision=source.last_revision())
 
162
                source.branch.push(
 
163
                    target, stop_revision=source.last_revision())
161
164
        except errors.NoRoundtrippingSupport:
162
165
            raise tests.TestNotApplicable(
163
166
                'lossless push between %r and %r not supported' %
174
177
 
175
178
        try:
176
179
            with source.branch.lock_read(), target.lock_write():
177
 
                source.branch.push(target, stop_revision=source.last_revision(), lossy=True)
 
180
                source.branch.push(
 
181
                    target, stop_revision=source.last_revision(), lossy=True)
178
182
        except errors.LossyPushToSameVCS:
179
183
            raise tests.TestNotApplicable(
180
184
                'push between branches of same format')
226
230
            if self.vfs_transport_factory is test_server.LocalURLServer:
227
231
                # the branch is colocated on disk, we cannot create a checkout.
228
232
                # hopefully callers will expect this.
229
 
                local_controldir = controldir.ControlDir.open(self.get_vfs_only_url('repo/tree'))
 
233
                local_controldir = controldir.ControlDir.open(
 
234
                    self.get_vfs_only_url('repo/tree'))
230
235
                tree = local_controldir.create_workingtree()
231
236
            else:
232
237
                tree = a_branch.create_checkout('repo/tree', lightweight=True)
294
299
            ('add', ('filename', None, 'file', b'content\n'))])
295
300
        revid2 = builder.build_snapshot([revid1], [])
296
301
        revid3 = builder.build_snapshot([revid2],
297
 
            [('modify', ('filename', b'new-content\n'))])
 
302
                                        [('modify', ('filename', b'new-content\n'))])
298
303
        builder.finish_series()
299
304
        trunk = builder.get_branch()
300
305
        # Sprout rev-1 to "trunk", so that we can stack on it.
360
365
            [b'Repository.insert_stream_1.19', b'Repository.insert_stream_1.19',
361
366
             b'Branch.set_last_revision_info', b'get', b'Branch.unlock'])
362
367
        self.assertThat(calls_after_insert_stream,
363
 
            MatchesAny(bzr_core_trace, bzr_loom_trace))
 
368
                        MatchesAny(bzr_core_trace, bzr_loom_trace))
364
369
 
365
370
    def disableOptimisticGetParentMap(self):
366
371
        # Tweak some class variables to stop remote get_parent_map calls asking
368
373
        self.overrideAttr(vf_repository.InterVersionedFileRepository,
369
374
                          '_walk_to_common_revisions_batch_size', 1)
370
375
        self.overrideAttr(SmartServerRepositoryGetParentMap,
371
 
                            'no_extra_results', True)
 
376
                          'no_extra_results', True)
372
377
 
373
378
 
374
379
class TestPushHook(TestCaseWithInterBranch):