mercurial/changegroup.py
changeset 22971 3fe571c74b27
parent 22970 d82e2223f132
child 23168 a92ba36a1a9d
child 23224 f4ab47ccefde
--- a/mercurial/changegroup.py	Tue Oct 14 00:43:20 2014 -0700
+++ b/mercurial/changegroup.py	Tue Oct 14 00:06:46 2014 -0700
@@ -602,9 +602,14 @@
     oldheads = cl.heads()
 
     tr = repo.transaction("\n".join([srctype, util.hidepassword(url)]))
+    # The transaction could have been created before and already carries source
+    # information. In this case we use the top level data. We overwrite the
+    # argument because we need to use the top level value (if they exist) in
+    # this function.
+    srctype = tr.hookargs.setdefault('source', srctype)
+    url = tr.hookargs.setdefault('url', url)
     try:
-        repo.hook('prechangegroup', throw=True, source=srctype, url=url,
-                  **tr.hookargs)
+        repo.hook('prechangegroup', throw=True, **tr.hookargs)
 
         trp = weakref.proxy(tr)
         # pull off the changeset group
@@ -692,8 +697,7 @@
             else:
                 hookargs = dict(tr.hookargs)
                 hookargs['node'] = hex(cl.node(clstart))
-            repo.hook('pretxnchangegroup', throw=True, source=srctype,
-                      url=url, pending=p, **hookargs)
+            repo.hook('pretxnchangegroup', throw=True, pending=p, **hookargs)
 
         added = [cl.node(r) for r in xrange(clstart, clend)]
         publishing = repo.ui.configbool('phases', 'publish', True)
@@ -739,13 +743,12 @@
 
                 # forcefully update the on-disk branch cache
                 repo.ui.debug("updating the branch cache\n")
-                repo.hook("changegroup", source=srctype, url=url,
-                          **hookargs)
+                repo.hook("changegroup", **hookargs)
 
                 for n in added:
                     args = hookargs.copy()
                     args['node'] = hex(n)
-                    repo.hook("incoming", source=srctype, url=url, **args)
+                    repo.hook("incoming", **args)
 
                 newheads = [h for h in repo.heads() if h not in oldheads]
                 repo.ui.log("incoming",