##// END OF EJS Templates
dispatch: extract command execution block into method...
Bill Barry -
r7819:14b70325 default
parent child Browse files
Show More
@@ -239,6 +239,17 b' def _earlygetopt(aliases, args):'
239 pos += 1
239 pos += 1
240 return values
240 return values
241
241
242 def runcommand(lui, repo, cmd, fullargs, ui, options, d):
243 # run pre-hook, and abort if it fails
244 ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs))
245 if ret:
246 return ret
247 ret = _runcommand(ui, options, cmd, d)
248 # run post-hook, passing command result
249 hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
250 result = ret)
251 return ret
252
242 _loaded = {}
253 _loaded = {}
243 def _dispatch(ui, args):
254 def _dispatch(ui, args):
244 # read --config before doing anything else
255 # read --config before doing anything else
@@ -358,16 +369,7 b' def _dispatch(ui, args):'
358 ui.warn("warning: --repository ignored\n")
369 ui.warn("warning: --repository ignored\n")
359
370
360 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
371 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
361
372 return runcommand(lui, repo, cmd, fullargs, ui, options, d)
362 # run pre-hook, and abort if it fails
363 ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs))
364 if ret:
365 return ret
366 ret = _runcommand(ui, options, cmd, d)
367 # run post-hook, passing command result
368 hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
369 result = ret)
370 return ret
371
373
372 def _runcommand(ui, options, cmd, cmdfunc):
374 def _runcommand(ui, options, cmd, cmdfunc):
373 def checkargs():
375 def checkargs():
General Comments 0
You need to be logged in to leave comments. Login now