changeset 19011:12acbea17625

dispatch: print 'abort:' when a pre-command hook fails (BC) This also changes the exit code from whatever the hook returned to 255. This brings it in line with all the other hooks that abort.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 16 Apr 2013 14:39:37 -0700
parents e071d161b266
children 811e253226c3
files mercurial/dispatch.py tests/test-hook.t
diffstat 2 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Mon Apr 15 23:31:56 2013 +0200
+++ b/mercurial/dispatch.py	Tue Apr 16 14:39:37 2013 -0700
@@ -511,10 +511,8 @@
 
 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
     # run pre-hook, and abort if it fails
-    ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs),
-                    pats=cmdpats, opts=cmdoptions)
-    if ret:
-        return ret
+    hook.hook(lui, repo, "pre-%s" % cmd, True, args=" ".join(fullargs),
+              pats=cmdpats, opts=cmdoptions)
     ret = _runcommand(ui, options, cmd, d)
     # run post-hook, passing command result
     hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
--- a/tests/test-hook.t	Mon Apr 15 23:31:56 2013 +0200
+++ b/tests/test-hook.t	Tue Apr 16 14:39:37 2013 -0700
@@ -71,8 +71,8 @@
 
   $ hg id
   pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[]
-  warning: pre-identify hook exited with status 1
-  [1]
+  abort: pre-identify hook exited with status 1
+  [255]
   $ hg cat b
   pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
   b