Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.4rc1, 0.4rc2, and 0.4rc3

overlay: fix typo in --lsprof option to test module

Traceback induced by lsprof was caused by bug in Mercurial, which
has been fixed in crew changeset 30c40ba10963

Changeset e4ba1a3dddf5

Parent e2244d8d10d0

by Adrian Buehlmann

Changes to one file · Browse files at e4ba1a3dddf5 Showing diff from parent e2244d8d10d0 Diff from another changeset...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
 
 
112
113
114
115
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 
 
110
111
112
113
114
115
 #  # development and stub-testing module for overlay icon handlers  #    import os, sys, time, atexit  from mercurial import ui  from mercurial.i18n import _    # FIXMEL: quick & dirty hack to add tortoise to module search path  import __init__  moddir = os.path.dirname(__init__.__file__)  sys.path.insert(0, os.path.join(moddir, os.pardir))    from iconoverlay import IconOverlayExtension    def lsprof(checkargs):   try:   from mercurial import lsprof   except ImportError:   raise util.Abort(_(   'lsprof not available - install from '   'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))   p = lsprof.Profiler()   p.enable(subcalls=True)   try:   return checkargs()   finally:   p.disable()   stats = lsprof.Stats(p.getstats())   stats.sort()   stats.pprint(top=10, file=sys.stderr, climit=5)    def profile(checkargs):   import hotshot, hotshot.stats   prof = hotshot.Profile("hg.prof")   try:   try:   return prof.runcall(checkargs)   except:   try:   ui.warn(_('exception raised - generating '   'profile anyway\n'))   except:   pass   raise   finally:   prof.close()   stats = hotshot.stats.load("hg.prof")   stats.strip_dirs()   stats.sort_stats('cumulative', 'time', 'calls')   stats.print_stats(40)    def timeit():   u = ui.ui()   def get_times():   t = os.times()   if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()   t = (t[0], t[1], t[2], t[3], time.clock())   return t   s = get_times()   def print_time():   t = get_times()   u.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %   (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))     atexit.register(print_time)    def get_option(args):   import getopt   long_opt_list = ('time', 'lsprof', 'profile')   opts, args = getopt.getopt(args, "", long_opt_list)   options = {}   for o, a in opts:   options[o] = a   return options, args      if __name__=='__main__':   ovh = IconOverlayExtension()     option, argv = get_option(sys.argv[1:])   path = len(argv) and argv[0] or os.getcwd()   path = os.path.abspath(path)     # get the list of files residing in the target directory   dirname = os.path.dirname(path)   if dirname == path:   dirlist = [path]   else:   dirlist = [os.path.join(dirname, x) for x in os.listdir(dirname)]     # first call to _get_state() is usually longer...   def get_state_1st():   ovh._get_state(path)     # subsequent call to _get_state() using the files in   # the target directory   def get_state_2nd():   for f in dirlist:   ovh._get_state(f)     # 'master' function for profiling purpose   def get_states():   get_state_1st()   get_state_2nd()     if option.has_key('--time'):   timeit()   - if option.has_key('--lsprod'): - lsprof(get_states) # fixme: lsprof traceback on win32 (only?) + if option.has_key('--lsprof'): + lsprof(get_states)   elif option.has_key('--profile'):   profile(get_states)   else:   get_states()