two fixes for the pager stuff
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Wed, 19 Mar 2008 16:54:35 -0300
changeset 6303 577a7da1d44b
parent 6302 8e3dc3de7e73
child 6304 d99b4e8652b3
two fixes for the pager stuff - open pipe in binary mode - don't start a pager if stdout is not a tty (this prevents test-ssh from hanging if you set ui.usepager=True in run-tests.py)
mercurial/ui.py
--- a/mercurial/ui.py	Tue Mar 18 22:12:34 2008 +0100
+++ b/mercurial/ui.py	Wed Mar 19 16:54:35 2008 -0300
@@ -385,7 +385,7 @@
             self.buffers[-1].extend([str(a) for a in args])
         else:
             if self.getpager() and not self.pager:
-                self.pager = os.popen(self.getpager(), "w")
+                self.pager = os.popen(self.getpager(), "wb")
                 sys.stderr = self.pager
                 sys.stdout = self.pager
             for a in args:
@@ -495,6 +495,6 @@
 
     def getpager(self):
         '''return a pager'''
-        if self.configbool("ui", "usepager", False):
+        if sys.stdout.isatty() and self.configbool("ui", "usepager", False):
             return (self.config("ui", "pager")
                     or os.environ.get("PAGER"))