41
43
class TestPush(TestCaseWithBranch):
43
45
def test_push_convergence_simple(self):
44
# when revisions are pushed, the left-most accessible parents must
46
# when revisions are pushed, the left-most accessible parents must
45
47
# become the revision-history.
46
48
mine = self.make_branch_and_tree('mine')
47
49
mine.commit('1st post', rev_id='P1', allow_pointless=True)
224
226
trunk.push(remote_branch)
225
227
remote_branch.check()
229
def test_no_get_parent_map_after_insert_stream(self):
230
# Effort test for bug 331823
231
self.setup_smart_server_with_call_log()
232
# Make a local branch with four revisions. Four revisions because:
233
# one to push, one there for _walk_to_common_revisions to find, one we
234
# don't want to access, one for luck :)
235
if isinstance(self.branch_format, branch.BranchReferenceFormat):
236
# This test could in principle apply to BranchReferenceFormat, but
237
# make_branch_builder doesn't support it.
238
raise tests.TestSkipped(
239
"BranchBuilder can't make reference branches.")
241
builder = self.make_branch_builder('local')
242
except (errors.TransportNotPossible, errors.UninitializableFormat):
243
raise tests.TestNotApplicable('format not directly constructable')
244
builder.start_series()
245
builder.build_snapshot('first', None, [
246
('add', ('', 'root-id', 'directory', ''))])
247
builder.build_snapshot('second', ['first'], [])
248
builder.build_snapshot('third', ['second'], [])
249
builder.build_snapshot('fourth', ['third'], [])
250
builder.finish_series()
251
local = builder.get_branch()
252
local = branch.Branch.open(self.get_vfs_only_url('local'))
253
# Initial push of three revisions
254
remote_bzrdir = local.bzrdir.sprout(
255
self.get_url('remote'), revision_id='third')
256
remote = remote_bzrdir.open_branch()
257
# Push fourth revision
258
self.reset_smart_call_log()
259
self.disableOptimisticGetParentMap()
260
self.assertFalse(local.is_locked())
262
hpss_call_names = [item.call.method for item in self.hpss_calls]
263
self.assertTrue('Repository.insert_stream' in hpss_call_names)
264
insert_stream_idx = hpss_call_names.index('Repository.insert_stream')
265
calls_after_insert_stream = hpss_call_names[insert_stream_idx:]
266
# After inserting the stream the client has no reason to query the
267
# remote graph any further.
269
['Repository.insert_stream', 'Repository.insert_stream', 'get',
270
'Branch.set_last_revision_info', 'Branch.unlock'],
271
calls_after_insert_stream)
273
def disableOptimisticGetParentMap(self):
274
# Tweak some class variables to stop remote get_parent_map calls asking
275
# for or receiving more data than the caller asked for.
276
old_flag = SmartServerRepositoryGetParentMap.no_extra_results
277
inter_class = repository.InterRepository
278
old_batch_size = inter_class._walk_to_common_revisions_batch_size
279
inter_class._walk_to_common_revisions_batch_size = 1
280
SmartServerRepositoryGetParentMap.no_extra_results = True
282
SmartServerRepositoryGetParentMap.no_extra_results = old_flag
283
inter_class._walk_to_common_revisions_batch_size = old_batch_size
284
self.addCleanup(reset_values)
228
287
class TestPushHook(TestCaseWithBranch):