##// END OF EJS Templates
help: document branch template keyword...
Adrian Buehlmann -
r13498:6ec84cbc stable
parent child Browse files
Show More
@@ -1,160 +1,163 b''
1 1 Mercurial allows you to customize output of commands through
2 2 templates. You can either pass in a template from the command
3 3 line, via the --template option, or select an existing
4 4 template-style (--style).
5 5
6 6 You can customize output for any "log-like" command: log,
7 7 outgoing, incoming, tip, parents, heads and glog.
8 8
9 9 Four styles are packaged with Mercurial: default (the style used
10 10 when no explicit preference is passed), compact, changelog,
11 11 and xml.
12 12 Usage::
13 13
14 14 $ hg log -r1 --style changelog
15 15
16 16 A template is a piece of text, with markup to invoke variable
17 17 expansion::
18 18
19 19 $ hg log -r1 --template "{node}\n"
20 20 b56ce7b07c52de7d5fd79fb89701ea538af65746
21 21
22 22 Strings in curly braces are called keywords. The availability of
23 23 keywords depends on the exact context of the templater. These
24 24 keywords are usually available for templating a log-like command:
25 25
26 26 :author: String. The unmodified author of the changeset.
27 27
28 :branch: String. The name of the branch on which the changeset was
29 committed.
30
28 31 :branches: List of strings. The name of the branch on which the
29 32 changeset was committed. Will be empty if the branch name was
30 33 default.
31 34
32 35 :children: List of strings. The children of the changeset.
33 36
34 37 :date: Date information. The date when the changeset was committed.
35 38
36 39 :desc: String. The text of the changeset description.
37 40
38 41 :diffstat: String. Statistics of changes with the following format:
39 42 "modified files: +added/-removed lines"
40 43
41 44 :files: List of strings. All files modified, added, or removed by this
42 45 changeset.
43 46
44 47 :file_adds: List of strings. Files added by this changeset.
45 48
46 49 :file_copies: List of strings. Files copied in this changeset with
47 50 their sources.
48 51
49 52 :file_copies_switch: List of strings. Like "file_copies" but displayed
50 53 only if the --copied switch is set.
51 54
52 55 :file_mods: List of strings. Files modified by this changeset.
53 56
54 57 :file_dels: List of strings. Files removed by this changeset.
55 58
56 59 :node: String. The changeset identification hash, as a 40 hexadecimal
57 60 digit string.
58 61
59 62 :parents: List of strings. The parents of the changeset.
60 63
61 64 :rev: Integer. The repository-local changeset revision number.
62 65
63 66 :tags: List of strings. Any tags associated with the changeset.
64 67
65 68 :latesttag: String. Most recent global tag in the ancestors of this
66 69 changeset.
67 70
68 71 :latesttagdistance: Integer. Longest path to the latest tag.
69 72
70 73 The "date" keyword does not produce human-readable output. If you
71 74 want to use a date in your output, you can use a filter to process
72 75 it. Filters are functions which return a string based on the input
73 76 variable. Be sure to use the stringify filter first when you're
74 77 applying a string-input filter to a list-like input variable.
75 78 You can also use a chain of filters to get the desired output::
76 79
77 80 $ hg tip --template "{date|isodate}\n"
78 81 2008-08-21 18:22 +0000
79 82
80 83 List of filters:
81 84
82 85 :addbreaks: Any text. Add an XHTML "<br />" tag before the end of
83 86 every line except the last.
84 87
85 88 :age: Date. Returns a human-readable date/time difference between the
86 89 given date/time and the current date/time.
87 90
88 91 :basename: Any text. Treats the text as a path, and returns the last
89 92 component of the path after splitting by the path separator
90 93 (ignoring trailing separators). For example, "foo/bar/baz" becomes
91 94 "baz" and "foo/bar//" becomes "bar".
92 95
93 96 :stripdir: Treat the text as path and strip a directory level, if
94 97 possible. For example, "foo" and "foo/bar" becomes "foo".
95 98
96 99 :date: Date. Returns a date in a Unix date format, including the
97 100 timezone: "Mon Sep 04 15:13:13 2006 0700".
98 101
99 102 :domain: Any text. Finds the first string that looks like an email
100 103 address, and extracts just the domain component. Example: ``User
101 104 <user@example.com>`` becomes ``example.com``.
102 105
103 106 :email: Any text. Extracts the first string that looks like an email
104 107 address. Example: ``User <user@example.com>`` becomes
105 108 ``user@example.com``.
106 109
107 110 :escape: Any text. Replaces the special XML/XHTML characters "&", "<"
108 111 and ">" with XML entities.
109 112
110 113 :hex: Any text. Convert a binary Mercurial node identifier into
111 114 its long hexadecimal representation.
112 115
113 116 :fill68: Any text. Wraps the text to fit in 68 columns.
114 117
115 118 :fill76: Any text. Wraps the text to fit in 76 columns.
116 119
117 120 :firstline: Any text. Returns the first line of text.
118 121
119 122 :nonempty: Any text. Returns '(none)' if the string is empty.
120 123
121 124 :hgdate: Date. Returns the date as a pair of numbers: "1157407993
122 125 25200" (Unix timestamp, timezone offset).
123 126
124 127 :isodate: Date. Returns the date in ISO 8601 format: "2009-08-18 13:00
125 128 +0200".
126 129
127 130 :isodatesec: Date. Returns the date in ISO 8601 format, including
128 131 seconds: "2009-08-18 13:00:13 +0200". See also the rfc3339date
129 132 filter.
130 133
131 134 :localdate: Date. Converts a date to local date.
132 135
133 136 :obfuscate: Any text. Returns the input text rendered as a sequence of
134 137 XML entities.
135 138
136 139 :person: Any text. Returns the text before an email address.
137 140
138 141 :rfc822date: Date. Returns a date using the same format used in email
139 142 headers: "Tue, 18 Aug 2009 13:00:13 +0200".
140 143
141 144 :rfc3339date: Date. Returns a date using the Internet date format
142 145 specified in RFC 3339: "2009-08-18T13:00:13+02:00".
143 146
144 147 :short: Changeset hash. Returns the short form of a changeset hash,
145 148 i.e. a 12 hexadecimal digit string.
146 149
147 150 :shortdate: Date. Returns a date like "2006-09-18".
148 151
149 152 :stringify: Any type. Turns the value into text by converting values into
150 153 text and concatenating them.
151 154
152 155 :strip: Any text. Strips all leading and trailing whitespace.
153 156
154 157 :tabindent: Any text. Returns the text, with every line except the
155 158 first starting with a tab character.
156 159
157 160 :urlescape: Any text. Escapes all "special" characters. For example,
158 161 "foo bar" becomes "foo%20bar".
159 162
160 163 :user: Any text. Returns the user portion of an email address.
General Comments 0
You need to be logged in to leave comments. Login now