##// END OF EJS Templates
help: add a topic about some of the templating features
Alexander Solovyov -
r7677:6a0bc2dc default
parent child Browse files
Show More
@@ -1,251 +1,334
1 # help.py - help data for mercurial
1 # help.py - help data for mercurial
2 #
2 #
3 # Copyright 2006 Matt Mackall <mpm@selenic.com>
3 # Copyright 2006 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms
5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference.
6 # of the GNU General Public License, incorporated herein by reference.
7
7
8 from i18n import _
8 from i18n import _
9
9
10 helptable = (
10 helptable = (
11 (["dates"], _("Date Formats"),
11 (["dates"], _("Date Formats"),
12 _(r'''
12 _(r'''
13 Some commands allow the user to specify a date:
13 Some commands allow the user to specify a date:
14 backout, commit, import, tag: Specify the commit date.
14 backout, commit, import, tag: Specify the commit date.
15 log, revert, update: Select revision(s) by date.
15 log, revert, update: Select revision(s) by date.
16
16
17 Many date formats are valid. Here are some examples:
17 Many date formats are valid. Here are some examples:
18
18
19 "Wed Dec 6 13:18:29 2006" (local timezone assumed)
19 "Wed Dec 6 13:18:29 2006" (local timezone assumed)
20 "Dec 6 13:18 -0600" (year assumed, time offset provided)
20 "Dec 6 13:18 -0600" (year assumed, time offset provided)
21 "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
21 "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
22 "Dec 6" (midnight)
22 "Dec 6" (midnight)
23 "13:18" (today assumed)
23 "13:18" (today assumed)
24 "3:39" (3:39AM assumed)
24 "3:39" (3:39AM assumed)
25 "3:39pm" (15:39)
25 "3:39pm" (15:39)
26 "2006-12-06 13:18:29" (ISO 8601 format)
26 "2006-12-06 13:18:29" (ISO 8601 format)
27 "2006-12-6 13:18"
27 "2006-12-6 13:18"
28 "2006-12-6"
28 "2006-12-6"
29 "12-6"
29 "12-6"
30 "12/6"
30 "12/6"
31 "12/6/6" (Dec 6 2006)
31 "12/6/6" (Dec 6 2006)
32
32
33 Lastly, there is Mercurial's internal format:
33 Lastly, there is Mercurial's internal format:
34
34
35 "1165432709 0" (Wed Dec 6 13:18:29 2006 UTC)
35 "1165432709 0" (Wed Dec 6 13:18:29 2006 UTC)
36
36
37 This is the internal representation format for dates. unixtime is
37 This is the internal representation format for dates. unixtime is
38 the number of seconds since the epoch (1970-01-01 00:00 UTC). offset
38 the number of seconds since the epoch (1970-01-01 00:00 UTC). offset
39 is the offset of the local timezone, in seconds west of UTC (negative
39 is the offset of the local timezone, in seconds west of UTC (negative
40 if the timezone is east of UTC).
40 if the timezone is east of UTC).
41
41
42 The log command also accepts date ranges:
42 The log command also accepts date ranges:
43
43
44 "<{date}" - on or before a given date
44 "<{date}" - on or before a given date
45 ">{date}" - on or after a given date
45 ">{date}" - on or after a given date
46 "{date} to {date}" - a date range, inclusive
46 "{date} to {date}" - a date range, inclusive
47 "-{days}" - within a given number of days of today
47 "-{days}" - within a given number of days of today
48 ''')),
48 ''')),
49
49
50 (["patterns"], _("File Name Patterns"),
50 (["patterns"], _("File Name Patterns"),
51 _(r'''
51 _(r'''
52 Mercurial accepts several notations for identifying one or more
52 Mercurial accepts several notations for identifying one or more
53 files at a time.
53 files at a time.
54
54
55 By default, Mercurial treats filenames as shell-style extended
55 By default, Mercurial treats filenames as shell-style extended
56 glob patterns.
56 glob patterns.
57
57
58 Alternate pattern notations must be specified explicitly.
58 Alternate pattern notations must be specified explicitly.
59
59
60 To use a plain path name without any pattern matching, start a
60 To use a plain path name without any pattern matching, start a
61 name with "path:". These path names must match completely, from
61 name with "path:". These path names must match completely, from
62 the root of the current repository.
62 the root of the current repository.
63
63
64 To use an extended glob, start a name with "glob:". Globs are
64 To use an extended glob, start a name with "glob:". Globs are
65 rooted at the current directory; a glob such as "*.c" will match
65 rooted at the current directory; a glob such as "*.c" will match
66 files ending in ".c" in the current directory only.
66 files ending in ".c" in the current directory only.
67
67
68 The supported glob syntax extensions are "**" to match any string
68 The supported glob syntax extensions are "**" to match any string
69 across path separators, and "{a,b}" to mean "a or b".
69 across path separators, and "{a,b}" to mean "a or b".
70
70
71 To use a Perl/Python regular expression, start a name with "re:".
71 To use a Perl/Python regular expression, start a name with "re:".
72 Regexp pattern matching is anchored at the root of the repository.
72 Regexp pattern matching is anchored at the root of the repository.
73
73
74 Plain examples:
74 Plain examples:
75
75
76 path:foo/bar a name bar in a directory named foo in the root of
76 path:foo/bar a name bar in a directory named foo in the root of
77 the repository
77 the repository
78 path:path:name a file or directory named "path:name"
78 path:path:name a file or directory named "path:name"
79
79
80 Glob examples:
80 Glob examples:
81
81
82 glob:*.c any name ending in ".c" in the current directory
82 glob:*.c any name ending in ".c" in the current directory
83 *.c any name ending in ".c" in the current directory
83 *.c any name ending in ".c" in the current directory
84 **.c any name ending in ".c" in the current directory, or
84 **.c any name ending in ".c" in the current directory, or
85 any subdirectory
85 any subdirectory
86 foo/*.c any name ending in ".c" in the directory foo
86 foo/*.c any name ending in ".c" in the directory foo
87 foo/**.c any name ending in ".c" in the directory foo, or any
87 foo/**.c any name ending in ".c" in the directory foo, or any
88 subdirectory
88 subdirectory
89
89
90 Regexp examples:
90 Regexp examples:
91
91
92 re:.*\.c$ any name ending in ".c", anywhere in the repository
92 re:.*\.c$ any name ending in ".c", anywhere in the repository
93
93
94 ''')),
94 ''')),
95
95
96 (['environment', 'env'], _('Environment Variables'),
96 (['environment', 'env'], _('Environment Variables'),
97 _(r'''
97 _(r'''
98 HG::
98 HG::
99 Path to the 'hg' executable, automatically passed when running hooks,
99 Path to the 'hg' executable, automatically passed when running hooks,
100 extensions or external tools. If unset or empty, an executable named
100 extensions or external tools. If unset or empty, an executable named
101 'hg' (with com/exe/bat/cmd extension on Windows) is searched.
101 'hg' (with com/exe/bat/cmd extension on Windows) is searched.
102
102
103 HGEDITOR::
103 HGEDITOR::
104 This is the name of the editor to use when committing. See EDITOR.
104 This is the name of the editor to use when committing. See EDITOR.
105
105
106 (deprecated, use .hgrc)
106 (deprecated, use .hgrc)
107
107
108 HGENCODING::
108 HGENCODING::
109 This overrides the default locale setting detected by Mercurial.
109 This overrides the default locale setting detected by Mercurial.
110 This setting is used to convert data including usernames,
110 This setting is used to convert data including usernames,
111 changeset descriptions, tag names, and branches. This setting can
111 changeset descriptions, tag names, and branches. This setting can
112 be overridden with the --encoding command-line option.
112 be overridden with the --encoding command-line option.
113
113
114 HGENCODINGMODE::
114 HGENCODINGMODE::
115 This sets Mercurial's behavior for handling unknown characters
115 This sets Mercurial's behavior for handling unknown characters
116 while transcoding user inputs. The default is "strict", which
116 while transcoding user inputs. The default is "strict", which
117 causes Mercurial to abort if it can't translate a character. Other
117 causes Mercurial to abort if it can't translate a character. Other
118 settings include "replace", which replaces unknown characters, and
118 settings include "replace", which replaces unknown characters, and
119 "ignore", which drops them. This setting can be overridden with
119 "ignore", which drops them. This setting can be overridden with
120 the --encodingmode command-line option.
120 the --encodingmode command-line option.
121
121
122 HGMERGE::
122 HGMERGE::
123 An executable to use for resolving merge conflicts. The program
123 An executable to use for resolving merge conflicts. The program
124 will be executed with three arguments: local file, remote file,
124 will be executed with three arguments: local file, remote file,
125 ancestor file.
125 ancestor file.
126
126
127 (deprecated, use .hgrc)
127 (deprecated, use .hgrc)
128
128
129 HGRCPATH::
129 HGRCPATH::
130 A list of files or directories to search for hgrc files. Item
130 A list of files or directories to search for hgrc files. Item
131 separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
131 separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
132 platform default search path is used. If empty, only .hg/hgrc of
132 platform default search path is used. If empty, only .hg/hgrc of
133 current repository is read.
133 current repository is read.
134
134
135 For each element in path, if a directory, all entries in directory
135 For each element in path, if a directory, all entries in directory
136 ending with ".rc" are added to path. Else, element itself is
136 ending with ".rc" are added to path. Else, element itself is
137 added to path.
137 added to path.
138
138
139 HGUSER::
139 HGUSER::
140 This is the string used for the author of a commit.
140 This is the string used for the author of a commit.
141
141
142 (deprecated, use .hgrc)
142 (deprecated, use .hgrc)
143
143
144 EMAIL::
144 EMAIL::
145 If HGUSER is not set, this will be used as the author for a commit.
145 If HGUSER is not set, this will be used as the author for a commit.
146
146
147 LOGNAME::
147 LOGNAME::
148 If neither HGUSER nor EMAIL is set, LOGNAME will be used (with
148 If neither HGUSER nor EMAIL is set, LOGNAME will be used (with
149 '@hostname' appended) as the author value for a commit.
149 '@hostname' appended) as the author value for a commit.
150
150
151 VISUAL::
151 VISUAL::
152 This is the name of the editor to use when committing. See EDITOR.
152 This is the name of the editor to use when committing. See EDITOR.
153
153
154 EDITOR::
154 EDITOR::
155 Sometimes Mercurial needs to open a text file in an editor
155 Sometimes Mercurial needs to open a text file in an editor
156 for a user to modify, for example when writing commit messages.
156 for a user to modify, for example when writing commit messages.
157 The editor it uses is determined by looking at the environment
157 The editor it uses is determined by looking at the environment
158 variables HGEDITOR, VISUAL and EDITOR, in that order. The first
158 variables HGEDITOR, VISUAL and EDITOR, in that order. The first
159 non-empty one is chosen. If all of them are empty, the editor
159 non-empty one is chosen. If all of them are empty, the editor
160 defaults to 'vi'.
160 defaults to 'vi'.
161
161
162 PYTHONPATH::
162 PYTHONPATH::
163 This is used by Python to find imported modules and may need to be set
163 This is used by Python to find imported modules and may need to be set
164 appropriately if Mercurial is not installed system-wide.
164 appropriately if Mercurial is not installed system-wide.
165 ''')),
165 ''')),
166
166
167 (['revs', 'revisions'], _('Specifying Single Revisions'),
167 (['revs', 'revisions'], _('Specifying Single Revisions'),
168 _(r'''
168 _(r'''
169 Mercurial accepts several notations for identifying individual
169 Mercurial accepts several notations for identifying individual
170 revisions.
170 revisions.
171
171
172 A plain integer is treated as a revision number. Negative
172 A plain integer is treated as a revision number. Negative
173 integers are treated as offsets from the tip, with -1 denoting the
173 integers are treated as offsets from the tip, with -1 denoting the
174 tip.
174 tip.
175
175
176 A 40-digit hexadecimal string is treated as a unique revision
176 A 40-digit hexadecimal string is treated as a unique revision
177 identifier.
177 identifier.
178
178
179 A hexadecimal string less than 40 characters long is treated as a
179 A hexadecimal string less than 40 characters long is treated as a
180 unique revision identifier, and referred to as a short-form
180 unique revision identifier, and referred to as a short-form
181 identifier. A short-form identifier is only valid if it is the
181 identifier. A short-form identifier is only valid if it is the
182 prefix of one full-length identifier.
182 prefix of one full-length identifier.
183
183
184 Any other string is treated as a tag name, which is a symbolic
184 Any other string is treated as a tag name, which is a symbolic
185 name associated with a revision identifier. Tag names may not
185 name associated with a revision identifier. Tag names may not
186 contain the ":" character.
186 contain the ":" character.
187
187
188 The reserved name "tip" is a special tag that always identifies
188 The reserved name "tip" is a special tag that always identifies
189 the most recent revision.
189 the most recent revision.
190
190
191 The reserved name "null" indicates the null revision. This is the
191 The reserved name "null" indicates the null revision. This is the
192 revision of an empty repository, and the parent of revision 0.
192 revision of an empty repository, and the parent of revision 0.
193
193
194 The reserved name "." indicates the working directory parent. If
194 The reserved name "." indicates the working directory parent. If
195 no working directory is checked out, it is equivalent to null.
195 no working directory is checked out, it is equivalent to null.
196 If an uncommitted merge is in progress, "." is the revision of
196 If an uncommitted merge is in progress, "." is the revision of
197 the first parent.
197 the first parent.
198 ''')),
198 ''')),
199
199
200 (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'),
200 (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'),
201 _(r'''
201 _(r'''
202 When Mercurial accepts more than one revision, they may be
202 When Mercurial accepts more than one revision, they may be
203 specified individually, or provided as a continuous range,
203 specified individually, or provided as a continuous range,
204 separated by the ":" character.
204 separated by the ":" character.
205
205
206 The syntax of range notation is [BEGIN]:[END], where BEGIN and END
206 The syntax of range notation is [BEGIN]:[END], where BEGIN and END
207 are revision identifiers. Both BEGIN and END are optional. If
207 are revision identifiers. Both BEGIN and END are optional. If
208 BEGIN is not specified, it defaults to revision number 0. If END
208 BEGIN is not specified, it defaults to revision number 0. If END
209 is not specified, it defaults to the tip. The range ":" thus
209 is not specified, it defaults to the tip. The range ":" thus
210 means "all revisions".
210 means "all revisions".
211
211
212 If BEGIN is greater than END, revisions are treated in reverse
212 If BEGIN is greater than END, revisions are treated in reverse
213 order.
213 order.
214
214
215 A range acts as a closed interval. This means that a range of 3:5
215 A range acts as a closed interval. This means that a range of 3:5
216 gives 3, 4 and 5. Similarly, a range of 4:2 gives 4, 3, and 2.
216 gives 3, 4 and 5. Similarly, a range of 4:2 gives 4, 3, and 2.
217 ''')),
217 ''')),
218
218
219 (['diffs'], _('Diff Formats'),
219 (['diffs'], _('Diff Formats'),
220 _(r'''
220 _(r'''
221 Mercurial's default format for showing changes between two versions
221 Mercurial's default format for showing changes between two versions
222 of a file is compatible with the unified format of GNU diff, which
222 of a file is compatible with the unified format of GNU diff, which
223 can be used by GNU patch and many other standard tools.
223 can be used by GNU patch and many other standard tools.
224
224
225 While this standard format is often enough, it does not encode the
225 While this standard format is often enough, it does not encode the
226 following information:
226 following information:
227
227
228 - executable status
228 - executable status
229 - copy or rename information
229 - copy or rename information
230 - changes in binary files
230 - changes in binary files
231 - creation or deletion of empty files
231 - creation or deletion of empty files
232
232
233 Mercurial also supports the extended diff format from the git VCS
233 Mercurial also supports the extended diff format from the git VCS
234 which addresses these limitations. The git diff format is not
234 which addresses these limitations. The git diff format is not
235 produced by default because there are very few tools which
235 produced by default because there are very few tools which
236 understand this format.
236 understand this format.
237
237
238 This means that when generating diffs from a Mercurial repository
238 This means that when generating diffs from a Mercurial repository
239 (e.g. with "hg export"), you should be careful about things like
239 (e.g. with "hg export"), you should be careful about things like
240 file copies and renames or other things mentioned above, because
240 file copies and renames or other things mentioned above, because
241 when applying a standard diff to a different repository, this extra
241 when applying a standard diff to a different repository, this extra
242 information is lost. Mercurial's internal operations (like push and
242 information is lost. Mercurial's internal operations (like push and
243 pull) are not affected by this, because they use an internal binary
243 pull) are not affected by this, because they use an internal binary
244 format for communicating changes.
244 format for communicating changes.
245
245
246 To make Mercurial produce the git extended diff format, use the
246 To make Mercurial produce the git extended diff format, use the
247 --git option available for many commands, or set 'git = True' in the
247 --git option available for many commands, or set 'git = True' in the
248 [diff] section of your hgrc. You do not need to set this option when
248 [diff] section of your hgrc. You do not need to set this option when
249 importing diffs in this format or using them in the mq extension.
249 importing diffs in this format or using them in the mq extension.
250 ''')),
250 ''')),
251 (['templating'], _('Usage of templates'),
252 _(r'''
253 Mercurial allows you to customize output of commands through
254 templates. There is command line option for that and additionally
255 styles, which are simply precanned templates that someone wrote.
256
257 You can customize output for any "log-like" command, which currently
258 are: log, outgoing, incoming, tip, parents, heads and glog (if you have
259 graphlog extension enabled).
260
261 There is three styles packaged with Mercurial: default (which is
262 naturally what you see by default), compact and changelog. Usage:
263
264 > hg log -r1 --style changelog
265
266 Template is a piece of text, where parts marked with special syntax
267 are expanded, for example:
268
269 > hg log -r1 --template "{node}\n"
270 b56ce7b07c52de7d5fd79fb89701ea538af65746
271
272 Strings in curly brackets are called keywords and that's their
273 current list:
274
275 - author: String. The unmodified author of the changeset.
276 - branches: String. The name of the branch on which the changeset
277 was committed. Will be empty if the branch name was default.
278 - date: Date information. The date when the changeset was committed.
279 - desc: String. The text of the changeset description.
280 - files: List of strings. All files modified, added, or removed by
281 this changeset.
282 - file_adds: List of strings. Files added by this changeset.
283 - file_dels: List of strings. Files removed by this changeset.
284 - node: String. The changeset identification hash, as a 40-character
285 hexadecimal string.
286 - parents: List of strings. The parents of the changeset.
287 - rev: Integer. The repository-local changeset revision number.
288 - tags: List of strings. Any tags associated with the changeset.
289
290 But "date" keyword does not produce human-readable output, what
291 means that you should use a filter to process it. Filter is a
292 function which modifies the result of expanding a keyword and
293 Mercurial lets you specify a chain of filters:
294
295 > hg tip --template "{date|isodate}\n"
296 2008-08-21 18:22 +0000
297
298 List of filters:
299
300 - addbreaks: Any text. Add an XHTML "<br/>" tag before the end of
301 every line except the last.
302 - age: Date. Render the age of the date.
303 - basename: Any text. Treat the text as a path, and return the
304 basename. For example, "foo/bar/baz" becomes "baz".
305 - date: Date. Render a date in a Unix date command format, but with
306 timezone included: "Mon Sep 04 15:13:13 2006 0700".
307 - domain: Any text. Finds the first string that looks like an email
308 address, and extract just the domain component.
309 - email: Any text. Extract the first string that looks like an email
310 address.
311 - escape: Any text. Replace the special XML/XHTML characters "&",
312 "<" and ">" with XML entities.
313 - fill68: Any text. Wrap the text to fit in 68 columns.
314 - fill76: Any text. Wrap the text to fit in 76 columns.
315 - firstline: Any text. Yield the first line of text.
316 - hgdate: Date. Render the date as a pair of readable numbers:
317 "1157407993 25200".
318 - isodate: Date. Render the date in ISO 8601 format.
319 - obfuscate: Any text. Yield the input text rendered as a sequence
320 of XML entities.
321 - person: Any text. Yield the text before an email address.
322 - rfc822date: date keyword. Render a date using the same format used
323 in email headers.
324 - short: Changeset hash. Yield the short form of a changeset hash,
325 i.e. a 12-byte hexadecimal string.
326 - shortdate: Date. Render date like "2006-09-04".
327 - strip: Any text. Strip all leading and trailing whitespace.
328 - tabindent: Any text. Yield the text, with every line except the
329 first starting with a tab character.
330 - urlescape: Any text. Escape all "special" characters. For example,
331 foo bar becomes foo%20bar.
332 - user: Any text. Return the "user" portion of an email address.
333 ''')),
251 )
334 )
General Comments 0
You need to be logged in to leave comments. Login now