##// END OF EJS Templates
pager: use ui._isatty infrastructure
Matt Mackall -
r16752:359fda6c default
parent child Browse files
Show More
@@ -53,7 +53,7 b' from mercurial.i18n import _'
53
53
54 testedwith = 'internal'
54 testedwith = 'internal'
55
55
56 def _runpager(p):
56 def _runpager(ui, p):
57 pager = subprocess.Popen(p, shell=True, bufsize=-1,
57 pager = subprocess.Popen(p, shell=True, bufsize=-1,
58 close_fds=util.closefds, stdin=subprocess.PIPE,
58 close_fds=util.closefds, stdin=subprocess.PIPE,
59 stdout=sys.stdout, stderr=sys.stderr)
59 stdout=sys.stdout, stderr=sys.stderr)
@@ -61,7 +61,7 b' def _runpager(p):'
61 stdout = os.dup(sys.stdout.fileno())
61 stdout = os.dup(sys.stdout.fileno())
62 stderr = os.dup(sys.stderr.fileno())
62 stderr = os.dup(sys.stderr.fileno())
63 os.dup2(pager.stdin.fileno(), sys.stdout.fileno())
63 os.dup2(pager.stdin.fileno(), sys.stdout.fileno())
64 if util.isatty(sys.stderr):
64 if ui._isatty(sys.stderr):
65 os.dup2(pager.stdin.fileno(), sys.stderr.fileno())
65 os.dup2(pager.stdin.fileno(), sys.stderr.fileno())
66
66
67 @atexit.register
67 @atexit.register
@@ -72,7 +72,7 b' def _runpager(p):'
72 pager.wait()
72 pager.wait()
73
73
74 def uisetup(ui):
74 def uisetup(ui):
75 if ui.plain() or '--debugger' in sys.argv or not util.isatty(sys.stdout):
75 if '--debugger' in sys.argv or not ui.formatted():
76 return
76 return
77
77
78 def pagecmd(orig, ui, options, cmd, cmdfunc):
78 def pagecmd(orig, ui, options, cmd, cmdfunc):
@@ -89,7 +89,7 b' def uisetup(ui):'
89 ui.setconfig('ui', 'interactive', False)
89 ui.setconfig('ui', 'interactive', False)
90 if util.safehasattr(signal, "SIGPIPE"):
90 if util.safehasattr(signal, "SIGPIPE"):
91 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
91 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
92 _runpager(p)
92 _runpager(ui, p)
93 return orig(ui, options, cmd, cmdfunc)
93 return orig(ui, options, cmd, cmdfunc)
94
94
95 extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
95 extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
General Comments 0
You need to be logged in to leave comments. Login now