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