[PATCH] Implementing the pager patch as an extension

Matt Mackall mpm at selenic.com
Thu Mar 20 11:05:55 CDT 2008

On Thu, 2008-03-20 at 01:02 +0100, David Soria Parra wrote:
> MPM and some others discussed the pager patch from me today in IRC and they wanted to see the pager
> patch as an extension instead of having it in core.
> so here is the patch. Alexis though that we should preserve the default behaviour of piping into a
> pager, which means that we accept broken pipe errors. As I don't like that solution very much, as
> those messages are really annoying I implemented it as a "feature". By default, the pager behaves
> exaclty the same way as it would if you pipe it on the shell "hg log | less", but you can silence
> the broken pipe errors by setting the pager.quiet variable to true.
> I hope you like the solution.

After I went offline yesterday, I came up with something very similar.
So I've applied yours and simplified it to:

def uisetup(ui):
    p = ui.config("pager", "pager", os.environ.get("PAGER"))
    if p and sys.stdout.isatty():
        if ui.configbool('pager', 'quiet'):
            signal.signal(signal.SIGPIPE, signal.SIG_DFL)
        sys.stderr = sys.stdout = os.popen(p, "wb")

(And removed the other implementation that got merged into core.)

Mathematics is the supreme nostalgia of our time.

More information about the Mercurial-devel mailing list