1 Mercurial allows you to customize output of commands through |
|
2 templates. You can either pass in a template from the command |
|
3 line, via the --template option, or select an existing |
|
4 template-style (--style). |
|
5 |
|
6 You can customize output for any "log-like" command: log, |
|
7 outgoing, incoming, tip, parents, heads and glog. |
|
8 |
|
9 Three styles are packaged with Mercurial: default (the style used |
|
10 when no explicit preference is passed), compact and changelog. |
|
11 Usage:: |
|
12 |
|
13 $ hg log -r1 --style changelog |
|
14 |
|
15 A template is a piece of text, with markup to invoke variable |
|
16 expansion:: |
|
17 |
|
18 $ hg log -r1 --template "{node}\n" |
|
19 b56ce7b07c52de7d5fd79fb89701ea538af65746 |
|
20 |
|
21 Strings in curly braces are called keywords. The availability of |
|
22 keywords depends on the exact context of the templater. These |
|
23 keywords are usually available for templating a log-like command: |
|
24 |
|
25 :author: String. The unmodified author of the changeset. |
|
26 :branches: String. The name of the branch on which the changeset |
|
27 was committed. Will be empty if the branch name was |
|
28 default. |
|
29 :date: Date information. The date when the changeset was |
|
30 committed. |
|
31 :desc: String. The text of the changeset description. |
|
32 :diffstat: String. Statistics of changes with the following |
|
33 format: "modified files: +added/-removed lines" |
|
34 :files: List of strings. All files modified, added, or removed |
|
35 by this changeset. |
|
36 :file_adds: List of strings. Files added by this changeset. |
|
37 :file_mods: List of strings. Files modified by this changeset. |
|
38 :file_dels: List of strings. Files removed by this changeset. |
|
39 :node: String. The changeset identification hash, as a |
|
40 40-character hexadecimal string. |
|
41 :parents: List of strings. The parents of the changeset. |
|
42 :rev: Integer. The repository-local changeset revision |
|
43 number. |
|
44 :tags: List of strings. Any tags associated with the |
|
45 changeset. |
|
46 :latesttag: String. Most recent global tag in the ancestors of this |
|
47 changeset. |
|
48 :latesttagdistance: Integer. Longest path to the latest tag. |
|
49 |
|
50 The "date" keyword does not produce human-readable output. If you |
|
51 want to use a date in your output, you can use a filter to process |
|
52 it. Filters are functions which return a string based on the input |
|
53 variable. You can also use a chain of filters to get the desired |
|
54 output:: |
|
55 |
|
56 $ hg tip --template "{date|isodate}\n" |
|
57 2008-08-21 18:22 +0000 |
|
58 |
|
59 List of filters: |
|
60 |
|
61 :addbreaks: Any text. Add an XHTML "<br />" tag before the end of |
|
62 every line except the last. |
|
63 :age: Date. Returns a human-readable date/time difference |
|
64 between the given date/time and the current |
|
65 date/time. |
|
66 :basename: Any text. Treats the text as a path, and returns the |
|
67 last component of the path after splitting by the |
|
68 path separator (ignoring trailing separators). For |
|
69 example, "foo/bar/baz" becomes "baz" and "foo/bar//" |
|
70 becomes "bar". |
|
71 :stripdir: Treat the text as path and strip a directory level, |
|
72 if possible. For example, "foo" and "foo/bar" becomes |
|
73 "foo". |
|
74 :date: Date. Returns a date in a Unix date format, including |
|
75 the timezone: "Mon Sep 04 15:13:13 2006 0700". |
|
76 :domain: Any text. Finds the first string that looks like an |
|
77 email address, and extracts just the domain |
|
78 component. Example: ``User <user@example.com>`` becomes |
|
79 ``example.com``. |
|
80 :email: Any text. Extracts the first string that looks like |
|
81 an email address. Example: ``User <user@example.com>`` |
|
82 becomes ``user@example.com``. |
|
83 :escape: Any text. Replaces the special XML/XHTML characters |
|
84 "&", "<" and ">" with XML entities. |
|
85 :fill68: Any text. Wraps the text to fit in 68 columns. |
|
86 :fill76: Any text. Wraps the text to fit in 76 columns. |
|
87 :firstline: Any text. Returns the first line of text. |
|
88 :nonempty: Any text. Returns '(none)' if the string is empty. |
|
89 :hgdate: Date. Returns the date as a pair of numbers: |
|
90 "1157407993 25200" (Unix timestamp, timezone offset). |
|
91 :isodate: Date. Returns the date in ISO 8601 format: |
|
92 "2009-08-18 13:00 +0200". |
|
93 :isodatesec: Date. Returns the date in ISO 8601 format, including |
|
94 seconds: "2009-08-18 13:00:13 +0200". See also the |
|
95 rfc3339date filter. |
|
96 :localdate: Date. Converts a date to local date. |
|
97 :obfuscate: Any text. Returns the input text rendered as a |
|
98 sequence of XML entities. |
|
99 :person: Any text. Returns the text before an email address. |
|
100 :rfc822date: Date. Returns a date using the same format used in |
|
101 email headers: "Tue, 18 Aug 2009 13:00:13 +0200". |
|
102 :rfc3339date: Date. Returns a date using the Internet date format |
|
103 specified in RFC 3339: "2009-08-18T13:00:13+02:00". |
|
104 :short: Changeset hash. Returns the short form of a changeset |
|
105 hash, i.e. a 12-byte hexadecimal string. |
|
106 :shortdate: Date. Returns a date like "2006-09-18". |
|
107 :strip: Any text. Strips all leading and trailing whitespace. |
|
108 :tabindent: Any text. Returns the text, with every line except |
|
109 the first starting with a tab character. |
|
110 :urlescape: Any text. Escapes all "special" characters. For |
|
111 example, "foo bar" becomes "foo%20bar". |
|
112 :user: Any text. Returns the user portion of an email |
|
113 address. |
|