[PATCH 1 of 1] dispatch: extract command execution block into method
Bill Barry
after.fallout at gmail.com
Thu Feb 12 10:43:58 CST 2009
# HG changeset patch
# User Bill Barry <after.fallout at gmail.com>
# Date 1234456575 25200
# Node ID 811cba8fb7dfc3b430d56aec4587cec59f0d5a9a
# Parent 9f73bddb9d0bf1531523f4b328e8ae0de1247f09
dispatch: extract command execution block into method
This pulls the pre-command hook/command/post-command hook workflow out of
the method it is in and puts it into its own method so that it potentially
could be exposed for extensions to wrap.
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -239,6 +239,17 @@
pos += 1
return values
+def runcommand(lui, repo, cmd, fullargs, ui, options, d):
+ # run pre-hook, and abort if it fails
+ ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs))
+ if ret:
+ return ret
+ ret = _runcommand(ui, options, cmd, d)
+ # run post-hook, passing command result
+ hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
+ result = ret)
+ return ret
+
_loaded = {}
def _dispatch(ui, args):
# read --config before doing anything else
@@ -358,16 +369,7 @@
ui.warn("warning: --repository ignored\n")
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
-
- # run pre-hook, and abort if it fails
- ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs))
- if ret:
- return ret
- ret = _runcommand(ui, options, cmd, d)
- # run post-hook, passing command result
- hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
- result = ret)
- return ret
+ return runcommand(lui, repo, cmd, fullargs, ui, options, d)
def _runcommand(ui, options, cmd, cmdfunc):
def checkargs():
More information about the Mercurial-devel
mailing list