187
187
self.assertEqual(tree.branch.last_revision(),
188
188
to_branch.last_revision())
190
def test_push_overwrite_with_older_mainline_rev(self):
191
"""Pushing an older mainline revision with overwrite.
193
This was <https://bugs.launchpad.net/bzr/+bug/386576>.
195
source = self.make_branch_and_tree('source')
196
target = self.make_branch('target')
198
source.commit('1st commit')
199
source.commit('2nd commit', rev_id='rev-2')
200
source.commit('3rd commit')
201
source.branch.push(target)
202
source.branch.push(target, stop_revision='rev-2', overwrite=True)
203
self.assertEqual('rev-2', target.last_revision())
205
def test_push_overwrite_of_non_tip_with_stop_revision(self):
206
"""Combining the stop_revision and overwrite options works.
208
This was <https://bugs.launchpad.net/bzr/+bug/234229>.
210
source = self.make_branch_and_tree('source')
211
target = self.make_branch('target')
213
source.commit('1st commit')
214
source.branch.push(target)
215
source.commit('2nd commit', rev_id='rev-2')
216
source.commit('3rd commit')
218
source.branch.push(target, stop_revision='rev-2', overwrite=True)
219
self.assertEqual('rev-2', target.last_revision())
190
221
def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
191
222
# See https://bugs.launchpad.net/bzr/+bug/465517
192
223
t = self.get_transport('target')
223
254
self.assertEqual([('A',), ('C',)], sorted(repo.revisions.keys()))
225
def test_push_overwrite_of_non_tip_with_stop_revision(self):
226
"""Combining the stop_revision and overwrite options works.
228
This was <https://bugs.launchpad.net/bzr/+bug/234229>.
230
source = self.make_branch_and_tree('source')
231
target = self.make_branch('target')
233
source.commit('1st commit')
234
source.branch.push(target)
235
source.commit('2nd commit', rev_id='rev-2')
236
source.commit('3rd commit')
238
source.branch.push(target, stop_revision='rev-2', overwrite=True)
239
self.assertEqual('rev-2', target.last_revision())
241
256
def test_push_with_default_stacking_does_not_create_broken_branch(self):
242
257
"""Pushing a new standalone branch works even when there's a default
243
258
stacking policy at the destination.
246
261
default for the branch), and will be stacked when the repo format
247
262
allows (which means that the branch format isn't necessarly preserved).
249
if isinstance(self.branch_format, branch.BzrBranchFormat4):
264
if self.bzrdir_format.fixed_components:
250
265
raise tests.TestNotApplicable('Not a metadir format.')
251
266
if isinstance(self.branch_format, branch.BranchReferenceFormat):
252
267
# This test could in principle apply to BranchReferenceFormat, but
387
402
raise tests.TestNotApplicable(
388
403
'Does not apply when remote backing branch is also '
389
404
'a smart branch')
390
if isinstance(self.branch_format, branch.BzrBranchFormat4):
405
if not self.branch_format.supports_leaving_lock():
391
406
raise tests.TestNotApplicable(
392
'Branch format 4 is not usable via HPSS.')
407
'Branch format is not usable via HPSS.')
393
408
super(EmptyPushSmartEffortTests, self).setUp()
394
409
# Create a smart server that publishes whatever the backing VFS server
446
461
def test_lossy_push_raises_same_vcs(self):
447
462
target = self.make_branch('target')
448
463
source = self.make_branch('source')
449
self.assertRaises(errors.LossyPushToSameVCS, source.lossy_push, target)
464
self.assertRaises(errors.LossyPushToSameVCS, source.push, target, lossy=True)