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