# HG changeset patch # User mpm@selenic.com # Date 1126224571 25200 # Node ID ea90162e210cb3a95ed3cd1eaba8862e372524d9 # Parent cc61d366bc3b5dffe98a68bea888527a5944ea56 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. diff -r cc61d366bc3b -r ea90162e210c mercurial/commands.py --- 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