make ui flush output. this makes error happen if printing to /dev/full.
authorVadim Gelfer <vadim.gelfer@gmail.com>
Mon, 06 Mar 2006 08:35:15 -0800
changeset 1837 6f67a4c93493
parent 1836 cd5c1db2132a
child 1840 d17f19d84fd3
make ui flush output. this makes error happen if printing to /dev/full. before this change, error happened with some pythons, but not others. now always happens. fixes issue 155.
mercurial/commands.py
mercurial/ui.py
--- a/mercurial/commands.py	Sun Mar 05 01:37:28 2006 -0800
+++ b/mercurial/commands.py	Mon Mar 06 08:35:15 2006 -0800
@@ -2860,27 +2860,30 @@
             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']:
--- a/mercurial/ui.py	Sun Mar 05 01:37:28 2006 -0800
+++ b/mercurial/ui.py	Mon Mar 06 08:35:15 2006 -0800
@@ -132,6 +132,12 @@
         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"):