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