[PATCH stable] pager: don't page stderr if it's being redirected (issue2541)
Brodie Rao
brodie at bitheap.org
Mon Jan 3 13:29:38 UTC 2011
# HG changeset patch
# User Brodie Rao <brodie at bitheap.org>
# Date 1294061074 -39600
# Branch stable
# Node ID 9ba813298ede02adf9d3dbc5ecb876e92071e7ec
# Parent 5d1bb1174047030036fcca00004573fc9f2c0713
pager: don't page stderr if it's being redirected (issue2541)
diff --git a/hgext/pager.py b/hgext/pager.py
--- a/hgext/pager.py
+++ b/hgext/pager.py
@@ -59,14 +59,17 @@ from mercurial.i18n import _
def _runpager(p):
if not hasattr(os, 'fork'):
- sys.stderr = sys.stdout = util.popen(p, 'wb')
+ sys.stdout = util.popen(p, 'wb')
+ if sys.stderr.isatty():
+ sys.stderr = sys.stdout
return
fdin, fdout = os.pipe()
pid = os.fork()
if pid == 0:
os.close(fdin)
os.dup2(fdout, sys.stdout.fileno())
- os.dup2(fdout, sys.stderr.fileno())
+ if sys.stderr.isatty():
+ os.dup2(fdout, sys.stderr.fileno())
os.close(fdout)
return
os.dup2(fdin, sys.stdin.fileno())
More information about the Mercurial-devel
mailing list