mercurial’s pager

For quiet some while, I play around with distributed version control systems. Particularly GIT. To think outside of the box I, sometimes try out mercurial. Mercurial works like a charm, only the lack of using a pager to display logs or other long output annoyed me. For sure I could define an alias or always pipe the output to a pager, but I looked for a “out-of-the-box” solution, like GIT provides one.

To make a long story short, the latest changesets on mercurial added a pager extension. To enable the pager, just add the following lines to your local .hg/hgrc or to your global .hgrc:

[extensions]
hgext.pager =

By default, the pager extension uses the environment variable $PAGER.

As mercurial want to be more platform independent than GIT, the developers care about not doing too much platform-dependend stuff. Therefore, if you use less(1) as a default pager, the pager will popup always, even for a oneliner. GIT avoids this by defining special less environment variables, which are to specific to be included into mercurial. To fix that behaviour yourself either define the environment variable LESS=’FSRX’ in your .bashrc or override the pager used by mercurial using the folliwng line in your .hgrc:

[pager]
application = LESS=’FSRX’ less

The pager extensions tries to do exactly the same as if the output would be piped on the bash. Therefore you might notice BROKEN PIPE errors, when you quit the pager before mercurial finished to write all the output. If you get annoyed by that error, use the quiet variable to silence it. It is not enabled by default.

[pager]
quiet = True

Browsing long changesets is now joy.

Leave a Reply