##// END OF EJS Templates
help: wrap extension descriptions
Martin Geisler -
r8889:9be82411 default
parent child Browse files
Show More
@@ -1,508 +1,513
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 of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2, incorporated herein by reference.
6 # GNU General Public License version 2, incorporated herein by reference.
7
7
8 import textwrap
8 from i18n import _
9 from i18n import _
9 import extensions
10 import extensions
10
11
11
12
12 def moduledoc(file):
13 def moduledoc(file):
13 '''return the top-level python documentation for the given file
14 '''return the top-level python documentation for the given file
14
15
15 Loosely inspired by pydoc.source_synopsis(), but rewritten to handle \'''
16 Loosely inspired by pydoc.source_synopsis(), but rewritten to handle \'''
16 as well as """ and to return the whole text instead of just the synopsis'''
17 as well as """ and to return the whole text instead of just the synopsis'''
17 result = []
18 result = []
18
19
19 line = file.readline()
20 line = file.readline()
20 while line[:1] == '#' or not line.strip():
21 while line[:1] == '#' or not line.strip():
21 line = file.readline()
22 line = file.readline()
22 if not line: break
23 if not line: break
23
24
24 start = line[:3]
25 start = line[:3]
25 if start == '"""' or start == "'''":
26 if start == '"""' or start == "'''":
26 line = line[3:]
27 line = line[3:]
27 while line:
28 while line:
28 if line.rstrip().endswith(start):
29 if line.rstrip().endswith(start):
29 line = line.split(start)[0]
30 line = line.split(start)[0]
30 if line:
31 if line:
31 result.append(line)
32 result.append(line)
32 break
33 break
33 elif not line:
34 elif not line:
34 return None # unmatched delimiter
35 return None # unmatched delimiter
35 result.append(line)
36 result.append(line)
36 line = file.readline()
37 line = file.readline()
37 else:
38 else:
38 return None
39 return None
39
40
40 return ''.join(result)
41 return ''.join(result)
41
42
42 def listexts(header, exts, maxlength):
43 def listexts(header, exts, maxlength):
43 '''return a text listing of the given extensions'''
44 '''return a text listing of the given extensions'''
44 if not exts:
45 if not exts:
45 return ''
46 return ''
46 result = '\n%s\n\n' % header
47 result = '\n%s\n\n' % header
47 for name, desc in sorted(exts.iteritems()):
48 for name, desc in sorted(exts.iteritems()):
48 result += ' %s %s\n' % (name.ljust(maxlength), desc)
49 # wrap desc at 70 characters, just like the main help texts
50 desc = textwrap.wrap(desc, width=70 - maxlength - 4)
51 pad = '\n' + ' ' * (maxlength + 4)
52 result += ' %s %s\n' % (name.ljust(maxlength),
53 pad.join(desc))
49 return result
54 return result
50
55
51 def extshelp():
56 def extshelp():
52 doc = _(r'''
57 doc = _(r'''
53 Mercurial has the ability to add new features through the use of
58 Mercurial has the ability to add new features through the use of
54 extensions. Extensions may add new commands, add options to
59 extensions. Extensions may add new commands, add options to
55 existing commands, change the default behavior of commands, or
60 existing commands, change the default behavior of commands, or
56 implement hooks.
61 implement hooks.
57
62
58 Extensions are not loaded by default for a variety of reasons:
63 Extensions are not loaded by default for a variety of reasons:
59 they can increase startup overhead; they may be meant for
64 they can increase startup overhead; they may be meant for
60 advanced usage only; they may provide potentially dangerous
65 advanced usage only; they may provide potentially dangerous
61 abilities (such as letting you destroy or modify history); they
66 abilities (such as letting you destroy or modify history); they
62 might not be ready for prime time; or they may alter some
67 might not be ready for prime time; or they may alter some
63 usual behaviors of stock Mercurial. It is thus up to the user to
68 usual behaviors of stock Mercurial. It is thus up to the user to
64 activate extensions as needed.
69 activate extensions as needed.
65
70
66 To enable the "foo" extension, either shipped with Mercurial
71 To enable the "foo" extension, either shipped with Mercurial
67 or in the Python search path, create an entry for it in your
72 or in the Python search path, create an entry for it in your
68 hgrc, like this:
73 hgrc, like this:
69
74
70 [extensions]
75 [extensions]
71 foo =
76 foo =
72
77
73 You may also specify the full path to an extension:
78 You may also specify the full path to an extension:
74
79
75 [extensions]
80 [extensions]
76 myfeature = ~/.hgext/myfeature.py
81 myfeature = ~/.hgext/myfeature.py
77
82
78 To explicitly disable an extension enabled in an hgrc of broader
83 To explicitly disable an extension enabled in an hgrc of broader
79 scope, prepend its path with !:
84 scope, prepend its path with !:
80
85
81 [extensions]
86 [extensions]
82 # disabling extension bar residing in /ext/path
87 # disabling extension bar residing in /ext/path
83 hgext.bar = !/path/to/extension/bar.py
88 hgext.bar = !/path/to/extension/bar.py
84 # ditto, but no path was supplied for extension baz
89 # ditto, but no path was supplied for extension baz
85 hgext.baz = !
90 hgext.baz = !
86 ''')
91 ''')
87
92
88 exts, maxlength = extensions.enabled()
93 exts, maxlength = extensions.enabled()
89 doc += listexts(_('enabled extensions:'), exts, maxlength)
94 doc += listexts(_('enabled extensions:'), exts, maxlength)
90
95
91 exts, maxlength = extensions.disabled()
96 exts, maxlength = extensions.disabled()
92 doc += listexts(_('disabled extensions:'), exts, maxlength)
97 doc += listexts(_('disabled extensions:'), exts, maxlength)
93
98
94 return doc
99 return doc
95
100
96 helptable = (
101 helptable = (
97 (["dates"], _("Date Formats"),
102 (["dates"], _("Date Formats"),
98 _(r'''
103 _(r'''
99 Some commands allow the user to specify a date, e.g.:
104 Some commands allow the user to specify a date, e.g.:
100 * backout, commit, import, tag: Specify the commit date.
105 * backout, commit, import, tag: Specify the commit date.
101 * log, revert, update: Select revision(s) by date.
106 * log, revert, update: Select revision(s) by date.
102
107
103 Many date formats are valid. Here are some examples:
108 Many date formats are valid. Here are some examples:
104
109
105 "Wed Dec 6 13:18:29 2006" (local timezone assumed)
110 "Wed Dec 6 13:18:29 2006" (local timezone assumed)
106 "Dec 6 13:18 -0600" (year assumed, time offset provided)
111 "Dec 6 13:18 -0600" (year assumed, time offset provided)
107 "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
112 "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
108 "Dec 6" (midnight)
113 "Dec 6" (midnight)
109 "13:18" (today assumed)
114 "13:18" (today assumed)
110 "3:39" (3:39AM assumed)
115 "3:39" (3:39AM assumed)
111 "3:39pm" (15:39)
116 "3:39pm" (15:39)
112 "2006-12-06 13:18:29" (ISO 8601 format)
117 "2006-12-06 13:18:29" (ISO 8601 format)
113 "2006-12-6 13:18"
118 "2006-12-6 13:18"
114 "2006-12-6"
119 "2006-12-6"
115 "12-6"
120 "12-6"
116 "12/6"
121 "12/6"
117 "12/6/6" (Dec 6 2006)
122 "12/6/6" (Dec 6 2006)
118
123
119 Lastly, there is Mercurial's internal format:
124 Lastly, there is Mercurial's internal format:
120
125
121 "1165432709 0" (Wed Dec 6 13:18:29 2006 UTC)
126 "1165432709 0" (Wed Dec 6 13:18:29 2006 UTC)
122
127
123 This is the internal representation format for dates. unixtime is
128 This is the internal representation format for dates. unixtime is
124 the number of seconds since the epoch (1970-01-01 00:00 UTC).
129 the number of seconds since the epoch (1970-01-01 00:00 UTC).
125 offset is the offset of the local timezone, in seconds west of UTC
130 offset is the offset of the local timezone, in seconds west of UTC
126 (negative if the timezone is east of UTC).
131 (negative if the timezone is east of UTC).
127
132
128 The log command also accepts date ranges:
133 The log command also accepts date ranges:
129
134
130 "<{datetime}" - at or before a given date/time
135 "<{datetime}" - at or before a given date/time
131 ">{datetime}" - on or after a given date/time
136 ">{datetime}" - on or after a given date/time
132 "{datetime} to {datetime}" - a date range, inclusive
137 "{datetime} to {datetime}" - a date range, inclusive
133 "-{days}" - within a given number of days of today
138 "-{days}" - within a given number of days of today
134 ''')),
139 ''')),
135
140
136 (["patterns"], _("File Name Patterns"),
141 (["patterns"], _("File Name Patterns"),
137 _(r'''
142 _(r'''
138 Mercurial accepts several notations for identifying one or more
143 Mercurial accepts several notations for identifying one or more
139 files at a time.
144 files at a time.
140
145
141 By default, Mercurial treats filenames as shell-style extended
146 By default, Mercurial treats filenames as shell-style extended
142 glob patterns.
147 glob patterns.
143
148
144 Alternate pattern notations must be specified explicitly.
149 Alternate pattern notations must be specified explicitly.
145
150
146 To use a plain path name without any pattern matching, start it
151 To use a plain path name without any pattern matching, start it
147 with "path:". These path names must completely match starting at
152 with "path:". These path names must completely match starting at
148 the current repository root.
153 the current repository root.
149
154
150 To use an extended glob, start a name with "glob:". Globs are
155 To use an extended glob, start a name with "glob:". Globs are
151 rooted at the current directory; a glob such as "*.c" will only
156 rooted at the current directory; a glob such as "*.c" will only
152 match files in the current directory ending with ".c".
157 match files in the current directory ending with ".c".
153
158
154 The supported glob syntax extensions are "**" to match any string
159 The supported glob syntax extensions are "**" to match any string
155 across path separators and "{a,b}" to mean "a or b".
160 across path separators and "{a,b}" to mean "a or b".
156
161
157 To use a Perl/Python regular expression, start a name with "re:".
162 To use a Perl/Python regular expression, start a name with "re:".
158 Regexp pattern matching is anchored at the root of the repository.
163 Regexp pattern matching is anchored at the root of the repository.
159
164
160 Plain examples:
165 Plain examples:
161
166
162 path:foo/bar a name bar in a directory named foo in the root of
167 path:foo/bar a name bar in a directory named foo in the root of
163 the repository
168 the repository
164 path:path:name a file or directory named "path:name"
169 path:path:name a file or directory named "path:name"
165
170
166 Glob examples:
171 Glob examples:
167
172
168 glob:*.c any name ending in ".c" in the current directory
173 glob:*.c any name ending in ".c" in the current directory
169 *.c any name ending in ".c" in the current directory
174 *.c any name ending in ".c" in the current directory
170 **.c any name ending in ".c" in any subdirectory of the
175 **.c any name ending in ".c" in any subdirectory of the
171 current directory including itself.
176 current directory including itself.
172 foo/*.c any name ending in ".c" in the directory foo
177 foo/*.c any name ending in ".c" in the directory foo
173 foo/**.c any name ending in ".c" in any subdirectory of foo
178 foo/**.c any name ending in ".c" in any subdirectory of foo
174 including itself.
179 including itself.
175
180
176 Regexp examples:
181 Regexp examples:
177
182
178 re:.*\.c$ any name ending in ".c", anywhere in the repository
183 re:.*\.c$ any name ending in ".c", anywhere in the repository
179
184
180 ''')),
185 ''')),
181
186
182 (['environment', 'env'], _('Environment Variables'),
187 (['environment', 'env'], _('Environment Variables'),
183 _(r'''
188 _(r'''
184 HG::
189 HG::
185 Path to the 'hg' executable, automatically passed when running
190 Path to the 'hg' executable, automatically passed when running
186 hooks, extensions or external tools. If unset or empty, this is
191 hooks, extensions or external tools. If unset or empty, this is
187 the hg executable's name if it's frozen, or an executable named
192 the hg executable's name if it's frozen, or an executable named
188 'hg' (with %PATHEXT% [defaulting to COM/EXE/BAT/CMD] extensions on
193 'hg' (with %PATHEXT% [defaulting to COM/EXE/BAT/CMD] extensions on
189 Windows) is searched.
194 Windows) is searched.
190
195
191 HGEDITOR::
196 HGEDITOR::
192 This is the name of the editor to run when committing. See EDITOR.
197 This is the name of the editor to run when committing. See EDITOR.
193
198
194 (deprecated, use .hgrc)
199 (deprecated, use .hgrc)
195
200
196 HGENCODING::
201 HGENCODING::
197 This overrides the default locale setting detected by Mercurial.
202 This overrides the default locale setting detected by Mercurial.
198 This setting is used to convert data including usernames,
203 This setting is used to convert data including usernames,
199 changeset descriptions, tag names, and branches. This setting can
204 changeset descriptions, tag names, and branches. This setting can
200 be overridden with the --encoding command-line option.
205 be overridden with the --encoding command-line option.
201
206
202 HGENCODINGMODE::
207 HGENCODINGMODE::
203 This sets Mercurial's behavior for handling unknown characters
208 This sets Mercurial's behavior for handling unknown characters
204 while transcoding user input. The default is "strict", which
209 while transcoding user input. The default is "strict", which
205 causes Mercurial to abort if it can't map a character. Other
210 causes Mercurial to abort if it can't map a character. Other
206 settings include "replace", which replaces unknown characters, and
211 settings include "replace", which replaces unknown characters, and
207 "ignore", which drops them. This setting can be overridden with
212 "ignore", which drops them. This setting can be overridden with
208 the --encodingmode command-line option.
213 the --encodingmode command-line option.
209
214
210 HGMERGE::
215 HGMERGE::
211 An executable to use for resolving merge conflicts. The program
216 An executable to use for resolving merge conflicts. The program
212 will be executed with three arguments: local file, remote file,
217 will be executed with three arguments: local file, remote file,
213 ancestor file.
218 ancestor file.
214
219
215 (deprecated, use .hgrc)
220 (deprecated, use .hgrc)
216
221
217 HGRCPATH::
222 HGRCPATH::
218 A list of files or directories to search for hgrc files. Item
223 A list of files or directories to search for hgrc files. Item
219 separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
224 separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
220 platform default search path is used. If empty, only the .hg/hgrc
225 platform default search path is used. If empty, only the .hg/hgrc
221 from the current repository is read.
226 from the current repository is read.
222
227
223 For each element in HGRCPATH:
228 For each element in HGRCPATH:
224 * if it's a directory, all files ending with .rc are added
229 * if it's a directory, all files ending with .rc are added
225 * otherwise, the file itself will be added
230 * otherwise, the file itself will be added
226
231
227 HGUSER::
232 HGUSER::
228 This is the string used as the author of a commit. If not set,
233 This is the string used as the author of a commit. If not set,
229 available values will be considered in this order:
234 available values will be considered in this order:
230
235
231 * HGUSER (deprecated)
236 * HGUSER (deprecated)
232 * hgrc files from the HGRCPATH
237 * hgrc files from the HGRCPATH
233 * EMAIL
238 * EMAIL
234 * interactive prompt
239 * interactive prompt
235 * LOGNAME (with '@hostname' appended)
240 * LOGNAME (with '@hostname' appended)
236
241
237 (deprecated, use .hgrc)
242 (deprecated, use .hgrc)
238
243
239 EMAIL::
244 EMAIL::
240 May be used as the author of a commit; see HGUSER.
245 May be used as the author of a commit; see HGUSER.
241
246
242 LOGNAME::
247 LOGNAME::
243 May be used as the author of a commit; see HGUSER.
248 May be used as the author of a commit; see HGUSER.
244
249
245 VISUAL::
250 VISUAL::
246 This is the name of the editor to use when committing. See EDITOR.
251 This is the name of the editor to use when committing. See EDITOR.
247
252
248 EDITOR::
253 EDITOR::
249 Sometimes Mercurial needs to open a text file in an editor for a
254 Sometimes Mercurial needs to open a text file in an editor for a
250 user to modify, for example when writing commit messages. The
255 user to modify, for example when writing commit messages. The
251 editor it uses is determined by looking at the environment
256 editor it uses is determined by looking at the environment
252 variables HGEDITOR, VISUAL and EDITOR, in that order. The first
257 variables HGEDITOR, VISUAL and EDITOR, in that order. The first
253 non-empty one is chosen. If all of them are empty, the editor
258 non-empty one is chosen. If all of them are empty, the editor
254 defaults to 'vi'.
259 defaults to 'vi'.
255
260
256 PYTHONPATH::
261 PYTHONPATH::
257 This is used by Python to find imported modules and may need to be
262 This is used by Python to find imported modules and may need to be
258 set appropriately if this Mercurial is not installed system-wide.
263 set appropriately if this Mercurial is not installed system-wide.
259 ''')),
264 ''')),
260
265
261 (['revs', 'revisions'], _('Specifying Single Revisions'),
266 (['revs', 'revisions'], _('Specifying Single Revisions'),
262 _(r'''
267 _(r'''
263 Mercurial supports several ways to specify individual revisions.
268 Mercurial supports several ways to specify individual revisions.
264
269
265 A plain integer is treated as a revision number. Negative integers
270 A plain integer is treated as a revision number. Negative integers
266 are treated as topological offsets from the tip, with -1 denoting
271 are treated as topological offsets from the tip, with -1 denoting
267 the tip. As such, negative numbers are only useful if you've
272 the tip. As such, negative numbers are only useful if you've
268 memorized your local tree numbers and want to save typing a single
273 memorized your local tree numbers and want to save typing a single
269 digit. This editor suggests copy and paste.
274 digit. This editor suggests copy and paste.
270
275
271 A 40-digit hexadecimal string is treated as a unique revision
276 A 40-digit hexadecimal string is treated as a unique revision
272 identifier.
277 identifier.
273
278
274 A hexadecimal string less than 40 characters long is treated as a
279 A hexadecimal string less than 40 characters long is treated as a
275 unique revision identifier, and referred to as a short-form
280 unique revision identifier, and referred to as a short-form
276 identifier. A short-form identifier is only valid if it is the
281 identifier. A short-form identifier is only valid if it is the
277 prefix of exactly one full-length identifier.
282 prefix of exactly one full-length identifier.
278
283
279 Any other string is treated as a tag name, which is a symbolic
284 Any other string is treated as a tag name, which is a symbolic
280 name associated with a revision identifier. Tag names may not
285 name associated with a revision identifier. Tag names may not
281 contain the ":" character.
286 contain the ":" character.
282
287
283 The reserved name "tip" is a special tag that always identifies
288 The reserved name "tip" is a special tag that always identifies
284 the most recent revision.
289 the most recent revision.
285
290
286 The reserved name "null" indicates the null revision. This is the
291 The reserved name "null" indicates the null revision. This is the
287 revision of an empty repository, and the parent of revision 0.
292 revision of an empty repository, and the parent of revision 0.
288
293
289 The reserved name "." indicates the working directory parent. If
294 The reserved name "." indicates the working directory parent. If
290 no working directory is checked out, it is equivalent to null. If
295 no working directory is checked out, it is equivalent to null. If
291 an uncommitted merge is in progress, "." is the revision of the
296 an uncommitted merge is in progress, "." is the revision of the
292 first parent.
297 first parent.
293 ''')),
298 ''')),
294
299
295 (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'),
300 (['mrevs', 'multirevs'], _('Specifying Multiple Revisions'),
296 _(r'''
301 _(r'''
297 When Mercurial accepts more than one revision, they may be
302 When Mercurial accepts more than one revision, they may be
298 specified individually, or provided as a topologically continuous
303 specified individually, or provided as a topologically continuous
299 range, separated by the ":" character.
304 range, separated by the ":" character.
300
305
301 The syntax of range notation is [BEGIN]:[END], where BEGIN and END
306 The syntax of range notation is [BEGIN]:[END], where BEGIN and END
302 are revision identifiers. Both BEGIN and END are optional. If
307 are revision identifiers. Both BEGIN and END are optional. If
303 BEGIN is not specified, it defaults to revision number 0. If END
308 BEGIN is not specified, it defaults to revision number 0. If END
304 is not specified, it defaults to the tip. The range ":" thus means
309 is not specified, it defaults to the tip. The range ":" thus means
305 "all revisions".
310 "all revisions".
306
311
307 If BEGIN is greater than END, revisions are treated in reverse
312 If BEGIN is greater than END, revisions are treated in reverse
308 order.
313 order.
309
314
310 A range acts as a closed interval. This means that a range of 3:5
315 A range acts as a closed interval. This means that a range of 3:5
311 gives 3, 4 and 5. Similarly, a range of 9:6 gives 9, 8, 7, and 6.
316 gives 3, 4 and 5. Similarly, a range of 9:6 gives 9, 8, 7, and 6.
312 ''')),
317 ''')),
313
318
314 (['diffs'], _('Diff Formats'),
319 (['diffs'], _('Diff Formats'),
315 _(r'''
320 _(r'''
316 Mercurial's default format for showing changes between two
321 Mercurial's default format for showing changes between two
317 versions of a file is compatible with the unified format of GNU
322 versions of a file is compatible with the unified format of GNU
318 diff, which can be used by GNU patch and many other standard
323 diff, which can be used by GNU patch and many other standard
319 tools.
324 tools.
320
325
321 While this standard format is often enough, it does not encode the
326 While this standard format is often enough, it does not encode the
322 following information:
327 following information:
323
328
324 - executable status and other permission bits
329 - executable status and other permission bits
325 - copy or rename information
330 - copy or rename information
326 - changes in binary files
331 - changes in binary files
327 - creation or deletion of empty files
332 - creation or deletion of empty files
328
333
329 Mercurial also supports the extended diff format from the git VCS
334 Mercurial also supports the extended diff format from the git VCS
330 which addresses these limitations. The git diff format is not
335 which addresses these limitations. The git diff format is not
331 produced by default because a few widespread tools still do not
336 produced by default because a few widespread tools still do not
332 understand this format.
337 understand this format.
333
338
334 This means that when generating diffs from a Mercurial repository
339 This means that when generating diffs from a Mercurial repository
335 (e.g. with "hg export"), you should be careful about things like
340 (e.g. with "hg export"), you should be careful about things like
336 file copies and renames or other things mentioned above, because
341 file copies and renames or other things mentioned above, because
337 when applying a standard diff to a different repository, this
342 when applying a standard diff to a different repository, this
338 extra information is lost. Mercurial's internal operations (like
343 extra information is lost. Mercurial's internal operations (like
339 push and pull) are not affected by this, because they use an
344 push and pull) are not affected by this, because they use an
340 internal binary format for communicating changes.
345 internal binary format for communicating changes.
341
346
342 To make Mercurial produce the git extended diff format, use the
347 To make Mercurial produce the git extended diff format, use the
343 --git option available for many commands, or set 'git = True' in
348 --git option available for many commands, or set 'git = True' in
344 the [diff] section of your hgrc. You do not need to set this
349 the [diff] section of your hgrc. You do not need to set this
345 option when importing diffs in this format or using them in the mq
350 option when importing diffs in this format or using them in the mq
346 extension.
351 extension.
347 ''')),
352 ''')),
348 (['templating'], _('Template Usage'),
353 (['templating'], _('Template Usage'),
349 _(r'''
354 _(r'''
350 Mercurial allows you to customize output of commands through
355 Mercurial allows you to customize output of commands through
351 templates. You can either pass in a template from the command
356 templates. You can either pass in a template from the command
352 line, via the --template option, or select an existing
357 line, via the --template option, or select an existing
353 template-style (--style).
358 template-style (--style).
354
359
355 You can customize output for any "log-like" command: log,
360 You can customize output for any "log-like" command: log,
356 outgoing, incoming, tip, parents, heads and glog.
361 outgoing, incoming, tip, parents, heads and glog.
357
362
358 Three styles are packaged with Mercurial: default (the style used
363 Three styles are packaged with Mercurial: default (the style used
359 when no explicit preference is passed), compact and changelog.
364 when no explicit preference is passed), compact and changelog.
360 Usage:
365 Usage:
361
366
362 $ hg log -r1 --style changelog
367 $ hg log -r1 --style changelog
363
368
364 A template is a piece of text, with markup to invoke variable
369 A template is a piece of text, with markup to invoke variable
365 expansion:
370 expansion:
366
371
367 $ hg log -r1 --template "{node}\n"
372 $ hg log -r1 --template "{node}\n"
368 b56ce7b07c52de7d5fd79fb89701ea538af65746
373 b56ce7b07c52de7d5fd79fb89701ea538af65746
369
374
370 Strings in curly braces are called keywords. The availability of
375 Strings in curly braces are called keywords. The availability of
371 keywords depends on the exact context of the templater. These
376 keywords depends on the exact context of the templater. These
372 keywords are usually available for templating a log-like command:
377 keywords are usually available for templating a log-like command:
373
378
374 - author: String. The unmodified author of the changeset.
379 - author: String. The unmodified author of the changeset.
375 - branches: String. The name of the branch on which the changeset
380 - branches: String. The name of the branch on which the changeset
376 was committed. Will be empty if the branch name was default.
381 was committed. Will be empty if the branch name was default.
377 - date: Date information. The date when the changeset was committed.
382 - date: Date information. The date when the changeset was committed.
378 - desc: String. The text of the changeset description.
383 - desc: String. The text of the changeset description.
379 - diffstat: String. Statistics of changes with the following
384 - diffstat: String. Statistics of changes with the following
380 format: "modified files: +added/-removed lines"
385 format: "modified files: +added/-removed lines"
381 - files: List of strings. All files modified, added, or removed by
386 - files: List of strings. All files modified, added, or removed by
382 this changeset.
387 this changeset.
383 - file_adds: List of strings. Files added by this changeset.
388 - file_adds: List of strings. Files added by this changeset.
384 - file_mods: List of strings. Files modified by this changeset.
389 - file_mods: List of strings. Files modified by this changeset.
385 - file_dels: List of strings. Files removed by this changeset.
390 - file_dels: List of strings. Files removed by this changeset.
386 - node: String. The changeset identification hash, as a
391 - node: String. The changeset identification hash, as a
387 40-character hexadecimal string.
392 40-character hexadecimal string.
388 - parents: List of strings. The parents of the changeset.
393 - parents: List of strings. The parents of the changeset.
389 - rev: Integer. The repository-local changeset revision number.
394 - rev: Integer. The repository-local changeset revision number.
390 - tags: List of strings. Any tags associated with the changeset.
395 - tags: List of strings. Any tags associated with the changeset.
391
396
392 The "date" keyword does not produce human-readable output. If you
397 The "date" keyword does not produce human-readable output. If you
393 want to use a date in your output, you can use a filter to process
398 want to use a date in your output, you can use a filter to process
394 it. Filters are functions which return a string based on the input
399 it. Filters are functions which return a string based on the input
395 variable. You can also use a chain of filters to get the desired
400 variable. You can also use a chain of filters to get the desired
396 output:
401 output:
397
402
398 $ hg tip --template "{date|isodate}\n"
403 $ hg tip --template "{date|isodate}\n"
399 2008-08-21 18:22 +0000
404 2008-08-21 18:22 +0000
400
405
401 List of filters:
406 List of filters:
402
407
403 - addbreaks: Any text. Add an XHTML "<br />" tag before the end of
408 - addbreaks: Any text. Add an XHTML "<br />" tag before the end of
404 every line except the last.
409 every line except the last.
405 - age: Date. Returns a human-readable date/time difference between
410 - age: Date. Returns a human-readable date/time difference between
406 the given date/time and the current date/time.
411 the given date/time and the current date/time.
407 - basename: Any text. Treats the text as a path, and returns the
412 - basename: Any text. Treats the text as a path, and returns the
408 last component of the path after splitting by the path
413 last component of the path after splitting by the path
409 separator (ignoring trailing separators). For example,
414 separator (ignoring trailing separators). For example,
410 "foo/bar/baz" becomes "baz" and "foo/bar//" becomes "bar".
415 "foo/bar/baz" becomes "baz" and "foo/bar//" becomes "bar".
411 - stripdir: Treat the text as path and strip a directory level, if
416 - stripdir: Treat the text as path and strip a directory level, if
412 possible. For example, "foo" and "foo/bar" becomes "foo".
417 possible. For example, "foo" and "foo/bar" becomes "foo".
413 - date: Date. Returns a date in a Unix date format, including
418 - date: Date. Returns a date in a Unix date format, including
414 the timezone: "Mon Sep 04 15:13:13 2006 0700".
419 the timezone: "Mon Sep 04 15:13:13 2006 0700".
415 - domain: Any text. Finds the first string that looks like an
420 - domain: Any text. Finds the first string that looks like an
416 email address, and extracts just the domain component.
421 email address, and extracts just the domain component.
417 Example: 'User <user@example.com>' becomes 'example.com'.
422 Example: 'User <user@example.com>' becomes 'example.com'.
418 - email: Any text. Extracts the first string that looks like an
423 - email: Any text. Extracts the first string that looks like an
419 email address. Example: 'User <user@example.com>' becomes
424 email address. Example: 'User <user@example.com>' becomes
420 'user@example.com'.
425 'user@example.com'.
421 - escape: Any text. Replaces the special XML/XHTML characters "&",
426 - escape: Any text. Replaces the special XML/XHTML characters "&",
422 "<" and ">" with XML entities.
427 "<" and ">" with XML entities.
423 - fill68: Any text. Wraps the text to fit in 68 columns.
428 - fill68: Any text. Wraps the text to fit in 68 columns.
424 - fill76: Any text. Wraps the text to fit in 76 columns.
429 - fill76: Any text. Wraps the text to fit in 76 columns.
425 - firstline: Any text. Returns the first line of text.
430 - firstline: Any text. Returns the first line of text.
426 - nonempty: Any text. Returns '(none)' if the string is empty.
431 - nonempty: Any text. Returns '(none)' if the string is empty.
427 - hgdate: Date. Returns the date as a pair of numbers:
432 - hgdate: Date. Returns the date as a pair of numbers:
428 "1157407993 25200" (Unix timestamp, timezone offset).
433 "1157407993 25200" (Unix timestamp, timezone offset).
429 - isodate: Date. Returns the date in ISO 8601 format.
434 - isodate: Date. Returns the date in ISO 8601 format.
430 - localdate: Date. Converts a date to local date.
435 - localdate: Date. Converts a date to local date.
431 - obfuscate: Any text. Returns the input text rendered as a
436 - obfuscate: Any text. Returns the input text rendered as a
432 sequence of XML entities.
437 sequence of XML entities.
433 - person: Any text. Returns the text before an email address.
438 - person: Any text. Returns the text before an email address.
434 - rfc822date: Date. Returns a date using the same format used
439 - rfc822date: Date. Returns a date using the same format used
435 in email headers.
440 in email headers.
436 - short: Changeset hash. Returns the short form of a changeset
441 - short: Changeset hash. Returns the short form of a changeset
437 hash, i.e. a 12-byte hexadecimal string.
442 hash, i.e. a 12-byte hexadecimal string.
438 - shortdate: Date. Returns a date like "2006-09-18".
443 - shortdate: Date. Returns a date like "2006-09-18".
439 - strip: Any text. Strips all leading and trailing whitespace.
444 - strip: Any text. Strips all leading and trailing whitespace.
440 - tabindent: Any text. Returns the text, with every line except
445 - tabindent: Any text. Returns the text, with every line except
441 the first starting with a tab character.
446 the first starting with a tab character.
442 - urlescape: Any text. Escapes all "special" characters. For
447 - urlescape: Any text. Escapes all "special" characters. For
443 example, "foo bar" becomes "foo%20bar".
448 example, "foo bar" becomes "foo%20bar".
444 - user: Any text. Returns the user portion of an email address.
449 - user: Any text. Returns the user portion of an email address.
445 ''')),
450 ''')),
446
451
447 (['urls'], _('URL Paths'),
452 (['urls'], _('URL Paths'),
448 _(r'''
453 _(r'''
449 Valid URLs are of the form:
454 Valid URLs are of the form:
450
455
451 local/filesystem/path (or file://local/filesystem/path)
456 local/filesystem/path (or file://local/filesystem/path)
452 http://[user[:pass]@]host[:port]/[path]
457 http://[user[:pass]@]host[:port]/[path]
453 https://[user[:pass]@]host[:port]/[path]
458 https://[user[:pass]@]host[:port]/[path]
454 ssh://[user[:pass]@]host[:port]/[path]
459 ssh://[user[:pass]@]host[:port]/[path]
455
460
456 Paths in the local filesystem can either point to Mercurial
461 Paths in the local filesystem can either point to Mercurial
457 repositories or to bundle files (as created by 'hg bundle' or
462 repositories or to bundle files (as created by 'hg bundle' or
458 'hg incoming --bundle').
463 'hg incoming --bundle').
459
464
460 An optional identifier after # indicates a particular branch, tag,
465 An optional identifier after # indicates a particular branch, tag,
461 or changeset to use from the remote repository.
466 or changeset to use from the remote repository.
462
467
463 Some features, such as pushing to http:// and https:// URLs are
468 Some features, such as pushing to http:// and https:// URLs are
464 only possible if the feature is explicitly enabled on the remote
469 only possible if the feature is explicitly enabled on the remote
465 Mercurial server.
470 Mercurial server.
466
471
467 Some notes about using SSH with Mercurial:
472 Some notes about using SSH with Mercurial:
468 - SSH requires an accessible shell account on the destination
473 - SSH requires an accessible shell account on the destination
469 machine and a copy of hg in the remote path or specified with as
474 machine and a copy of hg in the remote path or specified with as
470 remotecmd.
475 remotecmd.
471 - path is relative to the remote user's home directory by default.
476 - path is relative to the remote user's home directory by default.
472 Use an extra slash at the start of a path to specify an absolute path:
477 Use an extra slash at the start of a path to specify an absolute path:
473 ssh://example.com//tmp/repository
478 ssh://example.com//tmp/repository
474 - Mercurial doesn't use its own compression via SSH; the right
479 - Mercurial doesn't use its own compression via SSH; the right
475 thing to do is to configure it in your ~/.ssh/config, e.g.:
480 thing to do is to configure it in your ~/.ssh/config, e.g.:
476 Host *.mylocalnetwork.example.com
481 Host *.mylocalnetwork.example.com
477 Compression no
482 Compression no
478 Host *
483 Host *
479 Compression yes
484 Compression yes
480 Alternatively specify "ssh -C" as your ssh command in your hgrc
485 Alternatively specify "ssh -C" as your ssh command in your hgrc
481 or with the --ssh command line option.
486 or with the --ssh command line option.
482
487
483 These URLs can all be stored in your hgrc with path aliases under
488 These URLs can all be stored in your hgrc with path aliases under
484 the [paths] section like so:
489 the [paths] section like so:
485 [paths]
490 [paths]
486 alias1 = URL1
491 alias1 = URL1
487 alias2 = URL2
492 alias2 = URL2
488 ...
493 ...
489
494
490 You can then use the alias for any command that uses a URL (for
495 You can then use the alias for any command that uses a URL (for
491 example 'hg pull alias1' would pull from the 'alias1' path).
496 example 'hg pull alias1' would pull from the 'alias1' path).
492
497
493 Two path aliases are special because they are used as defaults
498 Two path aliases are special because they are used as defaults
494 when you do not provide the URL to a command:
499 when you do not provide the URL to a command:
495
500
496 default:
501 default:
497 When you create a repository with hg clone, the clone command
502 When you create a repository with hg clone, the clone command
498 saves the location of the source repository as the new
503 saves the location of the source repository as the new
499 repository's 'default' path. This is then used when you omit
504 repository's 'default' path. This is then used when you omit
500 path from push- and pull-like commands (including incoming and
505 path from push- and pull-like commands (including incoming and
501 outgoing).
506 outgoing).
502
507
503 default-push:
508 default-push:
504 The push command will look for a path named 'default-push', and
509 The push command will look for a path named 'default-push', and
505 prefer it over 'default' if both are defined.
510 prefer it over 'default' if both are defined.
506 ''')),
511 ''')),
507 (["extensions"], _("Using additional features"), extshelp),
512 (["extensions"], _("Using additional features"), extshelp),
508 )
513 )
General Comments 0
You need to be logged in to leave comments. Login now