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