Patchwork [1,of,4] addchangegroup: get the `node` argument of `incoming` hook from transaction

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 14, 2014, 10:58 p.m.
Message ID <abd625f5a330fa304b9e.1413327480@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6262/
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 1413270183 25200
#      Tue Oct 14 00:03:03 2014 -0700
# Node ID abd625f5a330fa304b9eedce34010768f94035c7
# Parent  ad8f99e232bc4041227b8b3231df81d963f8ae7e
addchangegroup: get the `node` argument of `incoming` hook from transaction

The transaction is now carrying hook-related informations. So we use it to
retrieve the `node` argument. This will also carry around all kinds of other useful
informations (like: "are we in a bundle2 processing")

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -735,12 +735,13 @@  def addchangegroup(repo, source, srctype
                 repo.ui.debug("updating the branch cache\n")
                 repo.hook("changegroup", source=srctype, url=url,
                           **tr.hookargs)
 
                 for n in added:
-                    repo.hook("incoming", node=hex(n), source=srctype,
-                              url=url)
+                    hookargs = tr.hookargs.copy()
+                    hookargs['node'] = hex(n)
+                    repo.hook("incoming", source=srctype, url=url, **hookargs)
 
                 newheads = [h for h in repo.heads() if h not in oldheads]
                 repo.ui.log("incoming",
                             "%s incoming changes - new heads: %s\n",
                             len(added),
diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -86,13 +86,13 @@  test generic hooks
   adding changesets
   adding manifests
   adding file changes
   added 3 changesets with 2 changes to 2 files
   changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
-  incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_URL=file:$TESTTMP/a
-  incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
-  incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
+  incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
+  incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
+  incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/a
   (run 'hg update' to get a working copy)
 
 tag hooks can see env vars
 
   $ cd ../a