comparison mercurial/commands.py @ 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
comparison
equal deleted inserted replaced
526:55af04e26bad 527:58790c83ce52
816 opts = [('v', 'verbose', None, 'verbose'), 816 opts = [('v', 'verbose', None, 'verbose'),
817 ('d', 'debug', None, 'debug'), 817 ('d', 'debug', None, 'debug'),
818 ('q', 'quiet', None, 'quiet'), 818 ('q', 'quiet', None, 'quiet'),
819 ('p', 'profile', None, 'profile'), 819 ('p', 'profile', None, 'profile'),
820 ('R', 'repository', "", 'repository root directory'), 820 ('R', 'repository', "", 'repository root directory'),
821 ('', 'traceback', None, 'print traceback on exception'),
821 ('y', 'noninteractive', None, 'run non-interactively'), 822 ('y', 'noninteractive', None, 'run non-interactively'),
822 ('', 'version', None, 'output version information and exit'), 823 ('', 'version', None, 'output version information and exit'),
823 ] 824 ]
824 825
825 args = fancyopts.fancyopts(args, opts, options, 826 args = fancyopts.fancyopts(args, opts, options,
853 u.warn("hg %s: %s\n" % (cmd, inst)) 854 u.warn("hg %s: %s\n" % (cmd, inst))
854 help(u, cmd) 855 help(u, cmd)
855 sys.exit(-1) 856 sys.exit(-1)
856 857
857 try: 858 try:
858 if cmd not in norepo.split(): 859 try:
859 path = options["repository"] or "" 860 if cmd not in norepo.split():
860 repo = hg.repository(ui=u, path=path) 861 path = options["repository"] or ""
861 d = lambda: i[0](u, repo, *args, **cmdoptions) 862 repo = hg.repository(ui=u, path=path)
862 else: 863 d = lambda: i[0](u, repo, *args, **cmdoptions)
863 d = lambda: i[0](u, *args, **cmdoptions) 864 else:
864 865 d = lambda: i[0](u, *args, **cmdoptions)
865 if options['profile']: 866
866 import hotshot, hotshot.stats 867 if options['profile']:
867 prof = hotshot.Profile("hg.prof") 868 import hotshot, hotshot.stats
868 r = prof.runcall(d) 869 prof = hotshot.Profile("hg.prof")
869 prof.close() 870 r = prof.runcall(d)
870 stats = hotshot.stats.load("hg.prof") 871 prof.close()
871 stats.strip_dirs() 872 stats = hotshot.stats.load("hg.prof")
872 stats.sort_stats('time', 'calls') 873 stats.strip_dirs()
873 stats.print_stats(40) 874 stats.sort_stats('time', 'calls')
874 return r 875 stats.print_stats(40)
875 else: 876 return r
876 return d() 877 else:
878 return d()
879 except:
880 if options['traceback']:
881 traceback.print_exc()
882 raise
877 except util.CommandError, inst: 883 except util.CommandError, inst:
878 u.warn("abort: %s\n" % inst.args) 884 u.warn("abort: %s\n" % inst.args)
879 except hg.RepoError, inst: 885 except hg.RepoError, inst:
880 u.warn("abort: ", inst, "!\n") 886 u.warn("abort: ", inst, "!\n")
881 except SignalInterrupt: 887 except SignalInterrupt: