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