# HG changeset patch # User Thomas Arendsen Hein # Date 1141663991 -3600 # Node ID d17f19d84fd391cecc02e57e0db2323dbc5de872 # Parent 876e4e6ad82b6012daf19f99fbd17badc8c6596e# Parent 6f67a4c93493ea07d3756aab20c341d2b03edbf8 Merge with crew diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2863,27 +2863,30 @@ def dispatch(args): else: d = lambda: func(u, *args, **cmdoptions) - if options['profile']: - import hotshot, hotshot.stats - prof = hotshot.Profile("hg.prof") - try: + try: + if options['profile']: + import hotshot, hotshot.stats + prof = hotshot.Profile("hg.prof") try: - return prof.runcall(d) - except: try: - u.warn(_('exception raised - generating profile ' - 'anyway\n')) + return prof.runcall(d) except: - pass - raise - finally: - prof.close() - stats = hotshot.stats.load("hg.prof") - stats.strip_dirs() - stats.sort_stats('time', 'calls') - stats.print_stats(40) - else: - return d() + try: + u.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('time', 'calls') + stats.print_stats(40) + else: + return d() + finally: + u.flush() except: # enter the debugger when we hit an exception if options['debugger']: diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -152,6 +152,12 @@ class ui(object): for a in args: sys.stderr.write(str(a)) + def flush(self): + try: + sys.stdout.flush() + finally: + sys.stderr.flush() + def readline(self): return sys.stdin.readline()[:-1] def prompt(self, msg, pat, default="y"):