infinitepush: fix tests

In 272dd7d8a1bb1b2e93697b5b65183b08c8bf0853 upstream hg commit phase pushes
started to use separate bundle2 part. Because of that:
1) pushkey hook is not called when updating phases.
2) pushkey bundle2 part doesn't process phases anymore, 'phase-heads' part do
it instead.

It caused breakages in infinitepush, because phases handling is not skipped even during
infinitepush.  This diff fixes it.

Test Plan:
Run infinitepush tests

Differential Revision: https://phab.mercurial-scm.org/D1225
This commit is contained in:
Stanislau Hlebik 2017-10-24 09:33:41 -07:00
parent 29bb657526
commit be4f75067d

View File

@ -267,6 +267,12 @@ def serverextsetup(ui):
newpushkeyhandler.params = origpushkeyhandler.params
bundle2.parthandlermapping['pushkey'] = newpushkeyhandler
orighandlephasehandler = bundle2.parthandlermapping['phase-heads']
newphaseheadshandler = lambda *args, **kwargs: \
bundle2handlephases(orighandlephasehandler, *args, **kwargs)
newphaseheadshandler.params = orighandlephasehandler.params
bundle2.parthandlermapping['phase-heads'] = newphaseheadshandler
wrapfunction(localrepo.localrepository, 'listkeys', localrepolistkeys)
wireproto.commands['lookup'] = (
_lookupwrap(wireproto.commands['lookup'][0]), 'key')
@ -1006,9 +1012,11 @@ def processparts(orig, repo, op, unbundler):
cgparams = part.params
# If we're not dumping all parts into the new bundle, we need to
# alert the future pushkey handler to skip the part.
# alert the future pushkey and phase-heads handler to skip
# the part.
if not handleallparts:
op.records.add(scratchbranchparttype + '_skippushkey', True)
op.records.add(scratchbranchparttype + '_skipphaseheads', True)
elif part.type == scratchbookmarksparttype:
# Save this for later processing. Details below.
scratchbookpart = part
@ -1221,6 +1229,11 @@ def _maybeaddpushbackpart(op, bookmark, newnode, oldnode, params):
op.reply.newpart('pushkey', mandatoryparams=params.iteritems())
def bundle2pushkey(orig, op, part):
'''Wrapper of bundle2.handlepushkey()
The only goal is to skip calling the original function if flag is set.
It's set if infinitepush push is happening.
'''
if op.records[scratchbranchparttype + '_skippushkey']:
if op.reply is not None:
rpart = op.reply.newpart('reply:pushkey')
@ -1230,6 +1243,18 @@ def bundle2pushkey(orig, op, part):
return orig(op, part)
def bundle2handlephases(orig, op, part):
'''Wrapper of bundle2.handlephases()
The only goal is to skip calling the original function if flag is set.
It's set if infinitepush push is happening.
'''
if op.records[scratchbranchparttype + '_skipphaseheads']:
return
return orig(op, part)
def _asyncsavemetadata(root, nodes):
'''starts a separate process that fills metadata for the nodes