Patchwork [2,of,3] hook: fewer parentheses for hook load errors

login
register
mail settings
Submitter Siddharth Agarwal
Date Feb. 12, 2016, 7:04 a.m.
Message ID <da66d8660fc331fe4d73.1455260652@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/13126/
State Accepted
Headers show

Comments

Siddharth Agarwal - Feb. 12, 2016, 7:04 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1455259280 28800
#      Thu Feb 11 22:41:20 2016 -0800
# Node ID da66d8660fc331fe4d73298fa497cff3a830fa6b
# Parent  8afad172ca2c68b1d1f8f814bbf08911479f3140
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r da66d8660fc3
hook: fewer parentheses for hook load errors

This matches 'hook failed' warnings.

We're also going to add hints to some of the hook load errors. Without this
change we'd have two pairs of parens for a single error message, which looks
really cluttered.

Patch

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -65,7 +65,7 @@  def _pythonhook(ui, repo, name, hname, f
                                   'attempt:\n'))
                     ui.traceback(e2)
                     raise error.HookLoadError(
-                        _('%s hook is invalid (import of "%s" failed)') %
+                        _('%s hook is invalid: import of "%s" failed') %
                         (hname, modname))
         sys.path = oldpaths
         try:
@@ -73,11 +73,11 @@  def _pythonhook(ui, repo, name, hname, f
                 obj = getattr(obj, p)
         except AttributeError:
             raise error.HookLoadError(
-                _('%s hook is invalid ("%s" is not defined)')
+                _('%s hook is invalid: "%s" is not defined')
                 % (hname, funcname))
         if not callable(obj):
             raise error.HookLoadError(
-                _('%s hook is invalid ("%s" is not callable)')
+                _('%s hook is invalid: "%s" is not callable')
                 % (hname, funcname))
 
     ui.note(_("calling hook %s: %s\n") % (hname, funcname))
diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -480,7 +480,7 @@  test python hooks
   $ hg pull ../a
   pulling from ../a
   searching for changes
-  abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable)
+  abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
   [255]
 
   $ echo '[hooks]' > ../a/.hg/hgrc
@@ -488,7 +488,7 @@  test python hooks
   $ hg pull ../a
   pulling from ../a
   searching for changes
-  abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined)
+  abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
   [255]
 
   $ echo '[hooks]' > ../a/.hg/hgrc
@@ -504,7 +504,7 @@  test python hooks
   $ hg pull ../a
   pulling from ../a
   searching for changes
-  abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed)
+  abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
   [255]
 
   $ echo '[hooks]' > ../a/.hg/hgrc
@@ -512,7 +512,7 @@  test python hooks
   $ hg pull ../a
   pulling from ../a
   searching for changes
-  abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed)
+  abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
   [255]
 
   $ echo '[hooks]' > ../a/.hg/hgrc
@@ -628,8 +628,8 @@  make sure --traceback works on hook impo
   Traceback (most recent call last):
   ImportError: No module named hgext_importfail
   Traceback (most recent call last):
-  HookLoadError: precommit.importfail hook is invalid (import of "importfail" failed)
-  abort: precommit.importfail hook is invalid (import of "importfail" failed)
+  HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed
+  abort: precommit.importfail hook is invalid: import of "importfail" failed
 
 Issue1827: Hooks Update & Commit not completely post operation