Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/cmdutil.py @ 4548:c9fcebbfc422
dispatch: move runcommand to cmdutil
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 11 Jun 2007 21:09:24 -0500 |
parents | 78b6add1f966 |
children | 0c61124ad877 |
comparison
equal
deleted
inserted
replaced
4547:8774d2cafe4d | 4548:c9fcebbfc422 |
---|---|
8 from node import * | 8 from node import * |
9 from i18n import _ | 9 from i18n import _ |
10 import os, sys, mdiff, bdiff, util, templater, patch | 10 import os, sys, mdiff, bdiff, util, templater, patch |
11 | 11 |
12 revrangesep = ':' | 12 revrangesep = ':' |
13 | |
14 def runcommand(u, options, d): | |
15 # enter the debugger before command execution | |
16 if options['debugger']: | |
17 pdb.set_trace() | |
18 | |
19 try: | |
20 try: | |
21 if options['profile']: | |
22 import hotshot, hotshot.stats | |
23 prof = hotshot.Profile("hg.prof") | |
24 try: | |
25 try: | |
26 return prof.runcall(d) | |
27 except: | |
28 try: | |
29 u.warn(_('exception raised - generating ' | |
30 'profile anyway\n')) | |
31 except: | |
32 pass | |
33 raise | |
34 finally: | |
35 prof.close() | |
36 stats = hotshot.stats.load("hg.prof") | |
37 stats.strip_dirs() | |
38 stats.sort_stats('time', 'calls') | |
39 stats.print_stats(40) | |
40 elif options['lsprof']: | |
41 try: | |
42 from mercurial import lsprof | |
43 except ImportError: | |
44 raise util.Abort(_( | |
45 'lsprof not available - install from ' | |
46 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/')) | |
47 p = lsprof.Profiler() | |
48 p.enable(subcalls=True) | |
49 try: | |
50 return d() | |
51 finally: | |
52 p.disable() | |
53 stats = lsprof.Stats(p.getstats()) | |
54 stats.sort() | |
55 stats.pprint(top=10, file=sys.stderr, climit=5) | |
56 else: | |
57 return d() | |
58 finally: | |
59 u.flush() | |
60 except: | |
61 # enter the debugger when we hit an exception | |
62 if options['debugger']: | |
63 pdb.post_mortem(sys.exc_info()[2]) | |
64 u.print_exc() | |
65 raise | |
13 | 66 |
14 def parseurl(url, revs): | 67 def parseurl(url, revs): |
15 '''parse url#branch, returning url, branch + revs''' | 68 '''parse url#branch, returning url, branch + revs''' |
16 | 69 |
17 if '#' not in url: | 70 if '#' not in url: |