Patchwork [2,of,4] addchangegroup: call `prechangegroup` hook after transaction retrieval

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 14, 2014, 10:58 p.m.
Message ID <628b5ad287da3c1ae043.1413327481@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6261/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 14, 2014, 10:58 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413270565 25200
#      Tue Oct 14 00:09:25 2014 -0700
# Node ID 628b5ad287da3c1ae043a2eb4b1338d7c1a891c7
# Parent  abd625f5a330fa304b9eedce34010768f94035c7
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.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -590,12 +590,10 @@  def addchangegroup(repo, source, srctype
         return cl.rev(x)
 
     if not source:
         return 0
 
-    repo.hook('prechangegroup', throw=True, source=srctype, url=url)
-
     changesets = files = revisions = 0
     efiles = set()
 
     # write changelog data to temp files so concurrent readers will not see
     # inconsistent view
@@ -603,10 +601,12 @@  def addchangegroup(repo, source, srctype
     cl.delayupdate()
     oldheads = cl.heads()
 
     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"))
         clstart = len(cl)
         class prog(object):