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