mercurial/bundle2.py
changeset 49764 4188e75af983
parent 49648 9be765b82a90
child 49766 f1887500f3ec
--- a/mercurial/bundle2.py	Mon Dec 05 03:23:46 2022 +0100
+++ b/mercurial/bundle2.py	Sat Dec 03 01:16:22 2022 +0100
@@ -315,8 +315,17 @@
     * 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 @@
     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 @@
             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 @@
         )
 
 
-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 @@
     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