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