##// END OF EJS Templates
dispatch: extract stub function to peek boolean command option...
Yuya Nishihara -
r35057:7f8f9f03 stable
parent child Browse files
Show More
@@ -147,7 +147,7 def dispatch(req):
147 147 try:
148 148 if not req.ui:
149 149 req.ui = uimod.ui.load()
150 if '--traceback' in req.args:
150 if _earlyreqoptbool(req, 'traceback', ['--traceback']):
151 151 req.ui.setconfig('ui', 'traceback', 'on', '--traceback')
152 152
153 153 # set ui streams from the request
@@ -275,7 +275,7 def _runcatch(req):
275 275 if not debugger or ui.plain():
276 276 # if we are in HGPLAIN mode, then disable custom debugging
277 277 debugger = 'pdb'
278 elif '--debugger' in req.args:
278 elif _earlyreqoptbool(req, 'debugger', ['--debugger']):
279 279 # This import can be slow for fancy debuggers, so only
280 280 # do it when absolutely necessary, i.e. when actual
281 281 # debugging has been requested
@@ -289,7 +289,7 def _runcatch(req):
289 289 debugmortem[debugger] = debugmod.post_mortem
290 290
291 291 # enter the debugger before command execution
292 if '--debugger' in req.args:
292 if _earlyreqoptbool(req, 'debugger', ['--debugger']):
293 293 ui.warn(_("entering debugger - "
294 294 "type c to continue starting hg or h for help\n"))
295 295
@@ -305,7 +305,7 def _runcatch(req):
305 305 ui.flush()
306 306 except: # re-raises
307 307 # enter the debugger when we hit an exception
308 if '--debugger' in req.args:
308 if _earlyreqoptbool(req, 'debugger', ['--debugger']):
309 309 traceback.print_exc()
310 310 debugmortem[debugger](sys.exc_info()[2])
311 311 raise
@@ -698,6 +698,10 def _earlygetopt(aliases, args):
698 698 pos += 1
699 699 return values
700 700
701 def _earlyreqoptbool(req, name, aliases):
702 assert len(aliases) == 1
703 return aliases[0] in req.args
704
701 705 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
702 706 # run pre-hook, and abort if it fails
703 707 hook.hook(lui, repo, "pre-%s" % cmd, True, args=" ".join(fullargs),
@@ -785,7 +789,7 def _dispatch(req):
785 789 if req.repo:
786 790 uis.add(req.repo.ui)
787 791
788 if '--profile' in args:
792 if _earlyreqoptbool(req, 'profile', ['--profile']):
789 793 for ui_ in uis:
790 794 ui_.setconfig('profiling', 'enabled', 'true', '--profile')
791 795
General Comments 0
You need to be logged in to leave comments. Login now