dmitry@294: Mercurial allows you to customize output of commands through dmitry@294: templates. You can either pass in a template from the command dmitry@294: line, via the --template option, or select an existing dmitry@294: template-style (--style). dmitry@294: dmitry@294: You can customize output for any "log-like" command: log, dmitry@294: outgoing, incoming, tip, parents, heads and glog. dmitry@294: dmitry@294: Four styles are packaged with Mercurial: default (the style used dmitry@294: when no explicit preference is passed), compact, changelog, dmitry@294: and xml. dmitry@294: Usage:: dmitry@294: dmitry@294: $ hg log -r1 --style changelog dmitry@294: dmitry@294: A template is a piece of text, with markup to invoke variable dmitry@294: expansion:: dmitry@294: dmitry@294: $ hg log -r1 --template "{node}\n" dmitry@294: b56ce7b07c52de7d5fd79fb89701ea538af65746 dmitry@294: dmitry@294: Strings in curly braces are called keywords. The availability of dmitry@294: keywords depends on the exact context of the templater. These dmitry@294: keywords are usually available for templating a log-like command: dmitry@294: dmitry@294: :author: String. The unmodified author of the changeset. dmitry@294: dmitry@294: :branches: String. The name of the branch on which the changeset was dmitry@294: committed. Will be empty if the branch name was default. dmitry@294: dmitry@294: :date: Date information. The date when the changeset was committed. dmitry@294: dmitry@294: :desc: String. The text of the changeset description. dmitry@294: dmitry@294: :diffstat: String. Statistics of changes with the following format: dmitry@294: "modified files: +added/-removed lines" dmitry@294: dmitry@294: :files: List of strings. All files modified, added, or removed by this dmitry@294: changeset. dmitry@294: dmitry@294: :file_adds: List of strings. Files added by this changeset. dmitry@294: dmitry@294: :file_copies: List of strings. Files copied in this changeset with dmitry@294: their sources. dmitry@294: dmitry@294: :file_copies_switch: List of strings. Like "file_copies" but displayed dmitry@294: only if the --copied switch is set. dmitry@294: dmitry@294: :file_mods: List of strings. Files modified by this changeset. dmitry@294: dmitry@294: :file_dels: List of strings. Files removed by this changeset. dmitry@294: dmitry@294: :node: String. The changeset identification hash, as a 40-character dmitry@294: hexadecimal string. dmitry@294: dmitry@294: :parents: List of strings. The parents of the changeset. dmitry@294: dmitry@294: :rev: Integer. The repository-local changeset revision number. dmitry@294: dmitry@294: :tags: List of strings. Any tags associated with the changeset. dmitry@294: dmitry@294: :latesttag: String. Most recent global tag in the ancestors of this dmitry@294: changeset. dmitry@294: dmitry@294: :latesttagdistance: Integer. Longest path to the latest tag. dmitry@294: dmitry@294: The "date" keyword does not produce human-readable output. If you dmitry@294: want to use a date in your output, you can use a filter to process dmitry@294: it. Filters are functions which return a string based on the input dmitry@294: variable. Be sure to use the stringify filter first when you're dmitry@294: applying a string-input filter to a list-like input variable. dmitry@294: You can also use a chain of filters to get the desired output:: dmitry@294: dmitry@294: $ hg tip --template "{date|isodate}\n" dmitry@294: 2008-08-21 18:22 +0000 dmitry@294: dmitry@294: List of filters: dmitry@294: dmitry@294: :addbreaks: Any text. Add an XHTML "
" tag before the end of dmitry@294: every line except the last. dmitry@294: dmitry@294: :age: Date. Returns a human-readable date/time difference between the dmitry@294: given date/time and the current date/time. dmitry@294: dmitry@294: :basename: Any text. Treats the text as a path, and returns the last dmitry@294: component of the path after splitting by the path separator dmitry@294: (ignoring trailing separators). For example, "foo/bar/baz" becomes dmitry@294: "baz" and "foo/bar//" becomes "bar". dmitry@294: dmitry@294: :stripdir: Treat the text as path and strip a directory level, if dmitry@294: possible. For example, "foo" and "foo/bar" becomes "foo". dmitry@294: dmitry@294: :date: Date. Returns a date in a Unix date format, including the dmitry@294: timezone: "Mon Sep 04 15:13:13 2006 0700". dmitry@294: dmitry@294: :domain: Any text. Finds the first string that looks like an email dmitry@294: address, and extracts just the domain component. Example: ``User dmitry@294: `` becomes ``example.com``. dmitry@294: dmitry@294: :email: Any text. Extracts the first string that looks like an email dmitry@294: address. Example: ``User `` becomes dmitry@294: ``user@example.com``. dmitry@294: dmitry@294: :escape: Any text. Replaces the special XML/XHTML characters "&", "<" dmitry@294: and ">" with XML entities. dmitry@294: dmitry@294: :fill68: Any text. Wraps the text to fit in 68 columns. dmitry@294: dmitry@294: :fill76: Any text. Wraps the text to fit in 76 columns. dmitry@294: dmitry@294: :firstline: Any text. Returns the first line of text. dmitry@294: dmitry@294: :nonempty: Any text. Returns '(none)' if the string is empty. dmitry@294: dmitry@294: :hgdate: Date. Returns the date as a pair of numbers: "1157407993 dmitry@294: 25200" (Unix timestamp, timezone offset). dmitry@294: dmitry@294: :isodate: Date. Returns the date in ISO 8601 format: "2009-08-18 13:00 dmitry@294: +0200". dmitry@294: dmitry@294: :isodatesec: Date. Returns the date in ISO 8601 format, including dmitry@294: seconds: "2009-08-18 13:00:13 +0200". See also the rfc3339date dmitry@294: filter. dmitry@294: dmitry@294: :localdate: Date. Converts a date to local date. dmitry@294: dmitry@294: :obfuscate: Any text. Returns the input text rendered as a sequence of dmitry@294: XML entities. dmitry@294: dmitry@294: :person: Any text. Returns the text before an email address. dmitry@294: dmitry@294: :rfc822date: Date. Returns a date using the same format used in email dmitry@294: headers: "Tue, 18 Aug 2009 13:00:13 +0200". dmitry@294: dmitry@294: :rfc3339date: Date. Returns a date using the Internet date format dmitry@294: specified in RFC 3339: "2009-08-18T13:00:13+02:00". dmitry@294: dmitry@294: :short: Changeset hash. Returns the short form of a changeset hash, dmitry@294: i.e. a 12-byte hexadecimal string. dmitry@294: dmitry@294: :shortdate: Date. Returns a date like "2006-09-18". dmitry@294: dmitry@294: :strip: Any text. Strips all leading and trailing whitespace. dmitry@294: dmitry@294: :tabindent: Any text. Returns the text, with every line except the dmitry@294: first starting with a tab character. dmitry@294: dmitry@294: :urlescape: Any text. Escapes all "special" characters. For example, dmitry@294: "foo bar" becomes "foo%20bar". dmitry@294: dmitry@294: :user: Any text. Returns the user portion of an email address.