pushrebase use hookargs correctly if transaction was taken

Summary:
Context: for Mononoke sync job we are considering applying a few pushrebase
bundles under the same transaction to make sync job faster. More details -
https://fburl.com/y4we86hc

Doing two pushrebases under the same transaction seems to fail for  just one
reason - `hookargs` is None on the second bundle. The reason is this line -
https://fburl.com/y4we86hc, after gettransaction() is called
bundleoperation.hookargs is set to None, but transaction.hookargs is set to
current hookargs value.

In this diff pushrebase is changed to check both bundleoperation.hookargs and
transaction.hookargs

Reviewed By: quark-zju

Differential Revision: D14930970

fbshipit-source-id: e4a4dd1c85b1fdca2699dd431040d65f2642ec8a
This commit is contained in:
Stanislau Hlebik 2019-04-16 03:07:24 -07:00 committed by Facebook Github Bot
parent f337e0d5e4
commit e1e5d4bb0d

View File

@ -1328,7 +1328,23 @@ def prepushrebasehooks(op, params, bundle, bundlefile):
prelockontonode = prelockonto.hex() if prelockonto else None
# Allow running hooks on the new commits before we take the lock
prelockrebaseargs = op.hookargs.copy()
if op.hookargs is None:
# Usually pushrebase prepushrebasehooks are called outside of
# transaction. If that's the case then op.hookargs is not None and
# it contains hook arguments.
# However Mononoke -> hg sync job might replay two bundles under
# the same transaction. In that case hookargs are stored in transaction
# object (see bundle2operation:gettransaction).
#
# For reference: Mononoke -> hg sync job uses wireproto.py:unbundlereplay
# function as it's entry point
tr = op.repo.currenttransaction()
if tr is not None:
prelockrebaseargs = tr.hookargs.copy()
else:
raise error.ProgrammingError("internal error: hookargs are not set")
else:
prelockrebaseargs = op.hookargs.copy()
prelockrebaseargs["source"] = "push"
prelockrebaseargs["bundle2"] = "1"
prelockrebaseargs["node"] = scmutil.revsingle(bundle, "min(bundle())").hex()