addchangegroup: call `prechangegroup` hook after transaction retrieval
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 14 Oct 2014 00:09:25 -0700
changeset 22969 805c18b27f48
parent 22968 01e98eba3bc1
child 22970 d82e2223f132
addchangegroup: call `prechangegroup` hook after transaction retrieval We want to reused some possible information stored in the transaction `hookargs` dict that may be stored by something handling the transaction at an upper level (eg: bundle2) So we move the running of the hooks after transaction creation. This has no visible effects (but an empty transaction roolback if the hook fails) because nothing had happened in the transaction yet.
mercurial/changegroup.py
--- a/mercurial/changegroup.py	Tue Oct 14 00:03:03 2014 -0700
+++ b/mercurial/changegroup.py	Tue Oct 14 00:09:25 2014 -0700
@@ -592,8 +592,6 @@
     if not source:
         return 0
 
-    repo.hook('prechangegroup', throw=True, source=srctype, url=url)
-
     changesets = files = revisions = 0
     efiles = set()
 
@@ -605,6 +603,8 @@
 
     tr = repo.transaction("\n".join([srctype, util.hidepassword(url)]))
     try:
+        repo.hook('prechangegroup', throw=True, source=srctype, url=url)
+
         trp = weakref.proxy(tr)
         # pull off the changeset group
         repo.ui.status(_("adding changesets\n"))