mercurial/commands.py
changeset 1840 d17f19d84fd3
parent 1839 876e4e6ad82b
parent 1837 6f67a4c93493
child 1847 94498a262d15
child 1848 bb70ffebe77b
equal deleted inserted replaced
1839:876e4e6ad82b 1840:d17f19d84fd3
  2861                         x.reposetup(u, repo)
  2861                         x.reposetup(u, repo)
  2862                 d = lambda: func(u, repo, *args, **cmdoptions)
  2862                 d = lambda: func(u, repo, *args, **cmdoptions)
  2863             else:
  2863             else:
  2864                 d = lambda: func(u, *args, **cmdoptions)
  2864                 d = lambda: func(u, *args, **cmdoptions)
  2865 
  2865 
  2866             if options['profile']:
  2866             try:
  2867                 import hotshot, hotshot.stats
  2867                 if options['profile']:
  2868                 prof = hotshot.Profile("hg.prof")
  2868                     import hotshot, hotshot.stats
  2869                 try:
  2869                     prof = hotshot.Profile("hg.prof")
  2870                     try:
  2870                     try:
  2871                         return prof.runcall(d)
       
  2872                     except:
       
  2873                         try:
  2871                         try:
  2874                             u.warn(_('exception raised - generating profile '
  2872                             return prof.runcall(d)
  2875                                      'anyway\n'))
       
  2876                         except:
  2873                         except:
  2877                             pass
  2874                             try:
  2878                         raise
  2875                                 u.warn(_('exception raised - generating '
  2879                 finally:
  2876                                          'profile anyway\n'))
  2880                     prof.close()
  2877                             except:
  2881                     stats = hotshot.stats.load("hg.prof")
  2878                                 pass
  2882                     stats.strip_dirs()
  2879                             raise
  2883                     stats.sort_stats('time', 'calls')
  2880                     finally:
  2884                     stats.print_stats(40)
  2881                         prof.close()
  2885             else:
  2882                         stats = hotshot.stats.load("hg.prof")
  2886                 return d()
  2883                         stats.strip_dirs()
       
  2884                         stats.sort_stats('time', 'calls')
       
  2885                         stats.print_stats(40)
       
  2886                 else:
       
  2887                     return d()
       
  2888             finally:
       
  2889                 u.flush()
  2887         except:
  2890         except:
  2888             # enter the debugger when we hit an exception
  2891             # enter the debugger when we hit an exception
  2889             if options['debugger']:
  2892             if options['debugger']:
  2890                 pdb.post_mortem(sys.exc_info()[2])
  2893                 pdb.post_mortem(sys.exc_info()[2])
  2891             if options['traceback']:
  2894             if options['traceback']: