Filtering Keywords to Change Their Results
Some of the results of template expansion are not
immediately easy to use. Mercurial lets you specify an optional chain of
filters to modify the result of expanding a
keyword. You have already seen a common filter, isodate
, in action above, to make
a date readable.
Below is a list of the most commonly used filters that Mercurial supports. While some filters can be applied to any text, others can only be used in specific circumstances. The name of each filter is followed first by an indication of where it can be used, then a description of its effect.
addbreaks
: Any text. Add an XHTML <br/> tag before the end of every line except the last. For example, foo\nbar becomes foo<br/>\nbar.age
:date
keyword. Render the age of the date, relative to the current time. Yields a string like 10 minutes.basename
: Any text, but most useful for thefiles
keyword and its relatives. Treat the text as a path, and return the basename. For example, foo/bar/baz becomes baz.date
:date
keyword. Render a date in a similar format to the Unixdate
command, but with timezone included. Yields a string like Mon Sep 04 15:13:13 2006 -0700.domain
: Any text, but most useful for theauthor
keyword. Find the first string that looks like an email address, and extract just the domain component. For example, Bryan O’Sullivan <bos@serpentine.com> becomes serpentine.com.email
: Any text, but most useful for theauthor
keyword. Extract the first string that looks like an email address. ...
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.