# HG changeset patch # User Siddharth Agarwal # Date 2013-04-16 21:39:37 # Node ID 12acbea17625a1441503418f7f2f49aa3825cf2f # Parent e071d161b266d785ba65fda937e6bc735b150244 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. diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -511,10 +511,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 --git a/tests/test-hook.t b/tests/test-hook.t --- a/tests/test-hook.t +++ b/tests/test-hook.t @@ -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