##// END OF EJS Templates
help: mark literal blocks
Martin Geisler -
r9290:26fb5b0a default
parent child Browse files
Show More
@@ -1,522 +1,522 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 Lastly, there is Mercurial's internal format:
122 Lastly, there is Mercurial's internal format::
123 123
124 "1165432709 0" (Wed Dec 6 13:18:29 2006 UTC)
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 Usage:
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 expansion:
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 378 - author: String. The unmodified author of the changeset.
379 379 - branches: String. The name of the branch on which the changeset
380 380 was committed. Will be empty if the branch name was default.
381 381 - date: Date information. The date when the changeset was
382 382 committed.
383 383 - desc: String. The text of the changeset description.
384 384 - diffstat: String. Statistics of changes with the following
385 385 format: "modified files: +added/-removed lines"
386 386 - files: List of strings. All files modified, added, or removed by
387 387 this changeset.
388 388 - file_adds: List of strings. Files added by this changeset.
389 389 - file_mods: List of strings. Files modified by this changeset.
390 390 - file_dels: List of strings. Files removed by this changeset.
391 391 - node: String. The changeset identification hash, as a
392 392 40-character hexadecimal string.
393 393 - parents: List of strings. The parents of the changeset.
394 394 - rev: Integer. The repository-local changeset revision number.
395 395 - tags: List of strings. Any tags associated with the changeset.
396 396
397 397 The "date" keyword does not produce human-readable output. If you
398 398 want to use a date in your output, you can use a filter to process
399 399 it. Filters are functions which return a string based on the input
400 400 variable. You can also use a chain of filters to get the desired
401 output:
401 output::
402 402
403 403 $ hg tip --template "{date|isodate}\n"
404 404 2008-08-21 18:22 +0000
405 405
406 406 List of filters:
407 407
408 408 - addbreaks: Any text. Add an XHTML "<br />" tag before the end of
409 409 every line except the last.
410 410 - age: Date. Returns a human-readable date/time difference between
411 411 the given date/time and the current date/time.
412 412 - basename: Any text. Treats the text as a path, and returns the
413 413 last component of the path after splitting by the path separator
414 414 (ignoring trailing separators). For example, "foo/bar/baz"
415 415 becomes "baz" and "foo/bar//" becomes "bar".
416 416 - stripdir: Treat the text as path and strip a directory level, if
417 417 possible. For example, "foo" and "foo/bar" becomes "foo".
418 418 - date: Date. Returns a date in a Unix date format, including the
419 419 timezone: "Mon Sep 04 15:13:13 2006 0700".
420 420 - domain: Any text. Finds the first string that looks like an
421 421 email address, and extracts just the domain component. Example:
422 422 'User <user@example.com>' becomes 'example.com'.
423 423 - email: Any text. Extracts the first string that looks like an
424 424 email address. Example: 'User <user@example.com>' becomes
425 425 'user@example.com'.
426 426 - escape: Any text. Replaces the special XML/XHTML characters "&",
427 427 "<" and ">" with XML entities.
428 428 - fill68: Any text. Wraps the text to fit in 68 columns.
429 429 - fill76: Any text. Wraps the text to fit in 76 columns.
430 430 - firstline: Any text. Returns the first line of text.
431 431 - nonempty: Any text. Returns '(none)' if the string is empty.
432 432 - hgdate: Date. Returns the date as a pair of numbers: "1157407993
433 433 25200" (Unix timestamp, timezone offset).
434 434 - isodate: Date. Returns the date in ISO 8601 format.
435 435 - localdate: Date. Converts a date to local date.
436 436 - obfuscate: Any text. Returns the input text rendered as a
437 437 sequence of XML entities.
438 438 - person: Any text. Returns the text before an email address.
439 439 - rfc822date: Date. Returns a date using the same format used in
440 440 email headers.
441 441 - short: Changeset hash. Returns the short form of a changeset
442 442 hash, i.e. a 12-byte hexadecimal string.
443 443 - shortdate: Date. Returns a date like "2006-09-18".
444 444 - strip: Any text. Strips all leading and trailing whitespace.
445 445 - tabindent: Any text. Returns the text, with every line except
446 446 the first starting with a tab character.
447 447 - urlescape: Any text. Escapes all "special" characters. For
448 448 example, "foo bar" becomes "foo%20bar".
449 449 - user: Any text. Returns the user portion of an email address.
450 450 ''')),
451 451
452 452 (['urls'], _('URL Paths'),
453 453 _(r'''
454 454 Valid URLs are of the form::
455 455
456 456 local/filesystem/path[#revision]
457 457 file://local/filesystem/path[#revision]
458 458 http://[user[:pass]@]host[:port]/[path][#revision]
459 459 https://[user[:pass]@]host[:port]/[path][#revision]
460 460 ssh://[user[:pass]@]host[:port]/[path][#revision]
461 461
462 462 Paths in the local filesystem can either point to Mercurial
463 463 repositories or to bundle files (as created by 'hg bundle' or 'hg
464 464 incoming --bundle').
465 465
466 466 An optional identifier after # indicates a particular branch, tag,
467 467 or changeset to use from the remote repository. See also 'hg help
468 468 revisions'.
469 469
470 470 Some features, such as pushing to http:// and https:// URLs are
471 471 only possible if the feature is explicitly enabled on the remote
472 472 Mercurial server.
473 473
474 474 Some notes about using SSH with Mercurial:
475 475
476 476 - SSH requires an accessible shell account on the destination
477 477 machine and a copy of hg in the remote path or specified with as
478 478 remotecmd.
479 479 - path is relative to the remote user's home directory by default.
480 480 Use an extra slash at the start of a path to specify an absolute
481 481 path::
482 482
483 483 ssh://example.com//tmp/repository
484 484
485 485 - Mercurial doesn't use its own compression via SSH; the right
486 486 thing to do is to configure it in your ~/.ssh/config, e.g.::
487 487
488 488 Host *.mylocalnetwork.example.com
489 489 Compression no
490 490 Host *
491 491 Compression yes
492 492
493 493 Alternatively specify "ssh -C" as your ssh command in your hgrc
494 494 or with the --ssh command line option.
495 495
496 496 These URLs can all be stored in your hgrc with path aliases under
497 497 the [paths] section like so::
498 498
499 499 [paths]
500 500 alias1 = URL1
501 501 alias2 = URL2
502 502 ...
503 503
504 504 You can then use the alias for any command that uses a URL (for
505 505 example 'hg pull alias1' would pull from the 'alias1' path).
506 506
507 507 Two path aliases are special because they are used as defaults
508 508 when you do not provide the URL to a command:
509 509
510 510 default:
511 511 When you create a repository with hg clone, the clone command
512 512 saves the location of the source repository as the new
513 513 repository's 'default' path. This is then used when you omit
514 514 path from push- and pull-like commands (including incoming and
515 515 outgoing).
516 516
517 517 default-push:
518 518 The push command will look for a path named 'default-push', and
519 519 prefer it over 'default' if both are defined.
520 520 ''')),
521 521 (["extensions"], _("Using additional features"), extshelp),
522 522 )
General Comments 0
You need to be logged in to leave comments. Login now