Patchwork [3,of,7,V2] hook: fix name used in untrusted message

login
register
mail settings
Submitter Pierre-Yves David
Date March 31, 2017, 10:43 p.m.
Message ID <e033dfed0a983e7c4230.1491000211@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/19883/
State Accepted
Headers show

Comments

Pierre-Yves David - March 31, 2017, 10:43 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1490950925 -7200
#      Fri Mar 31 11:02:05 2017 +0200
# Node ID e033dfed0a983e7c4230fd16eb86bce0e2008659
# Parent  c81fb978412978f5d10879987ed5a571cb9b0904
# EXP-Topic hookname
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r e033dfed0a98
hook: fix name used in untrusted message

The name used in the message we issue when a hook is untrusted was using "name"
which is actually the hook type and not the name of the hook.

Patch

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -223,9 +223,9 @@  def runhooks(ui, repo, name, hooks, thro
             if cmd is _fromuntrusted:
                 if throw:
                     raise error.HookAbort(
-                        _('untrusted hook %s not executed') % name,
+                        _('untrusted hook %s not executed') % hname,
                         hint = _("see 'hg help config.trusted'"))
-                ui.warn(_('warning: untrusted hook %s not executed\n') % name)
+                ui.warn(_('warning: untrusted hook %s not executed\n') % hname)
                 r = 1
                 raised = False
             elif callable(cmd):
diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -904,7 +904,7 @@  Non-blocking hook
   > txnclose.testing=echo txnclose hook called
   > EOF
   $ touch a && hg commit -Aqm a
-  warning: untrusted hook txnclose not executed
+  warning: untrusted hook txnclose.testing not executed
   $ hg log
   changeset:   0:3903775176ed
   tag:         tip
@@ -923,7 +923,7 @@  Non-blocking hook
   $ touch b && hg commit -Aqm a
   transaction abort!
   rollback completed
-  abort: untrusted hook pretxnclose not executed
+  abort: untrusted hook pretxnclose.testing not executed
   (see 'hg help config.trusted')
   [255]
   $ hg log