Patchwork [1,of,2] pushkey: use hook arguments from transaction when one exists

login
register
mail settings
Submitter Pierre-Yves David
Date April 20, 2015, 4:44 p.m.
Message ID <2f9f8e4ca47e26dbf118.1429548263@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8746/
State Accepted
Commit 0325c0da05df2589b68682e9d78c79219f32c007
Headers show

Comments

Pierre-Yves David - April 20, 2015, 4:44 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1429542950 -7200
#      Mon Apr 20 17:15:50 2015 +0200
# Branch stable
# Node ID 2f9f8e4ca47e26dbf1183585edc364f3ef72c549
# Parent  8d7d0bf62f9f84fef087c07eef505d5cd5b4c602
pushkey: use hook arguments from transaction when one exists

When pushkey is called during a transaction, we include its 'hookargs' when
running the pre-pushkey hooks. Having more data cannot hurt, especially the
transaction ID.
Pierre-Yves David - April 20, 2015, 4:45 p.m.
On 04/20/2015 06:44 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1429542950 -7200
> #      Mon Apr 20 17:15:50 2015 +0200
> # Branch stable
> # Node ID 2f9f8e4ca47e26dbf1183585edc364f3ef72c549
> # Parent  8d7d0bf62f9f84fef087c07eef505d5cd5b4c602
> pushkey: use hook arguments from transaction when one exists

This series was intended for stable

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1896,12 +1896,19 @@  class localrepository(object):
             self.ui.restoreconfig(quiet)
         return ret
 
     def pushkey(self, namespace, key, old, new):
         try:
-            self.hook('prepushkey', throw=True, namespace=namespace, key=key,
-                      old=old, new=new)
+            tr = self.currenttransaction()
+            hookargs = {}
+            if tr is not None:
+                hookargs.update(tr.hookargs)
+            hookargs['namespace'] = namespace
+            hookargs['key'] = key
+            hookargs['old'] = old
+            hookargs['new'] = new
+            self.hook('prepushkey', throw=True, **hookargs)
         except error.HookAbort, exc:
             self.ui.write_err(_("pushkey-abort: %s\n") % exc)
             if exc.hint:
                 self.ui.write_err(_("(%s)\n") % exc.hint)
             return False