[PATCH RFC] dispatch: print 'abort:' when a pre-command hook fails

Siddharth Agarwal sid0 at fb.com
Tue Apr 16 21:44:18 UTC 2013


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1366148377 25200
#      Tue Apr 16 14:39:37 2013 -0700
# Node ID 58f26562aa8cc468c651d65b55c16e2c0f9946df
# Parent  1e9704ba956a08cb298be3afb9a90fcf9d54c142
dispatch: print 'abort:' when a pre-command hook fails

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.

diff -r 1e9704ba956a -r 58f26562aa8c mercurial/dispatch.py
--- a/mercurial/dispatch.py	Thu Mar 28 00:30:40 2013 -0700
+++ b/mercurial/dispatch.py	Tue Apr 16 14:39:37 2013 -0700
@@ -508,10 +508,8 @@ def _earlygetopt(aliases, args):
 
 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),
diff -r 1e9704ba956a -r 58f26562aa8c tests/test-hook.t
--- a/tests/test-hook.t	Thu Mar 28 00:30:40 2013 -0700
+++ b/tests/test-hook.t	Tue Apr 16 14:39:37 2013 -0700
@@ -71,8 +71,8 @@ test generic hooks
 
   $ 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



More information about the Mercurial-devel mailing list