##// 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 1 # help.py - help data for mercurial
2 2 #
3 3 # Copyright 2006 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 8 from i18n import _
9 9
10 10 helptable = (
11 11 (["dates"], _("Date Formats"),
12 12 _(r'''
13 13 Some commands allow the user to specify a date:
14 14 backout, commit, import, tag: Specify the commit date.
15 15 log, revert, update: Select revision(s) by date.
16 16
17 17 Many date formats are valid. Here are some examples:
18 18
19 19 "Wed Dec 6 13:18:29 2006" (local timezone assumed)
20 20 "Dec 6 13:18 -0600" (year assumed, time offset provided)
21 21 "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
22 22 "Dec 6" (midnight)
23 23 "13:18" (today assumed)
24 24 "3:39" (3:39AM assumed)
25 25 "3:39pm" (15:39)
26 26 "2006-12-06 13:18:29" (ISO 8601 format)
27 27 "2006-12-6 13:18"
28 28 "2006-12-6"
29 29 "12-6"
30 30 "12/6"
31 31 "12/6/6" (Dec 6 2006)
32 32
33 33 Lastly, there is Mercurial's internal format:
34 34
35 35 "1165432709 0" (Wed Dec 6 13:18:29 2006 UTC)
36 36
37 37 This is the internal representation format for dates. unixtime is
38 38 the number of seconds since the epoch (1970-01-01 00:00 UTC). offset
39 39 is the offset of the local timezone, in seconds west of UTC (negative
40 40 if the timezone is east of UTC).
41 41
42 42 The log command also accepts date ranges:
43 43
44 44 "<{date}" - on or before a given date
45 45 ">{date}" - on or after a given date
46 46 "{date} to {date}" - a date range, inclusive
47 47 "-{days}" - within a given number of days of today
48 48 ''')),
49 49
50 50 (["patterns"], _("File Name Patterns"),
51 51 _(r'''
52 52 Mercurial accepts several notations for identifying one or more
53 53 files at a time.
54 54
55 55 By default, Mercurial treats filenames as shell-style extended
56 56 glob patterns.
57 57
58 58 Alternate pattern notations must be specified explicitly.
59 59
60 60 To use a plain path name without any pattern matching, start a
61 61 name with "path:". These path names must match completely, from
62 62 the root of the current repository.
63 63
64 64 To use an extended glob, start a name with "glob:". Globs are
65 65 rooted at the current directory; a glob such as "*.c" will match
66 66 files ending in ".c" in the current directory only.
67 67
68 68 The supported glob syntax extensions are "**" to match any string
69 69 across path separators, and "{a,b}" to mean "a or b".
70 70
71 71 To use a Perl/Python regular expression, start a name with "re:".
72 72 Regexp pattern matching is anchored at the root of the repository.
73 73
74 74 Plain examples:
75 75
76 76 path:foo/bar a name bar in a directory named foo in the root of
77 77 the repository
78 78 path:path:name a file or directory named "path:name"
79 79
80 80 Glob examples:
81 81
82 82 glob:*.c any name ending in ".c" in the current directory
83 83 *.c any name ending in ".c" in the current directory
84 84 **.c any name ending in ".c" in the current directory, or
85 85 any subdirectory
86 86 foo/*.c any name ending in ".c" in the directory foo
87 87 foo/**.c any name ending in ".c" in the directory foo, or any
88 88 subdirectory
89 89
90 90 Regexp examples:
91 91
92 92 re:.*\.c$ any name ending in ".c", anywhere in the repository
93 93
94 94 ''')),
95 95
96 96 (['environment', 'env'], _('Environment Variables'),
97 97 _(r'''
98 98 HG::
99 99 Path to the 'hg' executable, automatically passed when running hooks,
100 100 extensions or external tools. If unset or empty, an executable named
101 101 'hg' (with com/exe/bat/cmd extension on Windows) is searched.
102 102
103 103 HGEDITOR::
104 104 This is the name of the editor to use when committing. See EDITOR.
105 105
106 106 (deprecated, use .hgrc)
107 107
108 108 HGENCODING::
109 109 This overrides the default locale setting detected by Mercurial.
110 110 This setting is used to convert data including usernames,
111 111 changeset descriptions, tag names, and branches. This setting can
112 112 be overridden with the --encoding command-line option.
113 113
114 114 HGENCODINGMODE::
115 115 This sets Mercurial's behavior for handling unknown characters
116 116 while transcoding user inputs. The default is "strict", which
117 117 causes Mercurial to abort if it can't translate a character. Other
118 118 settings include "replace", which replaces unknown characters, and
119 119 "ignore", which drops them. This setting can be overridden with
120 120 the --encodingmode command-line option.
121 121
122 122 HGMERGE::
123 123 An executable to use for resolving merge conflicts. The program
124 124 will be executed with three arguments: local file, remote file,
125 125 ancestor file.
126 126
127 127 (deprecated, use .hgrc)
128 128
129 129 HGRCPATH::
130 130 A list of files or directories to search for hgrc files. Item
131 131 separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
132 132 platform default search path is used. If empty, only .hg/hgrc of
133 133 current repository is read.
134 134
135 135 For each element in path, if a directory, all entries in directory
136 136 ending with ".rc" are added to path. Else, element itself is
137 137 added to path.
138 138
139 139 HGUSER::
140 140 This is the string used for the author of a commit.
141 141
142 142 (deprecated, use .hgrc)
143 143
144 144 EMAIL::
145 145 If HGUSER is not set, this will be used as the author for a commit.
146 146
147 147 LOGNAME::
148 148 If neither HGUSER nor EMAIL is set, LOGNAME will be used (with
149 149 '@hostname' appended) as the author value for a commit.
150 150
151 151 VISUAL::
152 152 This is the name of the editor to use when committing. See EDITOR.
153 153
154 154 EDITOR::
155 155 Sometimes Mercurial needs to open a text file in an editor
156 156 for a user to modify, for example when writing commit messages.
157 157 The editor it uses is determined by looking at the environment
158 158 variables HGEDITOR, VISUAL and EDITOR, in that order. The first
159 159 non-empty one is chosen. If all of them are empty, the editor
160 160 defaults to 'vi'.
161 161
162 162 PYTHONPATH::
163 163 This is used by Python to find imported modules and may need to be set
164 164 appropriately if Mercurial is not installed system-wide.
165 165 ''')),
166 166
167 167 (['revs', 'revisions'], _('Specifying Single Revisions'),
168 168 _(r'''
169 169 Mercurial accepts several notations for identifying individual
170 170 revisions.
171 171
172 172 A plain integer is treated as a revision number. Negative
173 173 integers are treated as offsets from the tip, with -1 denoting the
174 174 tip.
175 175
176 176 A 40-digit hexadecimal string is treated as a unique revision
177 177 identifier.
178 178
179 179 A hexadecimal string less than 40 characters long is treated as a
180 180 unique revision identifier, and referred to as a short-form
181 181 identifier. A short-form identifier is only valid if it is the
182 182 prefix of one full-length identifier.
183 183
184 184 Any other string is treated as a tag name, which is a symbolic
185 185 name associated with a revision identifier. Tag names may not
186 186 contain the ":" character.
187 187
188 188 The reserved name "tip" is a special tag that always identifies
189 189 the most recent revision.
190 190
191 191 The reserved name "null" indicates the null revision. This is the
192 192 revision of an empty repository, and the parent of revision 0.
193 193
194 194 The reserved name "." indicates the working directory parent. If
195 195 no working directory is checked out, it is equivalent to null.
196 196 If an uncommitted merge is in progress, "." is the revision of
197 197 the first parent.
198 198 ''')),
199 199
200 200 (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'),
201 201 _(r'''
202 202 When Mercurial accepts more than one revision, they may be
203 203 specified individually, or provided as a continuous range,
204 204 separated by the ":" character.
205 205
206 206 The syntax of range notation is [BEGIN]:[END], where BEGIN and END
207 207 are revision identifiers. Both BEGIN and END are optional. If
208 208 BEGIN is not specified, it defaults to revision number 0. If END
209 209 is not specified, it defaults to the tip. The range ":" thus
210 210 means "all revisions".
211 211
212 212 If BEGIN is greater than END, revisions are treated in reverse
213 213 order.
214 214
215 215 A range acts as a closed interval. This means that a range of 3:5
216 216 gives 3, 4 and 5. Similarly, a range of 4:2 gives 4, 3, and 2.
217 217 ''')),
218 218
219 219 (['diffs'], _('Diff Formats'),
220 220 _(r'''
221 221 Mercurial's default format for showing changes between two versions
222 222 of a file is compatible with the unified format of GNU diff, which
223 223 can be used by GNU patch and many other standard tools.
224 224
225 225 While this standard format is often enough, it does not encode the
226 226 following information:
227 227
228 228 - executable status
229 229 - copy or rename information
230 230 - changes in binary files
231 231 - creation or deletion of empty files
232 232
233 233 Mercurial also supports the extended diff format from the git VCS
234 234 which addresses these limitations. The git diff format is not
235 235 produced by default because there are very few tools which
236 236 understand this format.
237 237
238 238 This means that when generating diffs from a Mercurial repository
239 239 (e.g. with "hg export"), you should be careful about things like
240 240 file copies and renames or other things mentioned above, because
241 241 when applying a standard diff to a different repository, this extra
242 242 information is lost. Mercurial's internal operations (like push and
243 243 pull) are not affected by this, because they use an internal binary
244 244 format for communicating changes.
245 245
246 246 To make Mercurial produce the git extended diff format, use the
247 247 --git option available for many commands, or set 'git = True' in the
248 248 [diff] section of your hgrc. You do not need to set this option when
249 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