pager: use ui._isatty infrastructure
authorMatt Mackall <mpm@selenic.com>
Sun, 20 May 2012 14:33:49 -0500
changeset 16752 359fda6cb01d
parent 16751 2d432a1fc0db
child 16753 9cca7b70f8df
pager: use ui._isatty infrastructure
hgext/pager.py
--- a/hgext/pager.py	Sun May 20 14:31:56 2012 -0500
+++ b/hgext/pager.py	Sun May 20 14:33:49 2012 -0500
@@ -53,7 +53,7 @@
 
 testedwith = 'internal'
 
-def _runpager(p):
+def _runpager(ui, p):
     pager = subprocess.Popen(p, shell=True, bufsize=-1,
                              close_fds=util.closefds, stdin=subprocess.PIPE,
                              stdout=sys.stdout, stderr=sys.stderr)
@@ -61,7 +61,7 @@
     stdout = os.dup(sys.stdout.fileno())
     stderr = os.dup(sys.stderr.fileno())
     os.dup2(pager.stdin.fileno(), sys.stdout.fileno())
-    if util.isatty(sys.stderr):
+    if ui._isatty(sys.stderr):
         os.dup2(pager.stdin.fileno(), sys.stderr.fileno())
 
     @atexit.register
@@ -72,7 +72,7 @@
         pager.wait()
 
 def uisetup(ui):
-    if ui.plain() or '--debugger' in sys.argv or not util.isatty(sys.stdout):
+    if '--debugger' in sys.argv or not ui.formatted():
         return
 
     def pagecmd(orig, ui, options, cmd, cmdfunc):
@@ -89,7 +89,7 @@
                 ui.setconfig('ui', 'interactive', False)
                 if util.safehasattr(signal, "SIGPIPE"):
                     signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-                _runpager(p)
+                _runpager(ui, p)
         return orig(ui, options, cmd, cmdfunc)
 
     extensions.wrapfunction(dispatch, '_runcommand', pagecmd)