mercurial/commands.py
changeset 309 61414da06fe5
parent 306 f06a4a3b86a7
child 310 273f6a01d18b
equal deleted inserted replaced
308:075619d00dd7 309:61414da06fe5
   593 def dispatch(args):
   593 def dispatch(args):
   594     options = {}
   594     options = {}
   595     opts = [('v', 'verbose', None, 'verbose'),
   595     opts = [('v', 'verbose', None, 'verbose'),
   596             ('d', 'debug', None, 'debug'),
   596             ('d', 'debug', None, 'debug'),
   597             ('q', 'quiet', None, 'quiet'),
   597             ('q', 'quiet', None, 'quiet'),
       
   598             ('p', 'profile', None, 'profile'),
   598             ('y', 'noninteractive', None, 'run non-interactively'),
   599             ('y', 'noninteractive', None, 'run non-interactively'),
   599             ]
   600             ]
   600 
   601 
   601     args = fancyopts.fancyopts(args, opts, options,
   602     args = fancyopts.fancyopts(args, opts, options,
   602                                'hg [options] <command> [options] [files]')
   603                                'hg [options] <command> [options] [files]')
   631         d = lambda: i[0](u, repo, *args, **cmdoptions)
   632         d = lambda: i[0](u, repo, *args, **cmdoptions)
   632     else:
   633     else:
   633         d = lambda: i[0](u, *args, **cmdoptions)
   634         d = lambda: i[0](u, *args, **cmdoptions)
   634 
   635 
   635     try:
   636     try:
   636         return d()
   637         if options['profile']:
       
   638             import hotshot, hotshot.stats
       
   639             prof = hotshot.Profile("hg.prof")
       
   640             r = prof.runcall(d)
       
   641             prof.close()
       
   642             stats = hotshot.stats.load("hg.prof")
       
   643             stats.strip_dirs()
       
   644             stats.sort_stats('time', 'calls')
       
   645             stats.print_stats(40)
       
   646             return r
       
   647         else:
       
   648             return d()
   637     except SignalInterrupt:
   649     except SignalInterrupt:
   638         u.warn("killed!\n")
   650         u.warn("killed!\n")
   639     except KeyboardInterrupt:
   651     except KeyboardInterrupt:
   640         u.warn("interrupted!\n")
   652         u.warn("interrupted!\n")
   641     except IOError, inst:
   653     except IOError, inst: