/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: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

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')
181
185
 
 
186
    def test_between_colocated(self):
 
187
        """Pushing from one colocated branch to another doesn't change the active branch."""
 
188
        source = self.make_from_branch_and_tree('source')
 
189
        target = self.make_to_branch('target')
 
190
 
 
191
        self.build_tree(['source/a'])
 
192
        source.add(['a'])
 
193
        revid1 = source.commit('a')
 
194
 
 
195
        self.build_tree(['source/b'])
 
196
        source.add(['b'])
 
197
        revid2 = source.commit('b')
 
198
 
 
199
        source_colo = source.controldir.create_branch('colo')
 
200
        source_colo.generate_revision_history(revid1)
 
201
        try:
 
202
            source_colo.push(target)
 
203
        except errors.NoRoundtrippingSupport:
 
204
            raise tests.TestNotApplicable(
 
205
                'push between branches of different format')
 
206
        self.assertEqual(source_colo.last_revision(), revid1)
 
207
        self.assertEqual(source.last_revision(), revid2)
 
208
        self.assertEqual(target.last_revision(), revid1)
 
209
 
182
210
    def test_push_within_repository(self):
183
211
        """Push from one branch to another inside the same repository."""
184
212
        try:
202
230
            if self.vfs_transport_factory is test_server.LocalURLServer:
203
231
                # the branch is colocated on disk, we cannot create a checkout.
204
232
                # hopefully callers will expect this.
205
 
                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'))
206
235
                tree = local_controldir.create_workingtree()
207
236
            else:
208
237
                tree = a_branch.create_checkout('repo/tree', lightweight=True)
270
299
            ('add', ('filename', None, 'file', b'content\n'))])
271
300
        revid2 = builder.build_snapshot([revid1], [])
272
301
        revid3 = builder.build_snapshot([revid2],
273
 
            [('modify', ('filename', b'new-content\n'))])
 
302
                                        [('modify', ('filename', b'new-content\n'))])
274
303
        builder.finish_series()
275
304
        trunk = builder.get_branch()
276
305
        # Sprout rev-1 to "trunk", so that we can stack on it.
336
365
            [b'Repository.insert_stream_1.19', b'Repository.insert_stream_1.19',
337
366
             b'Branch.set_last_revision_info', b'get', b'Branch.unlock'])
338
367
        self.assertThat(calls_after_insert_stream,
339
 
            MatchesAny(bzr_core_trace, bzr_loom_trace))
 
368
                        MatchesAny(bzr_core_trace, bzr_loom_trace))
340
369
 
341
370
    def disableOptimisticGetParentMap(self):
342
371
        # Tweak some class variables to stop remote get_parent_map calls asking
344
373
        self.overrideAttr(vf_repository.InterVersionedFileRepository,
345
374
                          '_walk_to_common_revisions_batch_size', 1)
346
375
        self.overrideAttr(SmartServerRepositoryGetParentMap,
347
 
                            'no_extra_results', True)
 
376
                          'no_extra_results', True)
348
377
 
349
378
 
350
379
class TestPushHook(TestCaseWithInterBranch):