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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Apr 20 16:44:23 UTC 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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


More information about the Mercurial-devel mailing list