Chapter 11. Customizing the Output of Mercurial
Mercurial provides a powerful mechanism to let you control how it displays information. The mechanism is based on templates. You can use templates to generate specific output for a single command, or to customize the entire appearance of the built-in web interface.
Using Precanned Output Styles
Packaged with Mercurial are some output styles that you can use immediately. A style is simply a precanned template that someone wrote and installed somewhere that Mercurial can find.
Before we take a look at Mercurial’s bundled styles, let’s review its normal output.
$
hg log -r1
changeset: 1:59ae2fd35d8a tag: mytag user: Bryan O'Sullivan <bos@serpentine.com> date: Tue May 05 06:44:45 2009 +0000 summary: added line to end of <<hello>> file.
This is somewhat informative, but it takes up a lot of
space—five lines of output per changeset. The compact
style reduces this to three lines, presented in a sparse
manner.
$
hg log --style compact
3[tip] 4b984b80759d 2009-05-05 06:44 +0000 bos Added tag v0.1 for changeset cefd14841d41 2[v0.1] cefd14841d41 2009-05-05 06:44 +0000 bos Added tag mytag for changeset 59ae2fd35d8a 1[mytag] 59ae2fd35d8a 2009-05-05 06:44 +0000 bos added line to end of <<hello>> file. 0 6ed500684dd0 2009-05-05 06:44 +0000 bos added hello
The changelog
style hints at the
expressive power of Mercurial’s templating engine. This style attempts to follow the GNU Project’s changelog
guidelines.
$
hg log --style changelog
2009-05-05 Bryan O'Sullivan ...
Get Mercurial: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.