Mercurial > hg
changeset 1225:ea90162e210c
Add --debugger global option
With this option, hg will drop into the Python debugger on execution.
Running 'continue' will execute normally, and the debugger will be
reinvoked if an exception is raised.
author | mpm@selenic.com |
---|---|
date | Thu, 08 Sep 2005 17:09:31 -0700 |
parents | cc61d366bc3b |
children | f3837564ed03 |
files | mercurial/commands.py |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Sep 08 15:01:33 2005 -0700 +++ b/mercurial/commands.py Thu Sep 08 17:09:31 2005 -0700 @@ -7,7 +7,7 @@ from demandload import demandload from node import * -demandload(globals(), "os re sys signal shutil imp urllib") +demandload(globals(), "os re sys signal shutil imp urllib pdb") demandload(globals(), "fancyopts ui hg util lock revlog") demandload(globals(), "fnmatch hgweb mdiff random signal time traceback") demandload(globals(), "errno socket version struct atexit sets bz2") @@ -1849,6 +1849,7 @@ ('q', 'quiet', None, 'quiet mode'), ('v', 'verbose', None, 'verbose mode'), ('', 'debug', None, 'debug mode'), + ('', 'debugger', None, 'start debugger'), ('', 'traceback', None, 'print traceback on exception'), ('', 'time', None, 'time how long the command takes'), ('', 'profile', None, 'profile'), @@ -1970,6 +1971,10 @@ u.updateopts(options["verbose"], options["debug"], options["quiet"], not options["noninteractive"]) + # enter the debugger before command execution + if options['debugger']: + pdb.set_trace() + try: try: if options['help']: @@ -2011,6 +2016,9 @@ else: return d() except: + # enter the debugger when we hit an exception + if options['debugger']: + pdb.post_mortem(sys.exc_info()[2]) if options['traceback']: traceback.print_exc() raise