diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -416,7 +416,7 @@ def _widen( repo, trmanager.transaction, source=b'widen' ) # TODO: we should catch error.Abort here - bundle2.processbundle(repo, bundle, op=op) + bundle2.processbundle(repo, bundle, op=op, remote=remote) if ellipsesremote: with ds.parentchange(): diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -315,8 +315,17 @@ class bundleoperation: * a way to construct a bundle response when applicable. """ - def __init__(self, repo, transactiongetter, captureoutput=True, source=b''): + def __init__( + self, + repo, + transactiongetter, + captureoutput=True, + source=b'', + remote=None, + ): self.repo = repo + # the peer object who produced this bundle if available + self.remote = remote self.ui = repo.ui self.records = unbundlerecords() self.reply = None @@ -363,7 +372,7 @@ def _notransaction(): raise TransactionUnavailable() -def applybundle(repo, unbundler, tr, source, url=None, **kwargs): +def applybundle(repo, unbundler, tr, source, url=None, remote=None, **kwargs): # transform me into unbundler.apply() as soon as the freeze is lifted if isinstance(unbundler, unbundle20): tr.hookargs[b'bundle2'] = b'1' @@ -371,10 +380,12 @@ def applybundle(repo, unbundler, tr, sou tr.hookargs[b'source'] = source if url is not None and b'url' not in tr.hookargs: tr.hookargs[b'url'] = url - return processbundle(repo, unbundler, lambda: tr, source=source) + return processbundle( + repo, unbundler, lambda: tr, source=source, remote=remote + ) else: # the transactiongetter won't be used, but we might as well set it - op = bundleoperation(repo, lambda: tr, source=source) + op = bundleoperation(repo, lambda: tr, source=source, remote=remote) _processchangegroup(op, unbundler, tr, source, url, **kwargs) return op @@ -450,7 +461,14 @@ class partiterator: ) -def processbundle(repo, unbundler, transactiongetter=None, op=None, source=b''): +def processbundle( + repo, + unbundler, + transactiongetter=None, + op=None, + source=b'', + remote=None, +): """This function process a bundle, apply effect to/from a repo It iterates over each part then searches for and uses the proper handling @@ -466,7 +484,12 @@ def processbundle(repo, unbundler, trans if op is None: if transactiongetter is None: transactiongetter = _notransaction - op = bundleoperation(repo, transactiongetter, source=source) + op = bundleoperation( + repo, + transactiongetter, + source=source, + remote=remote, + ) # todo: # - replace this is a init function soon. # - exception catching diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -1183,7 +1183,12 @@ def _pushbundle2(pushop): trgetter = None if pushback: trgetter = pushop.trmanager.transaction - op = bundle2.processbundle(pushop.repo, reply, trgetter) + op = bundle2.processbundle( + pushop.repo, + reply, + trgetter, + remote=pushop.remote, + ) except error.BundleValueError as exc: raise error.RemoteError(_(b'missing support for %s') % exc) except bundle2.AbortFromPart as exc: @@ -1903,10 +1908,18 @@ def _pullbundle2(pullop): try: op = bundle2.bundleoperation( - pullop.repo, pullop.gettransaction, source=b'pull' + pullop.repo, + pullop.gettransaction, + source=b'pull', + remote=pullop.remote, ) op.modes[b'bookmarks'] = b'records' - bundle2.processbundle(pullop.repo, bundle, op=op) + bundle2.processbundle( + pullop.repo, + bundle, + op=op, + remote=pullop.remote, + ) except bundle2.AbortFromPart as exc: pullop.repo.ui.error(_(b'remote: abort: %s\n') % exc) raise error.RemoteError(_(b'pull failed on remote'), hint=exc.hint) @@ -1995,7 +2008,12 @@ def _pullchangeset(pullop): ).result() bundleop = bundle2.applybundle( - pullop.repo, cg, tr, b'pull', pullop.remote.url() + pullop.repo, + cg, + tr, + b'pull', + pullop.remote.url(), + remote=pullop.remote, ) pullop.cgresult = bundle2.combinechangegroupresults(bundleop)