branch | stable |
changeset 35028 | 7f8f9f0369ca |
parent 35027 | 7384250eabd9 |
child 35029 | e16f68c4abe3 |
35027:7384250eabd9 | 35028:7f8f9f0369ca |
---|---|
145 ferr = util.stderr |
145 ferr = util.stderr |
146 |
146 |
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 |
154 if req.fin: |
154 if req.fin: |
155 req.ui.fin = req.fin |
155 req.ui.fin = req.fin |
273 debugger = ui.config("ui", "debugger") |
273 debugger = ui.config("ui", "debugger") |
274 debugmod = pdb |
274 debugmod = pdb |
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 |
282 with demandimport.deactivated(): |
282 with demandimport.deactivated(): |
283 try: |
283 try: |
287 |
287 |
288 debugtrace[debugger] = debugmod.set_trace |
288 debugtrace[debugger] = debugmod.set_trace |
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 |
296 if (debugger != 'pdb' and |
296 if (debugger != 'pdb' and |
297 debugtrace[debugger] == debugtrace['pdb']): |
297 debugtrace[debugger] == debugtrace['pdb']): |
303 return _dispatch(req) |
303 return _dispatch(req) |
304 finally: |
304 finally: |
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 |
312 |
312 |
313 return _callcatch(ui, _runcatchfunc) |
313 return _callcatch(ui, _runcatchfunc) |
696 argcount -= 1 |
696 argcount -= 1 |
697 else: |
697 else: |
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), |
704 pats=cmdpats, opts=cmdoptions) |
708 pats=cmdpats, opts=cmdoptions) |
705 try: |
709 try: |
783 uis = {ui, lui} |
787 uis = {ui, lui} |
784 |
788 |
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 |
792 profile = lui.configbool('profiling', 'enabled') |
796 profile = lui.configbool('profiling', 'enabled') |
793 with profiling.profile(lui, enabled=profile) as profiler: |
797 with profiling.profile(lui, enabled=profile) as profiler: |