diff mercurial/exchange.py @ 22971:3fe571c74b27

changegroup: store source and url in the `hookargs` dict We store the source and url of the current data into `transaction.hookargs` this let us inherit it from upper layers that may have created a much wider transaction. We have to modify bundle2 at the same time to register the source and url in the transaction. We have to do it in the same patch otherwise, the `addchangegroup` call would fill these values and the hook calling will crash because of the duplicated 'source' and 'url' arguments passed to the hook call.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 14 Oct 2014 00:06:46 -0700
parents a67ea4959ef5
children 44b16b59b80a
line wrap: on
line diff
--- a/mercurial/exchange.py	Tue Oct 14 00:43:20 2014 -0700
+++ b/mercurial/exchange.py	Tue Oct 14 00:06:46 2014 -0700
@@ -1235,15 +1235,16 @@
         if util.safehasattr(cg, 'params'):
             try:
                 tr = repo.transaction('unbundle')
+                tr.hookargs['source'] = source
+                tr.hookargs['url'] = url
                 tr.hookargs['bundle2-exp'] = '1'
                 r = bundle2.processbundle(repo, cg, lambda: tr).reply
                 cl = repo.unfiltered().changelog
                 p = cl.writepending() and repo.root or ""
-                repo.hook('b2x-pretransactionclose', throw=True, source=source,
-                          url=url, pending=p, **tr.hookargs)
+                repo.hook('b2x-pretransactionclose', throw=True, pending=p,
+                          **tr.hookargs)
                 tr.close()
-                repo.hook('b2x-transactionclose', source=source, url=url,
-                          **tr.hookargs)
+                repo.hook('b2x-transactionclose', **tr.hookargs)
             except Exception, exc:
                 exc.duringunbundle2 = True
                 raise