changeset 3737:9f5c46c50118

add a simple nested buffering scheme to ui
author Matt Mackall <mpm@selenic.com>
date Fri, 01 Dec 2006 01:28:18 -0600
parents ad3d5b4367cb
children cb48cd27d3f4
files mercurial/ui.py
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Thu Nov 30 22:38:48 2006 -0600
+++ b/mercurial/ui.py	Fri Dec 01 01:28:18 2006 -0600
@@ -29,6 +29,7 @@
                  interactive=True, traceback=False, report_untrusted=True,
                  parentui=None):
         self.overlay = None
+        self.buffers = []
         if parentui is None:
             # this is the parent of all ui children
             self.parentui = None
@@ -367,9 +368,18 @@
             path = self.config("paths", default)
         return path or loc
 
+    def pushbuffer(self):
+        self.buffers.append([])
+
+    def popbuffer(self):
+        return "".join(self.buffers.pop())
+
     def write(self, *args):
-        for a in args:
-            sys.stdout.write(str(a))
+        if self.buffers:
+            self.buffers[-1].extend([str(a) for a in args])
+        else:
+            for a in args:
+                sys.stdout.write(str(a))
 
     def write_err(self, *args):
         try: