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