Mercurial 1.7.2 (and 1.6 and default): $ hg --config extensions.pager= cat foobarbaz yields exit code 0 and appending 2>foo would not write the error message to file foo $ hg --config extensions.pager=\! cat foobarbaz (or just "hg cat foobarbaz" if no pager configured) does not have above problems. What should be done here? Should the pager be used if there is an error?
We might not know if there's an error until there's a substantial amount of output. We obviously need to fix the return code issue. We should probably not redirect stderr either, though we should perhaps have a config setting to allow it.
We can simply check sys.stderr.isatty() and avoid redirecting it to the pager if it returns False. Since the pager is the parent process, I'm not sure how we can influence its return code. Ideally, the extension would run the pager as a child process and stop Mercurial from returning until the pager has returned. I haven't figured out a reliable way to do that, though.
Fixed by http://selenic.com/repo/hg/rev/994510694b1d Brodie Rao <brodie@bitheap.org> pager: don't page stderr if it's being redirected (issue2541) (please test the fix)
--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:15 EDT --- This bug was previously known as _bug_ 2541 at http://mercurial.selenic.com/bts/issue2541