Common Template Keywords

You can start writing simple templates immediately using the keywords below:

  • author: String. The unmodified author of the changeset.

  • branches: String. The name of the branch on which the changeset was committed. Will be empty if the branch name was default.

  • date: Date information. The date when the changeset was committed. This is not human-readable; you must pass it through a filter that will render it appropriately. See Filtering Keywords to Change Their Results for more information on filters. The date is expressed as a pair of numbers. The first number is a Unix UTC timestamp (seconds since January 1, 1970); the second is the offset of the committer’s timezone from UTC, in seconds.

  • desc: String. The text of the changeset description.

  • files: List of strings. All files modified, added, or removed by this changeset.

  • file_adds: List of strings. Files added by this changeset.

  • file_dels: List of strings. Files removed by this changeset.

  • node: String. The changeset identification hash, as a 40-character hexadecimal string.

  • parents: List of strings. The parents of the changeset.

  • rev: Integer. The repository-local changeset revision number.

  • tags: List of strings. Any tags associated with the changeset.

A few simple experiments will show us what to expect when we use these keywords; you can see the results below.

$ hg log -r1 --template 'author: {author}\n'
author: Bryan O'Sullivan <bos@serpentine.com>
$ hg log -r1 --template 'desc:\n{desc}\n' desc: added line to end of <<hello>> ...

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.