changeset 527:58790c83ce52

[PATCH] Add --traceback option -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [PATCH] Add --traceback option From: Bryan O'Sullivan <bos@serpentine.com> Add --traceback option, to force printing tracebacks on top-level exceptions. manifest hash: 4347f42205b8b23835424b4e4100860ff2834b95 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCwx7GywK+sNU5EO8RAgS8AKCmJAvTMGNJYYIW9eTI3RAqJZMfYACfS/rl Hn1Ukml5D1fdSvyehH2G080= =eLJO -----END PGP SIGNATURE-----
author mpm@selenic.com
date Wed, 29 Jun 2005 14:20:54 -0800
parents 55af04e26bad
children 648386fabf9c abaea35387a8
files mercurial/commands.py
diffstat 1 files changed, 24 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Jun 29 14:15:16 2005 -0800
+++ b/mercurial/commands.py	Wed Jun 29 14:20:54 2005 -0800
@@ -818,6 +818,7 @@
             ('q', 'quiet', None, 'quiet'),
             ('p', 'profile', None, 'profile'),
             ('R', 'repository', "", 'repository root directory'),
+            ('', 'traceback', None, 'print traceback on exception'),
             ('y', 'noninteractive', None, 'run non-interactively'),
             ('', 'version', None, 'output version information and exit'),
             ]
@@ -855,25 +856,30 @@
         sys.exit(-1)
 
     try:
-        if cmd not in norepo.split():
-            path = options["repository"] or ""
-            repo = hg.repository(ui=u, path=path)
-            d = lambda: i[0](u, repo, *args, **cmdoptions)
-        else:
-            d = lambda: i[0](u, *args, **cmdoptions)
+        try:
+            if cmd not in norepo.split():
+                path = options["repository"] or ""
+                repo = hg.repository(ui=u, path=path)
+                d = lambda: i[0](u, repo, *args, **cmdoptions)
+            else:
+                d = lambda: i[0](u, *args, **cmdoptions)
 
-        if options['profile']:
-            import hotshot, hotshot.stats
-            prof = hotshot.Profile("hg.prof")
-            r = prof.runcall(d)
-            prof.close()
-            stats = hotshot.stats.load("hg.prof")
-            stats.strip_dirs()
-            stats.sort_stats('time', 'calls')
-            stats.print_stats(40)
-            return r
-        else:
-            return d()
+            if options['profile']:
+                import hotshot, hotshot.stats
+                prof = hotshot.Profile("hg.prof")
+                r = prof.runcall(d)
+                prof.close()
+                stats = hotshot.stats.load("hg.prof")
+                stats.strip_dirs()
+                stats.sort_stats('time', 'calls')
+                stats.print_stats(40)
+                return r
+            else:
+                return d()
+        except:
+            if options['traceback']:
+                traceback.print_exc()
+            raise
     except util.CommandError, inst:
         u.warn("abort: %s\n" % inst.args)
     except hg.RepoError, inst: