##// END OF EJS Templates
help: displaying documented aliases by default...
rdamazio@google.com -
r40450:444861dc default
parent child Browse files
Show More
@@ -1,1077 +1,1084 b''
1 # dispatch.py - command dispatching for mercurial
1 # dispatch.py - command dispatching for mercurial
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 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 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import, print_function
8 from __future__ import absolute_import, print_function
9
9
10 import difflib
10 import difflib
11 import errno
11 import errno
12 import getopt
12 import getopt
13 import os
13 import os
14 import pdb
14 import pdb
15 import re
15 import re
16 import signal
16 import signal
17 import sys
17 import sys
18 import time
18 import time
19 import traceback
19 import traceback
20
20
21
21
22 from .i18n import _
22 from .i18n import _
23
23
24 from hgdemandimport import tracing
24 from hgdemandimport import tracing
25
25
26 from . import (
26 from . import (
27 cmdutil,
27 cmdutil,
28 color,
28 color,
29 commands,
29 commands,
30 demandimport,
30 demandimport,
31 encoding,
31 encoding,
32 error,
32 error,
33 extensions,
33 extensions,
34 fancyopts,
34 fancyopts,
35 help,
35 help,
36 hg,
36 hg,
37 hook,
37 hook,
38 profiling,
38 profiling,
39 pycompat,
39 pycompat,
40 registrar,
40 scmutil,
41 scmutil,
41 ui as uimod,
42 ui as uimod,
42 util,
43 util,
43 )
44 )
44
45
45 from .utils import (
46 from .utils import (
46 procutil,
47 procutil,
47 stringutil,
48 stringutil,
48 )
49 )
49
50
50 class request(object):
51 class request(object):
51 def __init__(self, args, ui=None, repo=None, fin=None, fout=None,
52 def __init__(self, args, ui=None, repo=None, fin=None, fout=None,
52 ferr=None, prereposetups=None):
53 ferr=None, prereposetups=None):
53 self.args = args
54 self.args = args
54 self.ui = ui
55 self.ui = ui
55 self.repo = repo
56 self.repo = repo
56
57
57 # input/output/error streams
58 # input/output/error streams
58 self.fin = fin
59 self.fin = fin
59 self.fout = fout
60 self.fout = fout
60 self.ferr = ferr
61 self.ferr = ferr
61
62
62 # remember options pre-parsed by _earlyparseopts()
63 # remember options pre-parsed by _earlyparseopts()
63 self.earlyoptions = {}
64 self.earlyoptions = {}
64
65
65 # reposetups which run before extensions, useful for chg to pre-fill
66 # reposetups which run before extensions, useful for chg to pre-fill
66 # low-level repo state (for example, changelog) before extensions.
67 # low-level repo state (for example, changelog) before extensions.
67 self.prereposetups = prereposetups or []
68 self.prereposetups = prereposetups or []
68
69
69 # store the parsed and canonical command
70 # store the parsed and canonical command
70 self.canonical_command = None
71 self.canonical_command = None
71
72
72 def _runexithandlers(self):
73 def _runexithandlers(self):
73 exc = None
74 exc = None
74 handlers = self.ui._exithandlers
75 handlers = self.ui._exithandlers
75 try:
76 try:
76 while handlers:
77 while handlers:
77 func, args, kwargs = handlers.pop()
78 func, args, kwargs = handlers.pop()
78 try:
79 try:
79 func(*args, **kwargs)
80 func(*args, **kwargs)
80 except: # re-raises below
81 except: # re-raises below
81 if exc is None:
82 if exc is None:
82 exc = sys.exc_info()[1]
83 exc = sys.exc_info()[1]
83 self.ui.warn(('error in exit handlers:\n'))
84 self.ui.warn(('error in exit handlers:\n'))
84 self.ui.traceback(force=True)
85 self.ui.traceback(force=True)
85 finally:
86 finally:
86 if exc is not None:
87 if exc is not None:
87 raise exc
88 raise exc
88
89
89 def run():
90 def run():
90 "run the command in sys.argv"
91 "run the command in sys.argv"
91 initstdio()
92 initstdio()
92 with tracing.log('parse args into request'):
93 with tracing.log('parse args into request'):
93 req = request(pycompat.sysargv[1:])
94 req = request(pycompat.sysargv[1:])
94 err = None
95 err = None
95 try:
96 try:
96 status = dispatch(req)
97 status = dispatch(req)
97 except error.StdioError as e:
98 except error.StdioError as e:
98 err = e
99 err = e
99 status = -1
100 status = -1
100
101
101 # In all cases we try to flush stdio streams.
102 # In all cases we try to flush stdio streams.
102 if util.safehasattr(req.ui, 'fout'):
103 if util.safehasattr(req.ui, 'fout'):
103 try:
104 try:
104 req.ui.fout.flush()
105 req.ui.fout.flush()
105 except IOError as e:
106 except IOError as e:
106 err = e
107 err = e
107 status = -1
108 status = -1
108
109
109 if util.safehasattr(req.ui, 'ferr'):
110 if util.safehasattr(req.ui, 'ferr'):
110 try:
111 try:
111 if err is not None and err.errno != errno.EPIPE:
112 if err is not None and err.errno != errno.EPIPE:
112 req.ui.ferr.write('abort: %s\n' %
113 req.ui.ferr.write('abort: %s\n' %
113 encoding.strtolocal(err.strerror))
114 encoding.strtolocal(err.strerror))
114 req.ui.ferr.flush()
115 req.ui.ferr.flush()
115 # There's not much we can do about an I/O error here. So (possibly)
116 # There's not much we can do about an I/O error here. So (possibly)
116 # change the status code and move on.
117 # change the status code and move on.
117 except IOError:
118 except IOError:
118 status = -1
119 status = -1
119
120
120 _silencestdio()
121 _silencestdio()
121 sys.exit(status & 255)
122 sys.exit(status & 255)
122
123
123 if pycompat.ispy3:
124 if pycompat.ispy3:
124 def initstdio():
125 def initstdio():
125 pass
126 pass
126
127
127 def _silencestdio():
128 def _silencestdio():
128 for fp in (sys.stdout, sys.stderr):
129 for fp in (sys.stdout, sys.stderr):
129 # Check if the file is okay
130 # Check if the file is okay
130 try:
131 try:
131 fp.flush()
132 fp.flush()
132 continue
133 continue
133 except IOError:
134 except IOError:
134 pass
135 pass
135 # Otherwise mark it as closed to silence "Exception ignored in"
136 # Otherwise mark it as closed to silence "Exception ignored in"
136 # message emitted by the interpreter finalizer. Be careful to
137 # message emitted by the interpreter finalizer. Be careful to
137 # not close procutil.stdout, which may be a fdopen-ed file object
138 # not close procutil.stdout, which may be a fdopen-ed file object
138 # and its close() actually closes the underlying file descriptor.
139 # and its close() actually closes the underlying file descriptor.
139 try:
140 try:
140 fp.close()
141 fp.close()
141 except IOError:
142 except IOError:
142 pass
143 pass
143 else:
144 else:
144 def initstdio():
145 def initstdio():
145 for fp in (sys.stdin, sys.stdout, sys.stderr):
146 for fp in (sys.stdin, sys.stdout, sys.stderr):
146 procutil.setbinary(fp)
147 procutil.setbinary(fp)
147
148
148 def _silencestdio():
149 def _silencestdio():
149 pass
150 pass
150
151
151 def _getsimilar(symbols, value):
152 def _getsimilar(symbols, value):
152 sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio()
153 sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio()
153 # The cutoff for similarity here is pretty arbitrary. It should
154 # The cutoff for similarity here is pretty arbitrary. It should
154 # probably be investigated and tweaked.
155 # probably be investigated and tweaked.
155 return [s for s in symbols if sim(s) > 0.6]
156 return [s for s in symbols if sim(s) > 0.6]
156
157
157 def _reportsimilar(write, similar):
158 def _reportsimilar(write, similar):
158 if len(similar) == 1:
159 if len(similar) == 1:
159 write(_("(did you mean %s?)\n") % similar[0])
160 write(_("(did you mean %s?)\n") % similar[0])
160 elif similar:
161 elif similar:
161 ss = ", ".join(sorted(similar))
162 ss = ", ".join(sorted(similar))
162 write(_("(did you mean one of %s?)\n") % ss)
163 write(_("(did you mean one of %s?)\n") % ss)
163
164
164 def _formatparse(write, inst):
165 def _formatparse(write, inst):
165 similar = []
166 similar = []
166 if isinstance(inst, error.UnknownIdentifier):
167 if isinstance(inst, error.UnknownIdentifier):
167 # make sure to check fileset first, as revset can invoke fileset
168 # make sure to check fileset first, as revset can invoke fileset
168 similar = _getsimilar(inst.symbols, inst.function)
169 similar = _getsimilar(inst.symbols, inst.function)
169 if len(inst.args) > 1:
170 if len(inst.args) > 1:
170 write(_("hg: parse error at %s: %s\n") %
171 write(_("hg: parse error at %s: %s\n") %
171 (pycompat.bytestr(inst.args[1]), inst.args[0]))
172 (pycompat.bytestr(inst.args[1]), inst.args[0]))
172 if inst.args[0].startswith(' '):
173 if inst.args[0].startswith(' '):
173 write(_("unexpected leading whitespace\n"))
174 write(_("unexpected leading whitespace\n"))
174 else:
175 else:
175 write(_("hg: parse error: %s\n") % inst.args[0])
176 write(_("hg: parse error: %s\n") % inst.args[0])
176 _reportsimilar(write, similar)
177 _reportsimilar(write, similar)
177 if inst.hint:
178 if inst.hint:
178 write(_("(%s)\n") % inst.hint)
179 write(_("(%s)\n") % inst.hint)
179
180
180 def _formatargs(args):
181 def _formatargs(args):
181 return ' '.join(procutil.shellquote(a) for a in args)
182 return ' '.join(procutil.shellquote(a) for a in args)
182
183
183 def dispatch(req):
184 def dispatch(req):
184 """run the command specified in req.args; returns an integer status code"""
185 """run the command specified in req.args; returns an integer status code"""
185 with tracing.log('dispatch.dispatch'):
186 with tracing.log('dispatch.dispatch'):
186 if req.ferr:
187 if req.ferr:
187 ferr = req.ferr
188 ferr = req.ferr
188 elif req.ui:
189 elif req.ui:
189 ferr = req.ui.ferr
190 ferr = req.ui.ferr
190 else:
191 else:
191 ferr = procutil.stderr
192 ferr = procutil.stderr
192
193
193 try:
194 try:
194 if not req.ui:
195 if not req.ui:
195 req.ui = uimod.ui.load()
196 req.ui = uimod.ui.load()
196 req.earlyoptions.update(_earlyparseopts(req.ui, req.args))
197 req.earlyoptions.update(_earlyparseopts(req.ui, req.args))
197 if req.earlyoptions['traceback']:
198 if req.earlyoptions['traceback']:
198 req.ui.setconfig('ui', 'traceback', 'on', '--traceback')
199 req.ui.setconfig('ui', 'traceback', 'on', '--traceback')
199
200
200 # set ui streams from the request
201 # set ui streams from the request
201 if req.fin:
202 if req.fin:
202 req.ui.fin = req.fin
203 req.ui.fin = req.fin
203 if req.fout:
204 if req.fout:
204 req.ui.fout = req.fout
205 req.ui.fout = req.fout
205 if req.ferr:
206 if req.ferr:
206 req.ui.ferr = req.ferr
207 req.ui.ferr = req.ferr
207 except error.Abort as inst:
208 except error.Abort as inst:
208 ferr.write(_("abort: %s\n") % inst)
209 ferr.write(_("abort: %s\n") % inst)
209 if inst.hint:
210 if inst.hint:
210 ferr.write(_("(%s)\n") % inst.hint)
211 ferr.write(_("(%s)\n") % inst.hint)
211 return -1
212 return -1
212 except error.ParseError as inst:
213 except error.ParseError as inst:
213 _formatparse(ferr.write, inst)
214 _formatparse(ferr.write, inst)
214 return -1
215 return -1
215
216
216 msg = _formatargs(req.args)
217 msg = _formatargs(req.args)
217 starttime = util.timer()
218 starttime = util.timer()
218 ret = 1 # default of Python exit code on unhandled exception
219 ret = 1 # default of Python exit code on unhandled exception
219 try:
220 try:
220 ret = _runcatch(req) or 0
221 ret = _runcatch(req) or 0
221 except error.ProgrammingError as inst:
222 except error.ProgrammingError as inst:
222 req.ui.error(_('** ProgrammingError: %s\n') % inst)
223 req.ui.error(_('** ProgrammingError: %s\n') % inst)
223 if inst.hint:
224 if inst.hint:
224 req.ui.error(_('** (%s)\n') % inst.hint)
225 req.ui.error(_('** (%s)\n') % inst.hint)
225 raise
226 raise
226 except KeyboardInterrupt as inst:
227 except KeyboardInterrupt as inst:
227 try:
228 try:
228 if isinstance(inst, error.SignalInterrupt):
229 if isinstance(inst, error.SignalInterrupt):
229 msg = _("killed!\n")
230 msg = _("killed!\n")
230 else:
231 else:
231 msg = _("interrupted!\n")
232 msg = _("interrupted!\n")
232 req.ui.error(msg)
233 req.ui.error(msg)
233 except error.SignalInterrupt:
234 except error.SignalInterrupt:
234 # maybe pager would quit without consuming all the output, and
235 # maybe pager would quit without consuming all the output, and
235 # SIGPIPE was raised. we cannot print anything in this case.
236 # SIGPIPE was raised. we cannot print anything in this case.
236 pass
237 pass
237 except IOError as inst:
238 except IOError as inst:
238 if inst.errno != errno.EPIPE:
239 if inst.errno != errno.EPIPE:
239 raise
240 raise
240 ret = -1
241 ret = -1
241 finally:
242 finally:
242 duration = util.timer() - starttime
243 duration = util.timer() - starttime
243 req.ui.flush()
244 req.ui.flush()
244 if req.ui.logblockedtimes:
245 if req.ui.logblockedtimes:
245 req.ui._blockedtimes['command_duration'] = duration * 1000
246 req.ui._blockedtimes['command_duration'] = duration * 1000
246 req.ui.log('uiblocked', 'ui blocked ms',
247 req.ui.log('uiblocked', 'ui blocked ms',
247 **pycompat.strkwargs(req.ui._blockedtimes))
248 **pycompat.strkwargs(req.ui._blockedtimes))
248 req.ui.log("commandfinish", "%s exited %d after %0.2f seconds\n",
249 req.ui.log("commandfinish", "%s exited %d after %0.2f seconds\n",
249 msg, ret & 255, duration,
250 msg, ret & 255, duration,
250 canonical_command=req.canonical_command)
251 canonical_command=req.canonical_command)
251 try:
252 try:
252 req._runexithandlers()
253 req._runexithandlers()
253 except: # exiting, so no re-raises
254 except: # exiting, so no re-raises
254 ret = ret or -1
255 ret = ret or -1
255 return ret
256 return ret
256
257
257 def _runcatch(req):
258 def _runcatch(req):
258 with tracing.log('dispatch._runcatch'):
259 with tracing.log('dispatch._runcatch'):
259 def catchterm(*args):
260 def catchterm(*args):
260 raise error.SignalInterrupt
261 raise error.SignalInterrupt
261
262
262 ui = req.ui
263 ui = req.ui
263 try:
264 try:
264 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
265 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
265 num = getattr(signal, name, None)
266 num = getattr(signal, name, None)
266 if num:
267 if num:
267 signal.signal(num, catchterm)
268 signal.signal(num, catchterm)
268 except ValueError:
269 except ValueError:
269 pass # happens if called in a thread
270 pass # happens if called in a thread
270
271
271 def _runcatchfunc():
272 def _runcatchfunc():
272 realcmd = None
273 realcmd = None
273 try:
274 try:
274 cmdargs = fancyopts.fancyopts(
275 cmdargs = fancyopts.fancyopts(
275 req.args[:], commands.globalopts, {})
276 req.args[:], commands.globalopts, {})
276 cmd = cmdargs[0]
277 cmd = cmdargs[0]
277 aliases, entry = cmdutil.findcmd(cmd, commands.table, False)
278 aliases, entry = cmdutil.findcmd(cmd, commands.table, False)
278 realcmd = aliases[0]
279 realcmd = aliases[0]
279 except (error.UnknownCommand, error.AmbiguousCommand,
280 except (error.UnknownCommand, error.AmbiguousCommand,
280 IndexError, getopt.GetoptError):
281 IndexError, getopt.GetoptError):
281 # Don't handle this here. We know the command is
282 # Don't handle this here. We know the command is
282 # invalid, but all we're worried about for now is that
283 # invalid, but all we're worried about for now is that
283 # it's not a command that server operators expect to
284 # it's not a command that server operators expect to
284 # be safe to offer to users in a sandbox.
285 # be safe to offer to users in a sandbox.
285 pass
286 pass
286 if realcmd == 'serve' and '--stdio' in cmdargs:
287 if realcmd == 'serve' and '--stdio' in cmdargs:
287 # We want to constrain 'hg serve --stdio' instances pretty
288 # We want to constrain 'hg serve --stdio' instances pretty
288 # closely, as many shared-ssh access tools want to grant
289 # closely, as many shared-ssh access tools want to grant
289 # access to run *only* 'hg -R $repo serve --stdio'. We
290 # access to run *only* 'hg -R $repo serve --stdio'. We
290 # restrict to exactly that set of arguments, and prohibit
291 # restrict to exactly that set of arguments, and prohibit
291 # any repo name that starts with '--' to prevent
292 # any repo name that starts with '--' to prevent
292 # shenanigans wherein a user does something like pass
293 # shenanigans wherein a user does something like pass
293 # --debugger or --config=ui.debugger=1 as a repo
294 # --debugger or --config=ui.debugger=1 as a repo
294 # name. This used to actually run the debugger.
295 # name. This used to actually run the debugger.
295 if (len(req.args) != 4 or
296 if (len(req.args) != 4 or
296 req.args[0] != '-R' or
297 req.args[0] != '-R' or
297 req.args[1].startswith('--') or
298 req.args[1].startswith('--') or
298 req.args[2] != 'serve' or
299 req.args[2] != 'serve' or
299 req.args[3] != '--stdio'):
300 req.args[3] != '--stdio'):
300 raise error.Abort(
301 raise error.Abort(
301 _('potentially unsafe serve --stdio invocation: %s') %
302 _('potentially unsafe serve --stdio invocation: %s') %
302 (stringutil.pprint(req.args),))
303 (stringutil.pprint(req.args),))
303
304
304 try:
305 try:
305 debugger = 'pdb'
306 debugger = 'pdb'
306 debugtrace = {
307 debugtrace = {
307 'pdb': pdb.set_trace
308 'pdb': pdb.set_trace
308 }
309 }
309 debugmortem = {
310 debugmortem = {
310 'pdb': pdb.post_mortem
311 'pdb': pdb.post_mortem
311 }
312 }
312
313
313 # read --config before doing anything else
314 # read --config before doing anything else
314 # (e.g. to change trust settings for reading .hg/hgrc)
315 # (e.g. to change trust settings for reading .hg/hgrc)
315 cfgs = _parseconfig(req.ui, req.earlyoptions['config'])
316 cfgs = _parseconfig(req.ui, req.earlyoptions['config'])
316
317
317 if req.repo:
318 if req.repo:
318 # copy configs that were passed on the cmdline (--config) to
319 # copy configs that were passed on the cmdline (--config) to
319 # the repo ui
320 # the repo ui
320 for sec, name, val in cfgs:
321 for sec, name, val in cfgs:
321 req.repo.ui.setconfig(sec, name, val, source='--config')
322 req.repo.ui.setconfig(sec, name, val, source='--config')
322
323
323 # developer config: ui.debugger
324 # developer config: ui.debugger
324 debugger = ui.config("ui", "debugger")
325 debugger = ui.config("ui", "debugger")
325 debugmod = pdb
326 debugmod = pdb
326 if not debugger or ui.plain():
327 if not debugger or ui.plain():
327 # if we are in HGPLAIN mode, then disable custom debugging
328 # if we are in HGPLAIN mode, then disable custom debugging
328 debugger = 'pdb'
329 debugger = 'pdb'
329 elif req.earlyoptions['debugger']:
330 elif req.earlyoptions['debugger']:
330 # This import can be slow for fancy debuggers, so only
331 # This import can be slow for fancy debuggers, so only
331 # do it when absolutely necessary, i.e. when actual
332 # do it when absolutely necessary, i.e. when actual
332 # debugging has been requested
333 # debugging has been requested
333 with demandimport.deactivated():
334 with demandimport.deactivated():
334 try:
335 try:
335 debugmod = __import__(debugger)
336 debugmod = __import__(debugger)
336 except ImportError:
337 except ImportError:
337 pass # Leave debugmod = pdb
338 pass # Leave debugmod = pdb
338
339
339 debugtrace[debugger] = debugmod.set_trace
340 debugtrace[debugger] = debugmod.set_trace
340 debugmortem[debugger] = debugmod.post_mortem
341 debugmortem[debugger] = debugmod.post_mortem
341
342
342 # enter the debugger before command execution
343 # enter the debugger before command execution
343 if req.earlyoptions['debugger']:
344 if req.earlyoptions['debugger']:
344 ui.warn(_("entering debugger - "
345 ui.warn(_("entering debugger - "
345 "type c to continue starting hg or h for help\n"))
346 "type c to continue starting hg or h for help\n"))
346
347
347 if (debugger != 'pdb' and
348 if (debugger != 'pdb' and
348 debugtrace[debugger] == debugtrace['pdb']):
349 debugtrace[debugger] == debugtrace['pdb']):
349 ui.warn(_("%s debugger specified "
350 ui.warn(_("%s debugger specified "
350 "but its module was not found\n") % debugger)
351 "but its module was not found\n") % debugger)
351 with demandimport.deactivated():
352 with demandimport.deactivated():
352 debugtrace[debugger]()
353 debugtrace[debugger]()
353 try:
354 try:
354 return _dispatch(req)
355 return _dispatch(req)
355 finally:
356 finally:
356 ui.flush()
357 ui.flush()
357 except: # re-raises
358 except: # re-raises
358 # enter the debugger when we hit an exception
359 # enter the debugger when we hit an exception
359 if req.earlyoptions['debugger']:
360 if req.earlyoptions['debugger']:
360 traceback.print_exc()
361 traceback.print_exc()
361 debugmortem[debugger](sys.exc_info()[2])
362 debugmortem[debugger](sys.exc_info()[2])
362 raise
363 raise
363 return _callcatch(ui, _runcatchfunc)
364 return _callcatch(ui, _runcatchfunc)
364
365
365 def _callcatch(ui, func):
366 def _callcatch(ui, func):
366 """like scmutil.callcatch but handles more high-level exceptions about
367 """like scmutil.callcatch but handles more high-level exceptions about
367 config parsing and commands. besides, use handlecommandexception to handle
368 config parsing and commands. besides, use handlecommandexception to handle
368 uncaught exceptions.
369 uncaught exceptions.
369 """
370 """
370 try:
371 try:
371 return scmutil.callcatch(ui, func)
372 return scmutil.callcatch(ui, func)
372 except error.AmbiguousCommand as inst:
373 except error.AmbiguousCommand as inst:
373 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
374 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
374 (inst.args[0], " ".join(inst.args[1])))
375 (inst.args[0], " ".join(inst.args[1])))
375 except error.CommandError as inst:
376 except error.CommandError as inst:
376 if inst.args[0]:
377 if inst.args[0]:
377 ui.pager('help')
378 ui.pager('help')
378 msgbytes = pycompat.bytestr(inst.args[1])
379 msgbytes = pycompat.bytestr(inst.args[1])
379 ui.warn(_("hg %s: %s\n") % (inst.args[0], msgbytes))
380 ui.warn(_("hg %s: %s\n") % (inst.args[0], msgbytes))
380 commands.help_(ui, inst.args[0], full=False, command=True)
381 commands.help_(ui, inst.args[0], full=False, command=True)
381 else:
382 else:
382 ui.warn(_("hg: %s\n") % inst.args[1])
383 ui.warn(_("hg: %s\n") % inst.args[1])
383 ui.warn(_("(use 'hg help -v' for a list of global options)\n"))
384 ui.warn(_("(use 'hg help -v' for a list of global options)\n"))
384 except error.ParseError as inst:
385 except error.ParseError as inst:
385 _formatparse(ui.warn, inst)
386 _formatparse(ui.warn, inst)
386 return -1
387 return -1
387 except error.UnknownCommand as inst:
388 except error.UnknownCommand as inst:
388 nocmdmsg = _("hg: unknown command '%s'\n") % inst.args[0]
389 nocmdmsg = _("hg: unknown command '%s'\n") % inst.args[0]
389 try:
390 try:
390 # check if the command is in a disabled extension
391 # check if the command is in a disabled extension
391 # (but don't check for extensions themselves)
392 # (but don't check for extensions themselves)
392 formatted = help.formattedhelp(ui, commands, inst.args[0],
393 formatted = help.formattedhelp(ui, commands, inst.args[0],
393 unknowncmd=True)
394 unknowncmd=True)
394 ui.warn(nocmdmsg)
395 ui.warn(nocmdmsg)
395 ui.write(formatted)
396 ui.write(formatted)
396 except (error.UnknownCommand, error.Abort):
397 except (error.UnknownCommand, error.Abort):
397 suggested = False
398 suggested = False
398 if len(inst.args) == 2:
399 if len(inst.args) == 2:
399 sim = _getsimilar(inst.args[1], inst.args[0])
400 sim = _getsimilar(inst.args[1], inst.args[0])
400 if sim:
401 if sim:
401 ui.warn(nocmdmsg)
402 ui.warn(nocmdmsg)
402 _reportsimilar(ui.warn, sim)
403 _reportsimilar(ui.warn, sim)
403 suggested = True
404 suggested = True
404 if not suggested:
405 if not suggested:
405 ui.warn(nocmdmsg)
406 ui.warn(nocmdmsg)
406 ui.warn(_("(use 'hg help' for a list of commands)\n"))
407 ui.warn(_("(use 'hg help' for a list of commands)\n"))
407 except IOError:
408 except IOError:
408 raise
409 raise
409 except KeyboardInterrupt:
410 except KeyboardInterrupt:
410 raise
411 raise
411 except: # probably re-raises
412 except: # probably re-raises
412 if not handlecommandexception(ui):
413 if not handlecommandexception(ui):
413 raise
414 raise
414
415
415 return -1
416 return -1
416
417
417 def aliasargs(fn, givenargs):
418 def aliasargs(fn, givenargs):
418 args = []
419 args = []
419 # only care about alias 'args', ignore 'args' set by extensions.wrapfunction
420 # only care about alias 'args', ignore 'args' set by extensions.wrapfunction
420 if not util.safehasattr(fn, '_origfunc'):
421 if not util.safehasattr(fn, '_origfunc'):
421 args = getattr(fn, 'args', args)
422 args = getattr(fn, 'args', args)
422 if args:
423 if args:
423 cmd = ' '.join(map(procutil.shellquote, args))
424 cmd = ' '.join(map(procutil.shellquote, args))
424
425
425 nums = []
426 nums = []
426 def replacer(m):
427 def replacer(m):
427 num = int(m.group(1)) - 1
428 num = int(m.group(1)) - 1
428 nums.append(num)
429 nums.append(num)
429 if num < len(givenargs):
430 if num < len(givenargs):
430 return givenargs[num]
431 return givenargs[num]
431 raise error.Abort(_('too few arguments for command alias'))
432 raise error.Abort(_('too few arguments for command alias'))
432 cmd = re.sub(br'\$(\d+|\$)', replacer, cmd)
433 cmd = re.sub(br'\$(\d+|\$)', replacer, cmd)
433 givenargs = [x for i, x in enumerate(givenargs)
434 givenargs = [x for i, x in enumerate(givenargs)
434 if i not in nums]
435 if i not in nums]
435 args = pycompat.shlexsplit(cmd)
436 args = pycompat.shlexsplit(cmd)
436 return args + givenargs
437 return args + givenargs
437
438
438 def aliasinterpolate(name, args, cmd):
439 def aliasinterpolate(name, args, cmd):
439 '''interpolate args into cmd for shell aliases
440 '''interpolate args into cmd for shell aliases
440
441
441 This also handles $0, $@ and "$@".
442 This also handles $0, $@ and "$@".
442 '''
443 '''
443 # util.interpolate can't deal with "$@" (with quotes) because it's only
444 # util.interpolate can't deal with "$@" (with quotes) because it's only
444 # built to match prefix + patterns.
445 # built to match prefix + patterns.
445 replacemap = dict(('$%d' % (i + 1), arg) for i, arg in enumerate(args))
446 replacemap = dict(('$%d' % (i + 1), arg) for i, arg in enumerate(args))
446 replacemap['$0'] = name
447 replacemap['$0'] = name
447 replacemap['$$'] = '$'
448 replacemap['$$'] = '$'
448 replacemap['$@'] = ' '.join(args)
449 replacemap['$@'] = ' '.join(args)
449 # Typical Unix shells interpolate "$@" (with quotes) as all the positional
450 # Typical Unix shells interpolate "$@" (with quotes) as all the positional
450 # parameters, separated out into words. Emulate the same behavior here by
451 # parameters, separated out into words. Emulate the same behavior here by
451 # quoting the arguments individually. POSIX shells will then typically
452 # quoting the arguments individually. POSIX shells will then typically
452 # tokenize each argument into exactly one word.
453 # tokenize each argument into exactly one word.
453 replacemap['"$@"'] = ' '.join(procutil.shellquote(arg) for arg in args)
454 replacemap['"$@"'] = ' '.join(procutil.shellquote(arg) for arg in args)
454 # escape '\$' for regex
455 # escape '\$' for regex
455 regex = '|'.join(replacemap.keys()).replace('$', br'\$')
456 regex = '|'.join(replacemap.keys()).replace('$', br'\$')
456 r = re.compile(regex)
457 r = re.compile(regex)
457 return r.sub(lambda x: replacemap[x.group()], cmd)
458 return r.sub(lambda x: replacemap[x.group()], cmd)
458
459
459 class cmdalias(object):
460 class cmdalias(object):
460 def __init__(self, ui, name, definition, cmdtable, source):
461 def __init__(self, ui, name, definition, cmdtable, source):
461 self.name = self.cmd = name
462 self.name = self.cmd = name
462 self.cmdname = ''
463 self.cmdname = ''
463 self.definition = definition
464 self.definition = definition
464 self.fn = None
465 self.fn = None
465 self.givenargs = []
466 self.givenargs = []
466 self.opts = []
467 self.opts = []
467 self.help = ''
468 self.help = ''
468 self.badalias = None
469 self.badalias = None
469 self.unknowncmd = False
470 self.unknowncmd = False
470 self.source = source
471 self.source = source
471
472
472 try:
473 try:
473 aliases, entry = cmdutil.findcmd(self.name, cmdtable)
474 aliases, entry = cmdutil.findcmd(self.name, cmdtable)
474 for alias, e in cmdtable.iteritems():
475 for alias, e in cmdtable.iteritems():
475 if e is entry:
476 if e is entry:
476 self.cmd = alias
477 self.cmd = alias
477 break
478 break
478 self.shadows = True
479 self.shadows = True
479 except error.UnknownCommand:
480 except error.UnknownCommand:
480 self.shadows = False
481 self.shadows = False
481
482
482 if not self.definition:
483 if not self.definition:
483 self.badalias = _("no definition for alias '%s'") % self.name
484 self.badalias = _("no definition for alias '%s'") % self.name
484 return
485 return
485
486
486 if self.definition.startswith('!'):
487 if self.definition.startswith('!'):
487 shdef = self.definition[1:]
488 shdef = self.definition[1:]
488 self.shell = True
489 self.shell = True
489 def fn(ui, *args):
490 def fn(ui, *args):
490 env = {'HG_ARGS': ' '.join((self.name,) + args)}
491 env = {'HG_ARGS': ' '.join((self.name,) + args)}
491 def _checkvar(m):
492 def _checkvar(m):
492 if m.groups()[0] == '$':
493 if m.groups()[0] == '$':
493 return m.group()
494 return m.group()
494 elif int(m.groups()[0]) <= len(args):
495 elif int(m.groups()[0]) <= len(args):
495 return m.group()
496 return m.group()
496 else:
497 else:
497 ui.debug("No argument found for substitution "
498 ui.debug("No argument found for substitution "
498 "of %i variable in alias '%s' definition.\n"
499 "of %i variable in alias '%s' definition.\n"
499 % (int(m.groups()[0]), self.name))
500 % (int(m.groups()[0]), self.name))
500 return ''
501 return ''
501 cmd = re.sub(br'\$(\d+|\$)', _checkvar, shdef)
502 cmd = re.sub(br'\$(\d+|\$)', _checkvar, shdef)
502 cmd = aliasinterpolate(self.name, args, cmd)
503 cmd = aliasinterpolate(self.name, args, cmd)
503 return ui.system(cmd, environ=env,
504 return ui.system(cmd, environ=env,
504 blockedtag='alias_%s' % self.name)
505 blockedtag='alias_%s' % self.name)
505 self.fn = fn
506 self.fn = fn
507 self.alias = True
506 self._populatehelp(ui, name, shdef, self.fn)
508 self._populatehelp(ui, name, shdef, self.fn)
507 return
509 return
508
510
509 try:
511 try:
510 args = pycompat.shlexsplit(self.definition)
512 args = pycompat.shlexsplit(self.definition)
511 except ValueError as inst:
513 except ValueError as inst:
512 self.badalias = (_("error in definition for alias '%s': %s")
514 self.badalias = (_("error in definition for alias '%s': %s")
513 % (self.name, stringutil.forcebytestr(inst)))
515 % (self.name, stringutil.forcebytestr(inst)))
514 return
516 return
515 earlyopts, args = _earlysplitopts(args)
517 earlyopts, args = _earlysplitopts(args)
516 if earlyopts:
518 if earlyopts:
517 self.badalias = (_("error in definition for alias '%s': %s may "
519 self.badalias = (_("error in definition for alias '%s': %s may "
518 "only be given on the command line")
520 "only be given on the command line")
519 % (self.name, '/'.join(pycompat.ziplist(*earlyopts)
521 % (self.name, '/'.join(pycompat.ziplist(*earlyopts)
520 [0])))
522 [0])))
521 return
523 return
522 self.cmdname = cmd = args.pop(0)
524 self.cmdname = cmd = args.pop(0)
523 self.givenargs = args
525 self.givenargs = args
524
526
525 try:
527 try:
526 tableentry = cmdutil.findcmd(cmd, cmdtable, False)[1]
528 tableentry = cmdutil.findcmd(cmd, cmdtable, False)[1]
527 if len(tableentry) > 2:
529 if len(tableentry) > 2:
528 self.fn, self.opts, cmdhelp = tableentry
530 self.fn, self.opts, cmdhelp = tableentry
529 else:
531 else:
530 self.fn, self.opts = tableentry
532 self.fn, self.opts = tableentry
531 cmdhelp = None
533 cmdhelp = None
532
534
535 self.alias = True
533 self._populatehelp(ui, name, cmd, self.fn, cmdhelp)
536 self._populatehelp(ui, name, cmd, self.fn, cmdhelp)
534
537
535 except error.UnknownCommand:
538 except error.UnknownCommand:
536 self.badalias = (_("alias '%s' resolves to unknown command '%s'")
539 self.badalias = (_("alias '%s' resolves to unknown command '%s'")
537 % (self.name, cmd))
540 % (self.name, cmd))
538 self.unknowncmd = True
541 self.unknowncmd = True
539 except error.AmbiguousCommand:
542 except error.AmbiguousCommand:
540 self.badalias = (_("alias '%s' resolves to ambiguous command '%s'")
543 self.badalias = (_("alias '%s' resolves to ambiguous command '%s'")
541 % (self.name, cmd))
544 % (self.name, cmd))
542
545
543 def _populatehelp(self, ui, name, cmd, fn, defaulthelp=None):
546 def _populatehelp(self, ui, name, cmd, fn, defaulthelp=None):
544 # confine strings to be passed to i18n.gettext()
547 # confine strings to be passed to i18n.gettext()
545 cfg = {}
548 cfg = {}
546 for k in ('doc', 'help'):
549 for k in ('doc', 'help', 'category'):
547 v = ui.config('alias', '%s:%s' % (name, k), None)
550 v = ui.config('alias', '%s:%s' % (name, k), None)
548 if v is None:
551 if v is None:
549 continue
552 continue
550 if not encoding.isasciistr(v):
553 if not encoding.isasciistr(v):
551 self.badalias = (_("non-ASCII character in alias definition "
554 self.badalias = (_("non-ASCII character in alias definition "
552 "'%s:%s'") % (name, k))
555 "'%s:%s'") % (name, k))
553 return
556 return
554 cfg[k] = v
557 cfg[k] = v
555
558
556 self.help = cfg.get('help', defaulthelp or '')
559 self.help = cfg.get('help', defaulthelp or '')
557 if self.help and self.help.startswith("hg " + cmd):
560 if self.help and self.help.startswith("hg " + cmd):
558 # drop prefix in old-style help lines so hg shows the alias
561 # drop prefix in old-style help lines so hg shows the alias
559 self.help = self.help[4 + len(cmd):]
562 self.help = self.help[4 + len(cmd):]
560
563
564 self.owndoc = 'doc' in cfg
561 doc = cfg.get('doc', pycompat.getdoc(fn))
565 doc = cfg.get('doc', pycompat.getdoc(fn))
562 if doc is not None:
566 if doc is not None:
563 doc = pycompat.sysstr(doc)
567 doc = pycompat.sysstr(doc)
564 self.__doc__ = doc
568 self.__doc__ = doc
565
569
570 self.helpcategory = cfg.get('category', registrar.command.CATEGORY_NONE)
571
566 @property
572 @property
567 def args(self):
573 def args(self):
568 args = pycompat.maplist(util.expandpath, self.givenargs)
574 args = pycompat.maplist(util.expandpath, self.givenargs)
569 return aliasargs(self.fn, args)
575 return aliasargs(self.fn, args)
570
576
571 def __getattr__(self, name):
577 def __getattr__(self, name):
572 adefaults = {r'norepo': True, r'intents': set(),
578 adefaults = {r'norepo': True, r'intents': set(),
573 r'optionalrepo': False, r'inferrepo': False}
579 r'optionalrepo': False, r'inferrepo': False}
574 if name not in adefaults:
580 if name not in adefaults:
575 raise AttributeError(name)
581 raise AttributeError(name)
576 if self.badalias or util.safehasattr(self, 'shell'):
582 if self.badalias or util.safehasattr(self, 'shell'):
577 return adefaults[name]
583 return adefaults[name]
578 return getattr(self.fn, name)
584 return getattr(self.fn, name)
579
585
580 def __call__(self, ui, *args, **opts):
586 def __call__(self, ui, *args, **opts):
581 if self.badalias:
587 if self.badalias:
582 hint = None
588 hint = None
583 if self.unknowncmd:
589 if self.unknowncmd:
584 try:
590 try:
585 # check if the command is in a disabled extension
591 # check if the command is in a disabled extension
586 cmd, ext = extensions.disabledcmd(ui, self.cmdname)[:2]
592 cmd, ext = extensions.disabledcmd(ui, self.cmdname)[:2]
587 hint = _("'%s' is provided by '%s' extension") % (cmd, ext)
593 hint = _("'%s' is provided by '%s' extension") % (cmd, ext)
588 except error.UnknownCommand:
594 except error.UnknownCommand:
589 pass
595 pass
590 raise error.Abort(self.badalias, hint=hint)
596 raise error.Abort(self.badalias, hint=hint)
591 if self.shadows:
597 if self.shadows:
592 ui.debug("alias '%s' shadows command '%s'\n" %
598 ui.debug("alias '%s' shadows command '%s'\n" %
593 (self.name, self.cmdname))
599 (self.name, self.cmdname))
594
600
595 ui.log('commandalias', "alias '%s' expands to '%s'\n",
601 ui.log('commandalias', "alias '%s' expands to '%s'\n",
596 self.name, self.definition)
602 self.name, self.definition)
597 if util.safehasattr(self, 'shell'):
603 if util.safehasattr(self, 'shell'):
598 return self.fn(ui, *args, **opts)
604 return self.fn(ui, *args, **opts)
599 else:
605 else:
600 try:
606 try:
601 return util.checksignature(self.fn)(ui, *args, **opts)
607 return util.checksignature(self.fn)(ui, *args, **opts)
602 except error.SignatureError:
608 except error.SignatureError:
603 args = ' '.join([self.cmdname] + self.args)
609 args = ' '.join([self.cmdname] + self.args)
604 ui.debug("alias '%s' expands to '%s'\n" % (self.name, args))
610 ui.debug("alias '%s' expands to '%s'\n" % (self.name, args))
605 raise
611 raise
606
612
607 class lazyaliasentry(object):
613 class lazyaliasentry(object):
608 """like a typical command entry (func, opts, help), but is lazy"""
614 """like a typical command entry (func, opts, help), but is lazy"""
609
615
610 def __init__(self, ui, name, definition, cmdtable, source):
616 def __init__(self, ui, name, definition, cmdtable, source):
611 self.ui = ui
617 self.ui = ui
612 self.name = name
618 self.name = name
613 self.definition = definition
619 self.definition = definition
614 self.cmdtable = cmdtable.copy()
620 self.cmdtable = cmdtable.copy()
615 self.source = source
621 self.source = source
622 self.alias = True
616
623
617 @util.propertycache
624 @util.propertycache
618 def _aliasdef(self):
625 def _aliasdef(self):
619 return cmdalias(self.ui, self.name, self.definition, self.cmdtable,
626 return cmdalias(self.ui, self.name, self.definition, self.cmdtable,
620 self.source)
627 self.source)
621
628
622 def __getitem__(self, n):
629 def __getitem__(self, n):
623 aliasdef = self._aliasdef
630 aliasdef = self._aliasdef
624 if n == 0:
631 if n == 0:
625 return aliasdef
632 return aliasdef
626 elif n == 1:
633 elif n == 1:
627 return aliasdef.opts
634 return aliasdef.opts
628 elif n == 2:
635 elif n == 2:
629 return aliasdef.help
636 return aliasdef.help
630 else:
637 else:
631 raise IndexError
638 raise IndexError
632
639
633 def __iter__(self):
640 def __iter__(self):
634 for i in range(3):
641 for i in range(3):
635 yield self[i]
642 yield self[i]
636
643
637 def __len__(self):
644 def __len__(self):
638 return 3
645 return 3
639
646
640 def addaliases(ui, cmdtable):
647 def addaliases(ui, cmdtable):
641 # aliases are processed after extensions have been loaded, so they
648 # aliases are processed after extensions have been loaded, so they
642 # may use extension commands. Aliases can also use other alias definitions,
649 # may use extension commands. Aliases can also use other alias definitions,
643 # but only if they have been defined prior to the current definition.
650 # but only if they have been defined prior to the current definition.
644 for alias, definition in ui.configitems('alias', ignoresub=True):
651 for alias, definition in ui.configitems('alias', ignoresub=True):
645 try:
652 try:
646 if cmdtable[alias].definition == definition:
653 if cmdtable[alias].definition == definition:
647 continue
654 continue
648 except (KeyError, AttributeError):
655 except (KeyError, AttributeError):
649 # definition might not exist or it might not be a cmdalias
656 # definition might not exist or it might not be a cmdalias
650 pass
657 pass
651
658
652 source = ui.configsource('alias', alias)
659 source = ui.configsource('alias', alias)
653 entry = lazyaliasentry(ui, alias, definition, cmdtable, source)
660 entry = lazyaliasentry(ui, alias, definition, cmdtable, source)
654 cmdtable[alias] = entry
661 cmdtable[alias] = entry
655
662
656 def _parse(ui, args):
663 def _parse(ui, args):
657 options = {}
664 options = {}
658 cmdoptions = {}
665 cmdoptions = {}
659
666
660 try:
667 try:
661 args = fancyopts.fancyopts(args, commands.globalopts, options)
668 args = fancyopts.fancyopts(args, commands.globalopts, options)
662 except getopt.GetoptError as inst:
669 except getopt.GetoptError as inst:
663 raise error.CommandError(None, stringutil.forcebytestr(inst))
670 raise error.CommandError(None, stringutil.forcebytestr(inst))
664
671
665 if args:
672 if args:
666 cmd, args = args[0], args[1:]
673 cmd, args = args[0], args[1:]
667 aliases, entry = cmdutil.findcmd(cmd, commands.table,
674 aliases, entry = cmdutil.findcmd(cmd, commands.table,
668 ui.configbool("ui", "strict"))
675 ui.configbool("ui", "strict"))
669 cmd = aliases[0]
676 cmd = aliases[0]
670 args = aliasargs(entry[0], args)
677 args = aliasargs(entry[0], args)
671 defaults = ui.config("defaults", cmd)
678 defaults = ui.config("defaults", cmd)
672 if defaults:
679 if defaults:
673 args = pycompat.maplist(
680 args = pycompat.maplist(
674 util.expandpath, pycompat.shlexsplit(defaults)) + args
681 util.expandpath, pycompat.shlexsplit(defaults)) + args
675 c = list(entry[1])
682 c = list(entry[1])
676 else:
683 else:
677 cmd = None
684 cmd = None
678 c = []
685 c = []
679
686
680 # combine global options into local
687 # combine global options into local
681 for o in commands.globalopts:
688 for o in commands.globalopts:
682 c.append((o[0], o[1], options[o[1]], o[3]))
689 c.append((o[0], o[1], options[o[1]], o[3]))
683
690
684 try:
691 try:
685 args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True)
692 args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True)
686 except getopt.GetoptError as inst:
693 except getopt.GetoptError as inst:
687 raise error.CommandError(cmd, stringutil.forcebytestr(inst))
694 raise error.CommandError(cmd, stringutil.forcebytestr(inst))
688
695
689 # separate global options back out
696 # separate global options back out
690 for o in commands.globalopts:
697 for o in commands.globalopts:
691 n = o[1]
698 n = o[1]
692 options[n] = cmdoptions[n]
699 options[n] = cmdoptions[n]
693 del cmdoptions[n]
700 del cmdoptions[n]
694
701
695 return (cmd, cmd and entry[0] or None, args, options, cmdoptions)
702 return (cmd, cmd and entry[0] or None, args, options, cmdoptions)
696
703
697 def _parseconfig(ui, config):
704 def _parseconfig(ui, config):
698 """parse the --config options from the command line"""
705 """parse the --config options from the command line"""
699 configs = []
706 configs = []
700
707
701 for cfg in config:
708 for cfg in config:
702 try:
709 try:
703 name, value = [cfgelem.strip()
710 name, value = [cfgelem.strip()
704 for cfgelem in cfg.split('=', 1)]
711 for cfgelem in cfg.split('=', 1)]
705 section, name = name.split('.', 1)
712 section, name = name.split('.', 1)
706 if not section or not name:
713 if not section or not name:
707 raise IndexError
714 raise IndexError
708 ui.setconfig(section, name, value, '--config')
715 ui.setconfig(section, name, value, '--config')
709 configs.append((section, name, value))
716 configs.append((section, name, value))
710 except (IndexError, ValueError):
717 except (IndexError, ValueError):
711 raise error.Abort(_('malformed --config option: %r '
718 raise error.Abort(_('malformed --config option: %r '
712 '(use --config section.name=value)')
719 '(use --config section.name=value)')
713 % pycompat.bytestr(cfg))
720 % pycompat.bytestr(cfg))
714
721
715 return configs
722 return configs
716
723
717 def _earlyparseopts(ui, args):
724 def _earlyparseopts(ui, args):
718 options = {}
725 options = {}
719 fancyopts.fancyopts(args, commands.globalopts, options,
726 fancyopts.fancyopts(args, commands.globalopts, options,
720 gnu=not ui.plain('strictflags'), early=True,
727 gnu=not ui.plain('strictflags'), early=True,
721 optaliases={'repository': ['repo']})
728 optaliases={'repository': ['repo']})
722 return options
729 return options
723
730
724 def _earlysplitopts(args):
731 def _earlysplitopts(args):
725 """Split args into a list of possible early options and remainder args"""
732 """Split args into a list of possible early options and remainder args"""
726 shortoptions = 'R:'
733 shortoptions = 'R:'
727 # TODO: perhaps 'debugger' should be included
734 # TODO: perhaps 'debugger' should be included
728 longoptions = ['cwd=', 'repository=', 'repo=', 'config=']
735 longoptions = ['cwd=', 'repository=', 'repo=', 'config=']
729 return fancyopts.earlygetopt(args, shortoptions, longoptions,
736 return fancyopts.earlygetopt(args, shortoptions, longoptions,
730 gnu=True, keepsep=True)
737 gnu=True, keepsep=True)
731
738
732 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
739 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
733 # run pre-hook, and abort if it fails
740 # run pre-hook, and abort if it fails
734 hook.hook(lui, repo, "pre-%s" % cmd, True, args=" ".join(fullargs),
741 hook.hook(lui, repo, "pre-%s" % cmd, True, args=" ".join(fullargs),
735 pats=cmdpats, opts=cmdoptions)
742 pats=cmdpats, opts=cmdoptions)
736 try:
743 try:
737 ret = _runcommand(ui, options, cmd, d)
744 ret = _runcommand(ui, options, cmd, d)
738 # run post-hook, passing command result
745 # run post-hook, passing command result
739 hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
746 hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
740 result=ret, pats=cmdpats, opts=cmdoptions)
747 result=ret, pats=cmdpats, opts=cmdoptions)
741 except Exception:
748 except Exception:
742 # run failure hook and re-raise
749 # run failure hook and re-raise
743 hook.hook(lui, repo, "fail-%s" % cmd, False, args=" ".join(fullargs),
750 hook.hook(lui, repo, "fail-%s" % cmd, False, args=" ".join(fullargs),
744 pats=cmdpats, opts=cmdoptions)
751 pats=cmdpats, opts=cmdoptions)
745 raise
752 raise
746 return ret
753 return ret
747
754
748 def _getlocal(ui, rpath, wd=None):
755 def _getlocal(ui, rpath, wd=None):
749 """Return (path, local ui object) for the given target path.
756 """Return (path, local ui object) for the given target path.
750
757
751 Takes paths in [cwd]/.hg/hgrc into account."
758 Takes paths in [cwd]/.hg/hgrc into account."
752 """
759 """
753 if wd is None:
760 if wd is None:
754 try:
761 try:
755 wd = encoding.getcwd()
762 wd = encoding.getcwd()
756 except OSError as e:
763 except OSError as e:
757 raise error.Abort(_("error getting current working directory: %s") %
764 raise error.Abort(_("error getting current working directory: %s") %
758 encoding.strtolocal(e.strerror))
765 encoding.strtolocal(e.strerror))
759 path = cmdutil.findrepo(wd) or ""
766 path = cmdutil.findrepo(wd) or ""
760 if not path:
767 if not path:
761 lui = ui
768 lui = ui
762 else:
769 else:
763 lui = ui.copy()
770 lui = ui.copy()
764 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
771 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
765
772
766 if rpath:
773 if rpath:
767 path = lui.expandpath(rpath)
774 path = lui.expandpath(rpath)
768 lui = ui.copy()
775 lui = ui.copy()
769 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
776 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
770
777
771 return path, lui
778 return path, lui
772
779
773 def _checkshellalias(lui, ui, args):
780 def _checkshellalias(lui, ui, args):
774 """Return the function to run the shell alias, if it is required"""
781 """Return the function to run the shell alias, if it is required"""
775 options = {}
782 options = {}
776
783
777 try:
784 try:
778 args = fancyopts.fancyopts(args, commands.globalopts, options)
785 args = fancyopts.fancyopts(args, commands.globalopts, options)
779 except getopt.GetoptError:
786 except getopt.GetoptError:
780 return
787 return
781
788
782 if not args:
789 if not args:
783 return
790 return
784
791
785 cmdtable = commands.table
792 cmdtable = commands.table
786
793
787 cmd = args[0]
794 cmd = args[0]
788 try:
795 try:
789 strict = ui.configbool("ui", "strict")
796 strict = ui.configbool("ui", "strict")
790 aliases, entry = cmdutil.findcmd(cmd, cmdtable, strict)
797 aliases, entry = cmdutil.findcmd(cmd, cmdtable, strict)
791 except (error.AmbiguousCommand, error.UnknownCommand):
798 except (error.AmbiguousCommand, error.UnknownCommand):
792 return
799 return
793
800
794 cmd = aliases[0]
801 cmd = aliases[0]
795 fn = entry[0]
802 fn = entry[0]
796
803
797 if cmd and util.safehasattr(fn, 'shell'):
804 if cmd and util.safehasattr(fn, 'shell'):
798 # shell alias shouldn't receive early options which are consumed by hg
805 # shell alias shouldn't receive early options which are consumed by hg
799 _earlyopts, args = _earlysplitopts(args)
806 _earlyopts, args = _earlysplitopts(args)
800 d = lambda: fn(ui, *args[1:])
807 d = lambda: fn(ui, *args[1:])
801 return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d,
808 return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d,
802 [], {})
809 [], {})
803
810
804 def _dispatch(req):
811 def _dispatch(req):
805 args = req.args
812 args = req.args
806 ui = req.ui
813 ui = req.ui
807
814
808 # check for cwd
815 # check for cwd
809 cwd = req.earlyoptions['cwd']
816 cwd = req.earlyoptions['cwd']
810 if cwd:
817 if cwd:
811 os.chdir(cwd)
818 os.chdir(cwd)
812
819
813 rpath = req.earlyoptions['repository']
820 rpath = req.earlyoptions['repository']
814 path, lui = _getlocal(ui, rpath)
821 path, lui = _getlocal(ui, rpath)
815
822
816 uis = {ui, lui}
823 uis = {ui, lui}
817
824
818 if req.repo:
825 if req.repo:
819 uis.add(req.repo.ui)
826 uis.add(req.repo.ui)
820
827
821 if (req.earlyoptions['verbose'] or req.earlyoptions['debug']
828 if (req.earlyoptions['verbose'] or req.earlyoptions['debug']
822 or req.earlyoptions['quiet']):
829 or req.earlyoptions['quiet']):
823 for opt in ('verbose', 'debug', 'quiet'):
830 for opt in ('verbose', 'debug', 'quiet'):
824 val = pycompat.bytestr(bool(req.earlyoptions[opt]))
831 val = pycompat.bytestr(bool(req.earlyoptions[opt]))
825 for ui_ in uis:
832 for ui_ in uis:
826 ui_.setconfig('ui', opt, val, '--' + opt)
833 ui_.setconfig('ui', opt, val, '--' + opt)
827
834
828 if req.earlyoptions['profile']:
835 if req.earlyoptions['profile']:
829 for ui_ in uis:
836 for ui_ in uis:
830 ui_.setconfig('profiling', 'enabled', 'true', '--profile')
837 ui_.setconfig('profiling', 'enabled', 'true', '--profile')
831
838
832 profile = lui.configbool('profiling', 'enabled')
839 profile = lui.configbool('profiling', 'enabled')
833 with profiling.profile(lui, enabled=profile) as profiler:
840 with profiling.profile(lui, enabled=profile) as profiler:
834 # Configure extensions in phases: uisetup, extsetup, cmdtable, and
841 # Configure extensions in phases: uisetup, extsetup, cmdtable, and
835 # reposetup
842 # reposetup
836 extensions.loadall(lui)
843 extensions.loadall(lui)
837 # Propagate any changes to lui.__class__ by extensions
844 # Propagate any changes to lui.__class__ by extensions
838 ui.__class__ = lui.__class__
845 ui.__class__ = lui.__class__
839
846
840 # (uisetup and extsetup are handled in extensions.loadall)
847 # (uisetup and extsetup are handled in extensions.loadall)
841
848
842 # (reposetup is handled in hg.repository)
849 # (reposetup is handled in hg.repository)
843
850
844 addaliases(lui, commands.table)
851 addaliases(lui, commands.table)
845
852
846 # All aliases and commands are completely defined, now.
853 # All aliases and commands are completely defined, now.
847 # Check abbreviation/ambiguity of shell alias.
854 # Check abbreviation/ambiguity of shell alias.
848 shellaliasfn = _checkshellalias(lui, ui, args)
855 shellaliasfn = _checkshellalias(lui, ui, args)
849 if shellaliasfn:
856 if shellaliasfn:
850 return shellaliasfn()
857 return shellaliasfn()
851
858
852 # check for fallback encoding
859 # check for fallback encoding
853 fallback = lui.config('ui', 'fallbackencoding')
860 fallback = lui.config('ui', 'fallbackencoding')
854 if fallback:
861 if fallback:
855 encoding.fallbackencoding = fallback
862 encoding.fallbackencoding = fallback
856
863
857 fullargs = args
864 fullargs = args
858 cmd, func, args, options, cmdoptions = _parse(lui, args)
865 cmd, func, args, options, cmdoptions = _parse(lui, args)
859
866
860 # store the canonical command name in request object for later access
867 # store the canonical command name in request object for later access
861 req.canonical_command = cmd
868 req.canonical_command = cmd
862
869
863 if options["config"] != req.earlyoptions["config"]:
870 if options["config"] != req.earlyoptions["config"]:
864 raise error.Abort(_("option --config may not be abbreviated!"))
871 raise error.Abort(_("option --config may not be abbreviated!"))
865 if options["cwd"] != req.earlyoptions["cwd"]:
872 if options["cwd"] != req.earlyoptions["cwd"]:
866 raise error.Abort(_("option --cwd may not be abbreviated!"))
873 raise error.Abort(_("option --cwd may not be abbreviated!"))
867 if options["repository"] != req.earlyoptions["repository"]:
874 if options["repository"] != req.earlyoptions["repository"]:
868 raise error.Abort(_(
875 raise error.Abort(_(
869 "option -R has to be separated from other options (e.g. not "
876 "option -R has to be separated from other options (e.g. not "
870 "-qR) and --repository may only be abbreviated as --repo!"))
877 "-qR) and --repository may only be abbreviated as --repo!"))
871 if options["debugger"] != req.earlyoptions["debugger"]:
878 if options["debugger"] != req.earlyoptions["debugger"]:
872 raise error.Abort(_("option --debugger may not be abbreviated!"))
879 raise error.Abort(_("option --debugger may not be abbreviated!"))
873 # don't validate --profile/--traceback, which can be enabled from now
880 # don't validate --profile/--traceback, which can be enabled from now
874
881
875 if options["encoding"]:
882 if options["encoding"]:
876 encoding.encoding = options["encoding"]
883 encoding.encoding = options["encoding"]
877 if options["encodingmode"]:
884 if options["encodingmode"]:
878 encoding.encodingmode = options["encodingmode"]
885 encoding.encodingmode = options["encodingmode"]
879 if options["time"]:
886 if options["time"]:
880 def get_times():
887 def get_times():
881 t = os.times()
888 t = os.times()
882 if t[4] == 0.0:
889 if t[4] == 0.0:
883 # Windows leaves this as zero, so use time.clock()
890 # Windows leaves this as zero, so use time.clock()
884 t = (t[0], t[1], t[2], t[3], time.clock())
891 t = (t[0], t[1], t[2], t[3], time.clock())
885 return t
892 return t
886 s = get_times()
893 s = get_times()
887 def print_time():
894 def print_time():
888 t = get_times()
895 t = get_times()
889 ui.warn(
896 ui.warn(
890 _("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
897 _("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
891 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
898 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
892 ui.atexit(print_time)
899 ui.atexit(print_time)
893 if options["profile"]:
900 if options["profile"]:
894 profiler.start()
901 profiler.start()
895
902
896 # if abbreviated version of this were used, take them in account, now
903 # if abbreviated version of this were used, take them in account, now
897 if options['verbose'] or options['debug'] or options['quiet']:
904 if options['verbose'] or options['debug'] or options['quiet']:
898 for opt in ('verbose', 'debug', 'quiet'):
905 for opt in ('verbose', 'debug', 'quiet'):
899 if options[opt] == req.earlyoptions[opt]:
906 if options[opt] == req.earlyoptions[opt]:
900 continue
907 continue
901 val = pycompat.bytestr(bool(options[opt]))
908 val = pycompat.bytestr(bool(options[opt]))
902 for ui_ in uis:
909 for ui_ in uis:
903 ui_.setconfig('ui', opt, val, '--' + opt)
910 ui_.setconfig('ui', opt, val, '--' + opt)
904
911
905 if options['traceback']:
912 if options['traceback']:
906 for ui_ in uis:
913 for ui_ in uis:
907 ui_.setconfig('ui', 'traceback', 'on', '--traceback')
914 ui_.setconfig('ui', 'traceback', 'on', '--traceback')
908
915
909 if options['noninteractive']:
916 if options['noninteractive']:
910 for ui_ in uis:
917 for ui_ in uis:
911 ui_.setconfig('ui', 'interactive', 'off', '-y')
918 ui_.setconfig('ui', 'interactive', 'off', '-y')
912
919
913 if cmdoptions.get('insecure', False):
920 if cmdoptions.get('insecure', False):
914 for ui_ in uis:
921 for ui_ in uis:
915 ui_.insecureconnections = True
922 ui_.insecureconnections = True
916
923
917 # setup color handling before pager, because setting up pager
924 # setup color handling before pager, because setting up pager
918 # might cause incorrect console information
925 # might cause incorrect console information
919 coloropt = options['color']
926 coloropt = options['color']
920 for ui_ in uis:
927 for ui_ in uis:
921 if coloropt:
928 if coloropt:
922 ui_.setconfig('ui', 'color', coloropt, '--color')
929 ui_.setconfig('ui', 'color', coloropt, '--color')
923 color.setup(ui_)
930 color.setup(ui_)
924
931
925 if stringutil.parsebool(options['pager']):
932 if stringutil.parsebool(options['pager']):
926 # ui.pager() expects 'internal-always-' prefix in this case
933 # ui.pager() expects 'internal-always-' prefix in this case
927 ui.pager('internal-always-' + cmd)
934 ui.pager('internal-always-' + cmd)
928 elif options['pager'] != 'auto':
935 elif options['pager'] != 'auto':
929 for ui_ in uis:
936 for ui_ in uis:
930 ui_.disablepager()
937 ui_.disablepager()
931
938
932 if options['version']:
939 if options['version']:
933 return commands.version_(ui)
940 return commands.version_(ui)
934 if options['help']:
941 if options['help']:
935 return commands.help_(ui, cmd, command=cmd is not None)
942 return commands.help_(ui, cmd, command=cmd is not None)
936 elif not cmd:
943 elif not cmd:
937 return commands.help_(ui, 'shortlist')
944 return commands.help_(ui, 'shortlist')
938
945
939 repo = None
946 repo = None
940 cmdpats = args[:]
947 cmdpats = args[:]
941 if not func.norepo:
948 if not func.norepo:
942 # use the repo from the request only if we don't have -R
949 # use the repo from the request only if we don't have -R
943 if not rpath and not cwd:
950 if not rpath and not cwd:
944 repo = req.repo
951 repo = req.repo
945
952
946 if repo:
953 if repo:
947 # set the descriptors of the repo ui to those of ui
954 # set the descriptors of the repo ui to those of ui
948 repo.ui.fin = ui.fin
955 repo.ui.fin = ui.fin
949 repo.ui.fout = ui.fout
956 repo.ui.fout = ui.fout
950 repo.ui.ferr = ui.ferr
957 repo.ui.ferr = ui.ferr
951 else:
958 else:
952 try:
959 try:
953 repo = hg.repository(ui, path=path,
960 repo = hg.repository(ui, path=path,
954 presetupfuncs=req.prereposetups,
961 presetupfuncs=req.prereposetups,
955 intents=func.intents)
962 intents=func.intents)
956 if not repo.local():
963 if not repo.local():
957 raise error.Abort(_("repository '%s' is not local")
964 raise error.Abort(_("repository '%s' is not local")
958 % path)
965 % path)
959 repo.ui.setconfig("bundle", "mainreporoot", repo.root,
966 repo.ui.setconfig("bundle", "mainreporoot", repo.root,
960 'repo')
967 'repo')
961 except error.RequirementError:
968 except error.RequirementError:
962 raise
969 raise
963 except error.RepoError:
970 except error.RepoError:
964 if rpath: # invalid -R path
971 if rpath: # invalid -R path
965 raise
972 raise
966 if not func.optionalrepo:
973 if not func.optionalrepo:
967 if func.inferrepo and args and not path:
974 if func.inferrepo and args and not path:
968 # try to infer -R from command args
975 # try to infer -R from command args
969 repos = pycompat.maplist(cmdutil.findrepo, args)
976 repos = pycompat.maplist(cmdutil.findrepo, args)
970 guess = repos[0]
977 guess = repos[0]
971 if guess and repos.count(guess) == len(repos):
978 if guess and repos.count(guess) == len(repos):
972 req.args = ['--repository', guess] + fullargs
979 req.args = ['--repository', guess] + fullargs
973 req.earlyoptions['repository'] = guess
980 req.earlyoptions['repository'] = guess
974 return _dispatch(req)
981 return _dispatch(req)
975 if not path:
982 if not path:
976 raise error.RepoError(_("no repository found in"
983 raise error.RepoError(_("no repository found in"
977 " '%s' (.hg not found)")
984 " '%s' (.hg not found)")
978 % encoding.getcwd())
985 % encoding.getcwd())
979 raise
986 raise
980 if repo:
987 if repo:
981 ui = repo.ui
988 ui = repo.ui
982 if options['hidden']:
989 if options['hidden']:
983 repo = repo.unfiltered()
990 repo = repo.unfiltered()
984 args.insert(0, repo)
991 args.insert(0, repo)
985 elif rpath:
992 elif rpath:
986 ui.warn(_("warning: --repository ignored\n"))
993 ui.warn(_("warning: --repository ignored\n"))
987
994
988 msg = _formatargs(fullargs)
995 msg = _formatargs(fullargs)
989 ui.log("command", '%s\n', msg)
996 ui.log("command", '%s\n', msg)
990 strcmdopt = pycompat.strkwargs(cmdoptions)
997 strcmdopt = pycompat.strkwargs(cmdoptions)
991 d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
998 d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
992 try:
999 try:
993 return runcommand(lui, repo, cmd, fullargs, ui, options, d,
1000 return runcommand(lui, repo, cmd, fullargs, ui, options, d,
994 cmdpats, cmdoptions)
1001 cmdpats, cmdoptions)
995 finally:
1002 finally:
996 if repo and repo != req.repo:
1003 if repo and repo != req.repo:
997 repo.close()
1004 repo.close()
998
1005
999 def _runcommand(ui, options, cmd, cmdfunc):
1006 def _runcommand(ui, options, cmd, cmdfunc):
1000 """Run a command function, possibly with profiling enabled."""
1007 """Run a command function, possibly with profiling enabled."""
1001 try:
1008 try:
1002 with tracing.log("Running %s command" % cmd):
1009 with tracing.log("Running %s command" % cmd):
1003 return cmdfunc()
1010 return cmdfunc()
1004 except error.SignatureError:
1011 except error.SignatureError:
1005 raise error.CommandError(cmd, _('invalid arguments'))
1012 raise error.CommandError(cmd, _('invalid arguments'))
1006
1013
1007 def _exceptionwarning(ui):
1014 def _exceptionwarning(ui):
1008 """Produce a warning message for the current active exception"""
1015 """Produce a warning message for the current active exception"""
1009
1016
1010 # For compatibility checking, we discard the portion of the hg
1017 # For compatibility checking, we discard the portion of the hg
1011 # version after the + on the assumption that if a "normal
1018 # version after the + on the assumption that if a "normal
1012 # user" is running a build with a + in it the packager
1019 # user" is running a build with a + in it the packager
1013 # probably built from fairly close to a tag and anyone with a
1020 # probably built from fairly close to a tag and anyone with a
1014 # 'make local' copy of hg (where the version number can be out
1021 # 'make local' copy of hg (where the version number can be out
1015 # of date) will be clueful enough to notice the implausible
1022 # of date) will be clueful enough to notice the implausible
1016 # version number and try updating.
1023 # version number and try updating.
1017 ct = util.versiontuple(n=2)
1024 ct = util.versiontuple(n=2)
1018 worst = None, ct, ''
1025 worst = None, ct, ''
1019 if ui.config('ui', 'supportcontact') is None:
1026 if ui.config('ui', 'supportcontact') is None:
1020 for name, mod in extensions.extensions():
1027 for name, mod in extensions.extensions():
1021 # 'testedwith' should be bytes, but not all extensions are ported
1028 # 'testedwith' should be bytes, but not all extensions are ported
1022 # to py3 and we don't want UnicodeException because of that.
1029 # to py3 and we don't want UnicodeException because of that.
1023 testedwith = stringutil.forcebytestr(getattr(mod, 'testedwith', ''))
1030 testedwith = stringutil.forcebytestr(getattr(mod, 'testedwith', ''))
1024 report = getattr(mod, 'buglink', _('the extension author.'))
1031 report = getattr(mod, 'buglink', _('the extension author.'))
1025 if not testedwith.strip():
1032 if not testedwith.strip():
1026 # We found an untested extension. It's likely the culprit.
1033 # We found an untested extension. It's likely the culprit.
1027 worst = name, 'unknown', report
1034 worst = name, 'unknown', report
1028 break
1035 break
1029
1036
1030 # Never blame on extensions bundled with Mercurial.
1037 # Never blame on extensions bundled with Mercurial.
1031 if extensions.ismoduleinternal(mod):
1038 if extensions.ismoduleinternal(mod):
1032 continue
1039 continue
1033
1040
1034 tested = [util.versiontuple(t, 2) for t in testedwith.split()]
1041 tested = [util.versiontuple(t, 2) for t in testedwith.split()]
1035 if ct in tested:
1042 if ct in tested:
1036 continue
1043 continue
1037
1044
1038 lower = [t for t in tested if t < ct]
1045 lower = [t for t in tested if t < ct]
1039 nearest = max(lower or tested)
1046 nearest = max(lower or tested)
1040 if worst[0] is None or nearest < worst[1]:
1047 if worst[0] is None or nearest < worst[1]:
1041 worst = name, nearest, report
1048 worst = name, nearest, report
1042 if worst[0] is not None:
1049 if worst[0] is not None:
1043 name, testedwith, report = worst
1050 name, testedwith, report = worst
1044 if not isinstance(testedwith, (bytes, str)):
1051 if not isinstance(testedwith, (bytes, str)):
1045 testedwith = '.'.join([stringutil.forcebytestr(c)
1052 testedwith = '.'.join([stringutil.forcebytestr(c)
1046 for c in testedwith])
1053 for c in testedwith])
1047 warning = (_('** Unknown exception encountered with '
1054 warning = (_('** Unknown exception encountered with '
1048 'possibly-broken third-party extension %s\n'
1055 'possibly-broken third-party extension %s\n'
1049 '** which supports versions %s of Mercurial.\n'
1056 '** which supports versions %s of Mercurial.\n'
1050 '** Please disable %s and try your action again.\n'
1057 '** Please disable %s and try your action again.\n'
1051 '** If that fixes the bug please report it to %s\n')
1058 '** If that fixes the bug please report it to %s\n')
1052 % (name, testedwith, name, stringutil.forcebytestr(report)))
1059 % (name, testedwith, name, stringutil.forcebytestr(report)))
1053 else:
1060 else:
1054 bugtracker = ui.config('ui', 'supportcontact')
1061 bugtracker = ui.config('ui', 'supportcontact')
1055 if bugtracker is None:
1062 if bugtracker is None:
1056 bugtracker = _("https://mercurial-scm.org/wiki/BugTracker")
1063 bugtracker = _("https://mercurial-scm.org/wiki/BugTracker")
1057 warning = (_("** unknown exception encountered, "
1064 warning = (_("** unknown exception encountered, "
1058 "please report by visiting\n** ") + bugtracker + '\n')
1065 "please report by visiting\n** ") + bugtracker + '\n')
1059 sysversion = pycompat.sysbytes(sys.version).replace('\n', '')
1066 sysversion = pycompat.sysbytes(sys.version).replace('\n', '')
1060 warning += ((_("** Python %s\n") % sysversion) +
1067 warning += ((_("** Python %s\n") % sysversion) +
1061 (_("** Mercurial Distributed SCM (version %s)\n") %
1068 (_("** Mercurial Distributed SCM (version %s)\n") %
1062 util.version()) +
1069 util.version()) +
1063 (_("** Extensions loaded: %s\n") %
1070 (_("** Extensions loaded: %s\n") %
1064 ", ".join([x[0] for x in extensions.extensions()])))
1071 ", ".join([x[0] for x in extensions.extensions()])))
1065 return warning
1072 return warning
1066
1073
1067 def handlecommandexception(ui):
1074 def handlecommandexception(ui):
1068 """Produce a warning message for broken commands
1075 """Produce a warning message for broken commands
1069
1076
1070 Called when handling an exception; the exception is reraised if
1077 Called when handling an exception; the exception is reraised if
1071 this function returns False, ignored otherwise.
1078 this function returns False, ignored otherwise.
1072 """
1079 """
1073 warning = _exceptionwarning(ui)
1080 warning = _exceptionwarning(ui)
1074 ui.log("commandexception", "%s\n%s\n", warning,
1081 ui.log("commandexception", "%s\n%s\n", warning,
1075 pycompat.sysbytes(traceback.format_exc()))
1082 pycompat.sysbytes(traceback.format_exc()))
1076 ui.warn(warning)
1083 ui.warn(warning)
1077 return False # re-raise the exception
1084 return False # re-raise the exception
@@ -1,838 +1,856 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 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import itertools
10 import itertools
11 import os
11 import os
12 import textwrap
12 import textwrap
13
13
14 from .i18n import (
14 from .i18n import (
15 _,
15 _,
16 gettext,
16 gettext,
17 )
17 )
18 from . import (
18 from . import (
19 cmdutil,
19 cmdutil,
20 encoding,
20 encoding,
21 error,
21 error,
22 extensions,
22 extensions,
23 fancyopts,
23 fancyopts,
24 filemerge,
24 filemerge,
25 fileset,
25 fileset,
26 minirst,
26 minirst,
27 pycompat,
27 pycompat,
28 registrar,
28 registrar,
29 revset,
29 revset,
30 templatefilters,
30 templatefilters,
31 templatefuncs,
31 templatefuncs,
32 templatekw,
32 templatekw,
33 util,
33 util,
34 )
34 )
35 from .hgweb import (
35 from .hgweb import (
36 webcommands,
36 webcommands,
37 )
37 )
38
38
39 _exclkeywords = {
39 _exclkeywords = {
40 "(ADVANCED)",
40 "(ADVANCED)",
41 "(DEPRECATED)",
41 "(DEPRECATED)",
42 "(EXPERIMENTAL)",
42 "(EXPERIMENTAL)",
43 # i18n: "(ADVANCED)" is a keyword, must be translated consistently
43 # i18n: "(ADVANCED)" is a keyword, must be translated consistently
44 _("(ADVANCED)"),
44 _("(ADVANCED)"),
45 # i18n: "(DEPRECATED)" is a keyword, must be translated consistently
45 # i18n: "(DEPRECATED)" is a keyword, must be translated consistently
46 _("(DEPRECATED)"),
46 _("(DEPRECATED)"),
47 # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently
47 # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently
48 _("(EXPERIMENTAL)"),
48 _("(EXPERIMENTAL)"),
49 }
49 }
50
50
51 # The order in which command categories will be displayed.
51 # The order in which command categories will be displayed.
52 # Extensions with custom categories should insert them into this list
52 # Extensions with custom categories should insert them into this list
53 # after/before the appropriate item, rather than replacing the list or
53 # after/before the appropriate item, rather than replacing the list or
54 # assuming absolute positions.
54 # assuming absolute positions.
55 CATEGORY_ORDER = [
55 CATEGORY_ORDER = [
56 registrar.command.CATEGORY_REPO_CREATION,
56 registrar.command.CATEGORY_REPO_CREATION,
57 registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT,
57 registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT,
58 registrar.command.CATEGORY_COMMITTING,
58 registrar.command.CATEGORY_COMMITTING,
59 registrar.command.CATEGORY_CHANGE_MANAGEMENT,
59 registrar.command.CATEGORY_CHANGE_MANAGEMENT,
60 registrar.command.CATEGORY_CHANGE_ORGANIZATION,
60 registrar.command.CATEGORY_CHANGE_ORGANIZATION,
61 registrar.command.CATEGORY_FILE_CONTENTS,
61 registrar.command.CATEGORY_FILE_CONTENTS,
62 registrar.command.CATEGORY_CHANGE_NAVIGATION ,
62 registrar.command.CATEGORY_CHANGE_NAVIGATION ,
63 registrar.command.CATEGORY_WORKING_DIRECTORY,
63 registrar.command.CATEGORY_WORKING_DIRECTORY,
64 registrar.command.CATEGORY_IMPORT_EXPORT,
64 registrar.command.CATEGORY_IMPORT_EXPORT,
65 registrar.command.CATEGORY_MAINTENANCE,
65 registrar.command.CATEGORY_MAINTENANCE,
66 registrar.command.CATEGORY_HELP,
66 registrar.command.CATEGORY_HELP,
67 registrar.command.CATEGORY_MISC,
67 registrar.command.CATEGORY_MISC,
68 registrar.command.CATEGORY_NONE,
68 registrar.command.CATEGORY_NONE,
69 ]
69 ]
70
70
71 # Human-readable category names. These are translated.
71 # Human-readable category names. These are translated.
72 # Extensions with custom categories should add their names here.
72 # Extensions with custom categories should add their names here.
73 CATEGORY_NAMES = {
73 CATEGORY_NAMES = {
74 registrar.command.CATEGORY_REPO_CREATION: 'Repository creation',
74 registrar.command.CATEGORY_REPO_CREATION: 'Repository creation',
75 registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT:
75 registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT:
76 'Remote repository management',
76 'Remote repository management',
77 registrar.command.CATEGORY_COMMITTING: 'Change creation',
77 registrar.command.CATEGORY_COMMITTING: 'Change creation',
78 registrar.command.CATEGORY_CHANGE_NAVIGATION: 'Change navigation',
78 registrar.command.CATEGORY_CHANGE_NAVIGATION: 'Change navigation',
79 registrar.command.CATEGORY_CHANGE_MANAGEMENT: 'Change manipulation',
79 registrar.command.CATEGORY_CHANGE_MANAGEMENT: 'Change manipulation',
80 registrar.command.CATEGORY_CHANGE_ORGANIZATION: 'Change organization',
80 registrar.command.CATEGORY_CHANGE_ORGANIZATION: 'Change organization',
81 registrar.command.CATEGORY_WORKING_DIRECTORY:
81 registrar.command.CATEGORY_WORKING_DIRECTORY:
82 'Working directory management',
82 'Working directory management',
83 registrar.command.CATEGORY_FILE_CONTENTS: 'File content management',
83 registrar.command.CATEGORY_FILE_CONTENTS: 'File content management',
84 registrar.command.CATEGORY_IMPORT_EXPORT: 'Change import/export',
84 registrar.command.CATEGORY_IMPORT_EXPORT: 'Change import/export',
85 registrar.command.CATEGORY_MAINTENANCE: 'Repository maintenance',
85 registrar.command.CATEGORY_MAINTENANCE: 'Repository maintenance',
86 registrar.command.CATEGORY_HELP: 'Help',
86 registrar.command.CATEGORY_HELP: 'Help',
87 registrar.command.CATEGORY_MISC: 'Miscellaneous commands',
87 registrar.command.CATEGORY_MISC: 'Miscellaneous commands',
88 registrar.command.CATEGORY_NONE: 'Uncategorized commands',
88 registrar.command.CATEGORY_NONE: 'Uncategorized commands',
89 }
89 }
90
90
91 # Topic categories.
91 # Topic categories.
92 TOPIC_CATEGORY_IDS = 'ids'
92 TOPIC_CATEGORY_IDS = 'ids'
93 TOPIC_CATEGORY_OUTPUT = 'output'
93 TOPIC_CATEGORY_OUTPUT = 'output'
94 TOPIC_CATEGORY_CONFIG = 'config'
94 TOPIC_CATEGORY_CONFIG = 'config'
95 TOPIC_CATEGORY_CONCEPTS = 'concepts'
95 TOPIC_CATEGORY_CONCEPTS = 'concepts'
96 TOPIC_CATEGORY_MISC = 'misc'
96 TOPIC_CATEGORY_MISC = 'misc'
97 TOPIC_CATEGORY_NONE = 'none'
97 TOPIC_CATEGORY_NONE = 'none'
98
98
99 # The order in which topic categories will be displayed.
99 # The order in which topic categories will be displayed.
100 # Extensions with custom categories should insert them into this list
100 # Extensions with custom categories should insert them into this list
101 # after/before the appropriate item, rather than replacing the list or
101 # after/before the appropriate item, rather than replacing the list or
102 # assuming absolute positions.
102 # assuming absolute positions.
103 TOPIC_CATEGORY_ORDER = [
103 TOPIC_CATEGORY_ORDER = [
104 TOPIC_CATEGORY_IDS,
104 TOPIC_CATEGORY_IDS,
105 TOPIC_CATEGORY_OUTPUT,
105 TOPIC_CATEGORY_OUTPUT,
106 TOPIC_CATEGORY_CONFIG,
106 TOPIC_CATEGORY_CONFIG,
107 TOPIC_CATEGORY_CONCEPTS,
107 TOPIC_CATEGORY_CONCEPTS,
108 TOPIC_CATEGORY_MISC,
108 TOPIC_CATEGORY_MISC,
109 TOPIC_CATEGORY_NONE,
109 TOPIC_CATEGORY_NONE,
110 ]
110 ]
111
111
112 # Human-readable topic category names. These are translated.
112 # Human-readable topic category names. These are translated.
113 TOPIC_CATEGORY_NAMES = {
113 TOPIC_CATEGORY_NAMES = {
114 TOPIC_CATEGORY_IDS: 'Mercurial identifiers',
114 TOPIC_CATEGORY_IDS: 'Mercurial identifiers',
115 TOPIC_CATEGORY_OUTPUT: 'Mercurial output',
115 TOPIC_CATEGORY_OUTPUT: 'Mercurial output',
116 TOPIC_CATEGORY_CONFIG: 'Mercurial configuration',
116 TOPIC_CATEGORY_CONFIG: 'Mercurial configuration',
117 TOPIC_CATEGORY_CONCEPTS: 'Concepts',
117 TOPIC_CATEGORY_CONCEPTS: 'Concepts',
118 TOPIC_CATEGORY_MISC: 'Miscellaneous',
118 TOPIC_CATEGORY_MISC: 'Miscellaneous',
119 TOPIC_CATEGORY_NONE: 'Uncategorized topics',
119 TOPIC_CATEGORY_NONE: 'Uncategorized topics',
120 TOPIC_CATEGORY_NONE: 'Uncategorized topics',
120 TOPIC_CATEGORY_NONE: 'Uncategorized topics',
121 }
121 }
122
122
123 def listexts(header, exts, indent=1, showdeprecated=False):
123 def listexts(header, exts, indent=1, showdeprecated=False):
124 '''return a text listing of the given extensions'''
124 '''return a text listing of the given extensions'''
125 rst = []
125 rst = []
126 if exts:
126 if exts:
127 for name, desc in sorted(exts.iteritems()):
127 for name, desc in sorted(exts.iteritems()):
128 if not showdeprecated and any(w in desc for w in _exclkeywords):
128 if not showdeprecated and any(w in desc for w in _exclkeywords):
129 continue
129 continue
130 rst.append('%s:%s: %s\n' % (' ' * indent, name, desc))
130 rst.append('%s:%s: %s\n' % (' ' * indent, name, desc))
131 if rst:
131 if rst:
132 rst.insert(0, '\n%s\n\n' % header)
132 rst.insert(0, '\n%s\n\n' % header)
133 return rst
133 return rst
134
134
135 def extshelp(ui):
135 def extshelp(ui):
136 rst = loaddoc('extensions')(ui).splitlines(True)
136 rst = loaddoc('extensions')(ui).splitlines(True)
137 rst.extend(listexts(
137 rst.extend(listexts(
138 _('enabled extensions:'), extensions.enabled(), showdeprecated=True))
138 _('enabled extensions:'), extensions.enabled(), showdeprecated=True))
139 rst.extend(listexts(_('disabled extensions:'), extensions.disabled(),
139 rst.extend(listexts(_('disabled extensions:'), extensions.disabled(),
140 showdeprecated=ui.verbose))
140 showdeprecated=ui.verbose))
141 doc = ''.join(rst)
141 doc = ''.join(rst)
142 return doc
142 return doc
143
143
144 def optrst(header, options, verbose):
144 def optrst(header, options, verbose):
145 data = []
145 data = []
146 multioccur = False
146 multioccur = False
147 for option in options:
147 for option in options:
148 if len(option) == 5:
148 if len(option) == 5:
149 shortopt, longopt, default, desc, optlabel = option
149 shortopt, longopt, default, desc, optlabel = option
150 else:
150 else:
151 shortopt, longopt, default, desc = option
151 shortopt, longopt, default, desc = option
152 optlabel = _("VALUE") # default label
152 optlabel = _("VALUE") # default label
153
153
154 if not verbose and any(w in desc for w in _exclkeywords):
154 if not verbose and any(w in desc for w in _exclkeywords):
155 continue
155 continue
156
156
157 so = ''
157 so = ''
158 if shortopt:
158 if shortopt:
159 so = '-' + shortopt
159 so = '-' + shortopt
160 lo = '--' + longopt
160 lo = '--' + longopt
161
161
162 if isinstance(default, fancyopts.customopt):
162 if isinstance(default, fancyopts.customopt):
163 default = default.getdefaultvalue()
163 default = default.getdefaultvalue()
164 if default and not callable(default):
164 if default and not callable(default):
165 # default is of unknown type, and in Python 2 we abused
165 # default is of unknown type, and in Python 2 we abused
166 # the %s-shows-repr property to handle integers etc. To
166 # the %s-shows-repr property to handle integers etc. To
167 # match that behavior on Python 3, we do str(default) and
167 # match that behavior on Python 3, we do str(default) and
168 # then convert it to bytes.
168 # then convert it to bytes.
169 desc += _(" (default: %s)") % pycompat.bytestr(default)
169 desc += _(" (default: %s)") % pycompat.bytestr(default)
170
170
171 if isinstance(default, list):
171 if isinstance(default, list):
172 lo += " %s [+]" % optlabel
172 lo += " %s [+]" % optlabel
173 multioccur = True
173 multioccur = True
174 elif (default is not None) and not isinstance(default, bool):
174 elif (default is not None) and not isinstance(default, bool):
175 lo += " %s" % optlabel
175 lo += " %s" % optlabel
176
176
177 data.append((so, lo, desc))
177 data.append((so, lo, desc))
178
178
179 if multioccur:
179 if multioccur:
180 header += (_(" ([+] can be repeated)"))
180 header += (_(" ([+] can be repeated)"))
181
181
182 rst = ['\n%s:\n\n' % header]
182 rst = ['\n%s:\n\n' % header]
183 rst.extend(minirst.maketable(data, 1))
183 rst.extend(minirst.maketable(data, 1))
184
184
185 return ''.join(rst)
185 return ''.join(rst)
186
186
187 def indicateomitted(rst, omitted, notomitted=None):
187 def indicateomitted(rst, omitted, notomitted=None):
188 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted)
188 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted)
189 if notomitted:
189 if notomitted:
190 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted)
190 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted)
191
191
192 def filtercmd(ui, cmd, kw, doc):
192 def filtercmd(ui, cmd, func, kw, doc):
193 if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
193 if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
194 # Debug command, and user is not looking for those.
194 return True
195 return True
195 if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
196 if not ui.verbose:
197 if not kw and not doc:
198 # Command had no documentation, no point in showing it by default.
199 return True
200 if getattr(func, 'alias', False) and not getattr(func, 'owndoc', False):
201 # Alias didn't have its own documentation.
202 return True
203 if doc and any(w in doc for w in _exclkeywords):
204 # Documentation has excluded keywords.
205 return True
206 if kw == "shortlist" and not getattr(func, 'helpbasic', False):
207 # We're presenting the short list but the command is not basic.
196 return True
208 return True
197 if ui.configbool('help', 'hidden-command.%s' % cmd):
209 if ui.configbool('help', 'hidden-command.%s' % cmd):
210 # Configuration explicitly hides the command.
198 return True
211 return True
199 return False
212 return False
200
213
201 def filtertopic(ui, topic):
214 def filtertopic(ui, topic):
202 return ui.configbool('help', 'hidden-topic.%s' % topic, False)
215 return ui.configbool('help', 'hidden-topic.%s' % topic, False)
203
216
204 def topicmatch(ui, commands, kw):
217 def topicmatch(ui, commands, kw):
205 """Return help topics matching kw.
218 """Return help topics matching kw.
206
219
207 Returns {'section': [(name, summary), ...], ...} where section is
220 Returns {'section': [(name, summary), ...], ...} where section is
208 one of topics, commands, extensions, or extensioncommands.
221 one of topics, commands, extensions, or extensioncommands.
209 """
222 """
210 kw = encoding.lower(kw)
223 kw = encoding.lower(kw)
211 def lowercontains(container):
224 def lowercontains(container):
212 return kw in encoding.lower(container) # translated in helptable
225 return kw in encoding.lower(container) # translated in helptable
213 results = {'topics': [],
226 results = {'topics': [],
214 'commands': [],
227 'commands': [],
215 'extensions': [],
228 'extensions': [],
216 'extensioncommands': [],
229 'extensioncommands': [],
217 }
230 }
218 for topic in helptable:
231 for topic in helptable:
219 names, header, doc = topic[0:3]
232 names, header, doc = topic[0:3]
220 # Old extensions may use a str as doc.
233 # Old extensions may use a str as doc.
221 if (sum(map(lowercontains, names))
234 if (sum(map(lowercontains, names))
222 or lowercontains(header)
235 or lowercontains(header)
223 or (callable(doc) and lowercontains(doc(ui)))):
236 or (callable(doc) and lowercontains(doc(ui)))):
224 name = names[0]
237 name = names[0]
225 if not filtertopic(ui, name):
238 if not filtertopic(ui, name):
226 results['topics'].append((names[0], header))
239 results['topics'].append((names[0], header))
227 for cmd, entry in commands.table.iteritems():
240 for cmd, entry in commands.table.iteritems():
228 if len(entry) == 3:
241 if len(entry) == 3:
229 summary = entry[2]
242 summary = entry[2]
230 else:
243 else:
231 summary = ''
244 summary = ''
232 # translate docs *before* searching there
245 # translate docs *before* searching there
233 docs = _(pycompat.getdoc(entry[0])) or ''
246 func = entry[0]
247 docs = _(pycompat.getdoc(func)) or ''
234 if kw in cmd or lowercontains(summary) or lowercontains(docs):
248 if kw in cmd or lowercontains(summary) or lowercontains(docs):
235 doclines = docs.splitlines()
249 doclines = docs.splitlines()
236 if doclines:
250 if doclines:
237 summary = doclines[0]
251 summary = doclines[0]
238 cmdname = cmdutil.parsealiases(cmd)[0]
252 cmdname = cmdutil.parsealiases(cmd)[0]
239 if filtercmd(ui, cmdname, kw, docs):
253 if filtercmd(ui, cmdname, func, kw, docs):
240 continue
254 continue
241 results['commands'].append((cmdname, summary))
255 results['commands'].append((cmdname, summary))
242 for name, docs in itertools.chain(
256 for name, docs in itertools.chain(
243 extensions.enabled(False).iteritems(),
257 extensions.enabled(False).iteritems(),
244 extensions.disabled().iteritems()):
258 extensions.disabled().iteritems()):
245 if not docs:
259 if not docs:
246 continue
260 continue
247 name = name.rpartition('.')[-1]
261 name = name.rpartition('.')[-1]
248 if lowercontains(name) or lowercontains(docs):
262 if lowercontains(name) or lowercontains(docs):
249 # extension docs are already translated
263 # extension docs are already translated
250 results['extensions'].append((name, docs.splitlines()[0]))
264 results['extensions'].append((name, docs.splitlines()[0]))
251 try:
265 try:
252 mod = extensions.load(ui, name, '')
266 mod = extensions.load(ui, name, '')
253 except ImportError:
267 except ImportError:
254 # debug message would be printed in extensions.load()
268 # debug message would be printed in extensions.load()
255 continue
269 continue
256 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
270 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
257 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
271 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
258 cmdname = cmdutil.parsealiases(cmd)[0]
272 cmdname = cmdutil.parsealiases(cmd)[0]
259 cmddoc = pycompat.getdoc(entry[0])
273 func = entry[0]
274 cmddoc = pycompat.getdoc(func)
260 if cmddoc:
275 if cmddoc:
261 cmddoc = gettext(cmddoc).splitlines()[0]
276 cmddoc = gettext(cmddoc).splitlines()[0]
262 else:
277 else:
263 cmddoc = _('(no help text available)')
278 cmddoc = _('(no help text available)')
264 if filtercmd(ui, cmdname, kw, cmddoc):
279 if filtercmd(ui, cmdname, func, kw, cmddoc):
265 continue
280 continue
266 results['extensioncommands'].append((cmdname, cmddoc))
281 results['extensioncommands'].append((cmdname, cmddoc))
267 return results
282 return results
268
283
269 def loaddoc(topic, subdir=None):
284 def loaddoc(topic, subdir=None):
270 """Return a delayed loader for help/topic.txt."""
285 """Return a delayed loader for help/topic.txt."""
271
286
272 def loader(ui):
287 def loader(ui):
273 docdir = os.path.join(util.datapath, 'help')
288 docdir = os.path.join(util.datapath, 'help')
274 if subdir:
289 if subdir:
275 docdir = os.path.join(docdir, subdir)
290 docdir = os.path.join(docdir, subdir)
276 path = os.path.join(docdir, topic + ".txt")
291 path = os.path.join(docdir, topic + ".txt")
277 doc = gettext(util.readfile(path))
292 doc = gettext(util.readfile(path))
278 for rewriter in helphooks.get(topic, []):
293 for rewriter in helphooks.get(topic, []):
279 doc = rewriter(ui, topic, doc)
294 doc = rewriter(ui, topic, doc)
280 return doc
295 return doc
281
296
282 return loader
297 return loader
283
298
284 internalstable = sorted([
299 internalstable = sorted([
285 (['bundle2'], _('Bundle2'),
300 (['bundle2'], _('Bundle2'),
286 loaddoc('bundle2', subdir='internals')),
301 loaddoc('bundle2', subdir='internals')),
287 (['bundles'], _('Bundles'),
302 (['bundles'], _('Bundles'),
288 loaddoc('bundles', subdir='internals')),
303 loaddoc('bundles', subdir='internals')),
289 (['cbor'], _('CBOR'),
304 (['cbor'], _('CBOR'),
290 loaddoc('cbor', subdir='internals')),
305 loaddoc('cbor', subdir='internals')),
291 (['censor'], _('Censor'),
306 (['censor'], _('Censor'),
292 loaddoc('censor', subdir='internals')),
307 loaddoc('censor', subdir='internals')),
293 (['changegroups'], _('Changegroups'),
308 (['changegroups'], _('Changegroups'),
294 loaddoc('changegroups', subdir='internals')),
309 loaddoc('changegroups', subdir='internals')),
295 (['config'], _('Config Registrar'),
310 (['config'], _('Config Registrar'),
296 loaddoc('config', subdir='internals')),
311 loaddoc('config', subdir='internals')),
297 (['requirements'], _('Repository Requirements'),
312 (['requirements'], _('Repository Requirements'),
298 loaddoc('requirements', subdir='internals')),
313 loaddoc('requirements', subdir='internals')),
299 (['revlogs'], _('Revision Logs'),
314 (['revlogs'], _('Revision Logs'),
300 loaddoc('revlogs', subdir='internals')),
315 loaddoc('revlogs', subdir='internals')),
301 (['wireprotocol'], _('Wire Protocol'),
316 (['wireprotocol'], _('Wire Protocol'),
302 loaddoc('wireprotocol', subdir='internals')),
317 loaddoc('wireprotocol', subdir='internals')),
303 (['wireprotocolrpc'], _('Wire Protocol RPC'),
318 (['wireprotocolrpc'], _('Wire Protocol RPC'),
304 loaddoc('wireprotocolrpc', subdir='internals')),
319 loaddoc('wireprotocolrpc', subdir='internals')),
305 (['wireprotocolv2'], _('Wire Protocol Version 2'),
320 (['wireprotocolv2'], _('Wire Protocol Version 2'),
306 loaddoc('wireprotocolv2', subdir='internals')),
321 loaddoc('wireprotocolv2', subdir='internals')),
307 ])
322 ])
308
323
309 def internalshelp(ui):
324 def internalshelp(ui):
310 """Generate the index for the "internals" topic."""
325 """Generate the index for the "internals" topic."""
311 lines = ['To access a subtopic, use "hg help internals.{subtopic-name}"\n',
326 lines = ['To access a subtopic, use "hg help internals.{subtopic-name}"\n',
312 '\n']
327 '\n']
313 for names, header, doc in internalstable:
328 for names, header, doc in internalstable:
314 lines.append(' :%s: %s\n' % (names[0], header))
329 lines.append(' :%s: %s\n' % (names[0], header))
315
330
316 return ''.join(lines)
331 return ''.join(lines)
317
332
318 helptable = sorted([
333 helptable = sorted([
319 (['bundlespec'], _("Bundle File Formats"), loaddoc('bundlespec'),
334 (['bundlespec'], _("Bundle File Formats"), loaddoc('bundlespec'),
320 TOPIC_CATEGORY_CONCEPTS),
335 TOPIC_CATEGORY_CONCEPTS),
321 (['color'], _("Colorizing Outputs"), loaddoc('color'),
336 (['color'], _("Colorizing Outputs"), loaddoc('color'),
322 TOPIC_CATEGORY_OUTPUT),
337 TOPIC_CATEGORY_OUTPUT),
323 (["config", "hgrc"], _("Configuration Files"), loaddoc('config'),
338 (["config", "hgrc"], _("Configuration Files"), loaddoc('config'),
324 TOPIC_CATEGORY_CONFIG),
339 TOPIC_CATEGORY_CONFIG),
325 (['deprecated'], _("Deprecated Features"), loaddoc('deprecated'),
340 (['deprecated'], _("Deprecated Features"), loaddoc('deprecated'),
326 TOPIC_CATEGORY_MISC),
341 TOPIC_CATEGORY_MISC),
327 (["dates"], _("Date Formats"), loaddoc('dates'), TOPIC_CATEGORY_OUTPUT),
342 (["dates"], _("Date Formats"), loaddoc('dates'), TOPIC_CATEGORY_OUTPUT),
328 (["flags"], _("Command-line flags"), loaddoc('flags'),
343 (["flags"], _("Command-line flags"), loaddoc('flags'),
329 TOPIC_CATEGORY_CONFIG),
344 TOPIC_CATEGORY_CONFIG),
330 (["patterns"], _("File Name Patterns"), loaddoc('patterns'),
345 (["patterns"], _("File Name Patterns"), loaddoc('patterns'),
331 TOPIC_CATEGORY_IDS),
346 TOPIC_CATEGORY_IDS),
332 (['environment', 'env'], _('Environment Variables'),
347 (['environment', 'env'], _('Environment Variables'),
333 loaddoc('environment'), TOPIC_CATEGORY_CONFIG),
348 loaddoc('environment'), TOPIC_CATEGORY_CONFIG),
334 (['revisions', 'revs', 'revsets', 'revset', 'multirevs', 'mrevs'],
349 (['revisions', 'revs', 'revsets', 'revset', 'multirevs', 'mrevs'],
335 _('Specifying Revisions'), loaddoc('revisions'), TOPIC_CATEGORY_IDS),
350 _('Specifying Revisions'), loaddoc('revisions'), TOPIC_CATEGORY_IDS),
336 (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets'),
351 (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets'),
337 TOPIC_CATEGORY_IDS),
352 TOPIC_CATEGORY_IDS),
338 (['diffs'], _('Diff Formats'), loaddoc('diffs'), TOPIC_CATEGORY_OUTPUT),
353 (['diffs'], _('Diff Formats'), loaddoc('diffs'), TOPIC_CATEGORY_OUTPUT),
339 (['merge-tools', 'mergetools', 'mergetool'], _('Merge Tools'),
354 (['merge-tools', 'mergetools', 'mergetool'], _('Merge Tools'),
340 loaddoc('merge-tools'), TOPIC_CATEGORY_CONFIG),
355 loaddoc('merge-tools'), TOPIC_CATEGORY_CONFIG),
341 (['templating', 'templates', 'template', 'style'], _('Template Usage'),
356 (['templating', 'templates', 'template', 'style'], _('Template Usage'),
342 loaddoc('templates'), TOPIC_CATEGORY_OUTPUT),
357 loaddoc('templates'), TOPIC_CATEGORY_OUTPUT),
343 (['urls'], _('URL Paths'), loaddoc('urls'), TOPIC_CATEGORY_IDS),
358 (['urls'], _('URL Paths'), loaddoc('urls'), TOPIC_CATEGORY_IDS),
344 (["extensions"], _("Using Additional Features"), extshelp,
359 (["extensions"], _("Using Additional Features"), extshelp,
345 TOPIC_CATEGORY_CONFIG),
360 TOPIC_CATEGORY_CONFIG),
346 (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos'),
361 (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos'),
347 TOPIC_CATEGORY_CONCEPTS),
362 TOPIC_CATEGORY_CONCEPTS),
348 (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb'),
363 (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb'),
349 TOPIC_CATEGORY_CONFIG),
364 TOPIC_CATEGORY_CONFIG),
350 (["glossary"], _("Glossary"), loaddoc('glossary'), TOPIC_CATEGORY_CONCEPTS),
365 (["glossary"], _("Glossary"), loaddoc('glossary'), TOPIC_CATEGORY_CONCEPTS),
351 (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"),
366 (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"),
352 loaddoc('hgignore'), TOPIC_CATEGORY_IDS),
367 loaddoc('hgignore'), TOPIC_CATEGORY_IDS),
353 (["phases"], _("Working with Phases"), loaddoc('phases'),
368 (["phases"], _("Working with Phases"), loaddoc('phases'),
354 TOPIC_CATEGORY_CONCEPTS),
369 TOPIC_CATEGORY_CONCEPTS),
355 (['scripting'], _('Using Mercurial from scripts and automation'),
370 (['scripting'], _('Using Mercurial from scripts and automation'),
356 loaddoc('scripting'), TOPIC_CATEGORY_MISC),
371 loaddoc('scripting'), TOPIC_CATEGORY_MISC),
357 (['internals'], _("Technical implementation topics"), internalshelp,
372 (['internals'], _("Technical implementation topics"), internalshelp,
358 TOPIC_CATEGORY_MISC),
373 TOPIC_CATEGORY_MISC),
359 (['pager'], _("Pager Support"), loaddoc('pager'), TOPIC_CATEGORY_CONFIG),
374 (['pager'], _("Pager Support"), loaddoc('pager'), TOPIC_CATEGORY_CONFIG),
360 ])
375 ])
361
376
362 # Maps topics with sub-topics to a list of their sub-topics.
377 # Maps topics with sub-topics to a list of their sub-topics.
363 subtopics = {
378 subtopics = {
364 'internals': internalstable,
379 'internals': internalstable,
365 }
380 }
366
381
367 # Map topics to lists of callable taking the current topic help and
382 # Map topics to lists of callable taking the current topic help and
368 # returning the updated version
383 # returning the updated version
369 helphooks = {}
384 helphooks = {}
370
385
371 def addtopichook(topic, rewriter):
386 def addtopichook(topic, rewriter):
372 helphooks.setdefault(topic, []).append(rewriter)
387 helphooks.setdefault(topic, []).append(rewriter)
373
388
374 def makeitemsdoc(ui, topic, doc, marker, items, dedent=False):
389 def makeitemsdoc(ui, topic, doc, marker, items, dedent=False):
375 """Extract docstring from the items key to function mapping, build a
390 """Extract docstring from the items key to function mapping, build a
376 single documentation block and use it to overwrite the marker in doc.
391 single documentation block and use it to overwrite the marker in doc.
377 """
392 """
378 entries = []
393 entries = []
379 for name in sorted(items):
394 for name in sorted(items):
380 text = (pycompat.getdoc(items[name]) or '').rstrip()
395 text = (pycompat.getdoc(items[name]) or '').rstrip()
381 if (not text
396 if (not text
382 or not ui.verbose and any(w in text for w in _exclkeywords)):
397 or not ui.verbose and any(w in text for w in _exclkeywords)):
383 continue
398 continue
384 text = gettext(text)
399 text = gettext(text)
385 if dedent:
400 if dedent:
386 # Abuse latin1 to use textwrap.dedent() on bytes.
401 # Abuse latin1 to use textwrap.dedent() on bytes.
387 text = textwrap.dedent(text.decode('latin1')).encode('latin1')
402 text = textwrap.dedent(text.decode('latin1')).encode('latin1')
388 lines = text.splitlines()
403 lines = text.splitlines()
389 doclines = [(lines[0])]
404 doclines = [(lines[0])]
390 for l in lines[1:]:
405 for l in lines[1:]:
391 # Stop once we find some Python doctest
406 # Stop once we find some Python doctest
392 if l.strip().startswith('>>>'):
407 if l.strip().startswith('>>>'):
393 break
408 break
394 if dedent:
409 if dedent:
395 doclines.append(l.rstrip())
410 doclines.append(l.rstrip())
396 else:
411 else:
397 doclines.append(' ' + l.strip())
412 doclines.append(' ' + l.strip())
398 entries.append('\n'.join(doclines))
413 entries.append('\n'.join(doclines))
399 entries = '\n\n'.join(entries)
414 entries = '\n\n'.join(entries)
400 return doc.replace(marker, entries)
415 return doc.replace(marker, entries)
401
416
402 def addtopicsymbols(topic, marker, symbols, dedent=False):
417 def addtopicsymbols(topic, marker, symbols, dedent=False):
403 def add(ui, topic, doc):
418 def add(ui, topic, doc):
404 return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent)
419 return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent)
405 addtopichook(topic, add)
420 addtopichook(topic, add)
406
421
407 addtopicsymbols('bundlespec', '.. bundlecompressionmarker',
422 addtopicsymbols('bundlespec', '.. bundlecompressionmarker',
408 util.bundlecompressiontopics())
423 util.bundlecompressiontopics())
409 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
424 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
410 addtopicsymbols('merge-tools', '.. internaltoolsmarker',
425 addtopicsymbols('merge-tools', '.. internaltoolsmarker',
411 filemerge.internalsdoc)
426 filemerge.internalsdoc)
412 addtopicsymbols('revisions', '.. predicatesmarker', revset.symbols)
427 addtopicsymbols('revisions', '.. predicatesmarker', revset.symbols)
413 addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords)
428 addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords)
414 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
429 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
415 addtopicsymbols('templates', '.. functionsmarker', templatefuncs.funcs)
430 addtopicsymbols('templates', '.. functionsmarker', templatefuncs.funcs)
416 addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands,
431 addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands,
417 dedent=True)
432 dedent=True)
418
433
419 def help_(ui, commands, name, unknowncmd=False, full=True, subtopic=None,
434 def help_(ui, commands, name, unknowncmd=False, full=True, subtopic=None,
420 **opts):
435 **opts):
421 '''
436 '''
422 Generate the help for 'name' as unformatted restructured text. If
437 Generate the help for 'name' as unformatted restructured text. If
423 'name' is None, describe the commands available.
438 'name' is None, describe the commands available.
424 '''
439 '''
425
440
426 opts = pycompat.byteskwargs(opts)
441 opts = pycompat.byteskwargs(opts)
427
442
428 def helpcmd(name, subtopic=None):
443 def helpcmd(name, subtopic=None):
429 try:
444 try:
430 aliases, entry = cmdutil.findcmd(name, commands.table,
445 aliases, entry = cmdutil.findcmd(name, commands.table,
431 strict=unknowncmd)
446 strict=unknowncmd)
432 except error.AmbiguousCommand as inst:
447 except error.AmbiguousCommand as inst:
433 # py3 fix: except vars can't be used outside the scope of the
448 # py3 fix: except vars can't be used outside the scope of the
434 # except block, nor can be used inside a lambda. python issue4617
449 # except block, nor can be used inside a lambda. python issue4617
435 prefix = inst.args[0]
450 prefix = inst.args[0]
436 select = lambda c: cmdutil.parsealiases(c)[0].startswith(prefix)
451 select = lambda c: cmdutil.parsealiases(c)[0].startswith(prefix)
437 rst = helplist(select)
452 rst = helplist(select)
438 return rst
453 return rst
439
454
440 rst = []
455 rst = []
441
456
442 # check if it's an invalid alias and display its error if it is
457 # check if it's an invalid alias and display its error if it is
443 if getattr(entry[0], 'badalias', None):
458 if getattr(entry[0], 'badalias', None):
444 rst.append(entry[0].badalias + '\n')
459 rst.append(entry[0].badalias + '\n')
445 if entry[0].unknowncmd:
460 if entry[0].unknowncmd:
446 try:
461 try:
447 rst.extend(helpextcmd(entry[0].cmdname))
462 rst.extend(helpextcmd(entry[0].cmdname))
448 except error.UnknownCommand:
463 except error.UnknownCommand:
449 pass
464 pass
450 return rst
465 return rst
451
466
452 # synopsis
467 # synopsis
453 if len(entry) > 2:
468 if len(entry) > 2:
454 if entry[2].startswith('hg'):
469 if entry[2].startswith('hg'):
455 rst.append("%s\n" % entry[2])
470 rst.append("%s\n" % entry[2])
456 else:
471 else:
457 rst.append('hg %s %s\n' % (aliases[0], entry[2]))
472 rst.append('hg %s %s\n' % (aliases[0], entry[2]))
458 else:
473 else:
459 rst.append('hg %s\n' % aliases[0])
474 rst.append('hg %s\n' % aliases[0])
460 # aliases
475 # aliases
461 if full and not ui.quiet and len(aliases) > 1:
476 if full and not ui.quiet and len(aliases) > 1:
462 rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:]))
477 rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:]))
463 rst.append('\n')
478 rst.append('\n')
464
479
465 # description
480 # description
466 doc = gettext(pycompat.getdoc(entry[0]))
481 doc = gettext(pycompat.getdoc(entry[0]))
467 if not doc:
482 if not doc:
468 doc = _("(no help text available)")
483 doc = _("(no help text available)")
469 if util.safehasattr(entry[0], 'definition'): # aliased command
484 if util.safehasattr(entry[0], 'definition'): # aliased command
470 source = entry[0].source
485 source = entry[0].source
471 if entry[0].definition.startswith('!'): # shell alias
486 if entry[0].definition.startswith('!'): # shell alias
472 doc = (_('shell alias for: %s\n\n%s\n\ndefined by: %s\n') %
487 doc = (_('shell alias for: %s\n\n%s\n\ndefined by: %s\n') %
473 (entry[0].definition[1:], doc, source))
488 (entry[0].definition[1:], doc, source))
474 else:
489 else:
475 doc = (_('alias for: hg %s\n\n%s\n\ndefined by: %s\n') %
490 doc = (_('alias for: hg %s\n\n%s\n\ndefined by: %s\n') %
476 (entry[0].definition, doc, source))
491 (entry[0].definition, doc, source))
477 doc = doc.splitlines(True)
492 doc = doc.splitlines(True)
478 if ui.quiet or not full:
493 if ui.quiet or not full:
479 rst.append(doc[0])
494 rst.append(doc[0])
480 else:
495 else:
481 rst.extend(doc)
496 rst.extend(doc)
482 rst.append('\n')
497 rst.append('\n')
483
498
484 # check if this command shadows a non-trivial (multi-line)
499 # check if this command shadows a non-trivial (multi-line)
485 # extension help text
500 # extension help text
486 try:
501 try:
487 mod = extensions.find(name)
502 mod = extensions.find(name)
488 doc = gettext(pycompat.getdoc(mod)) or ''
503 doc = gettext(pycompat.getdoc(mod)) or ''
489 if '\n' in doc.strip():
504 if '\n' in doc.strip():
490 msg = _("(use 'hg help -e %s' to show help for "
505 msg = _("(use 'hg help -e %s' to show help for "
491 "the %s extension)") % (name, name)
506 "the %s extension)") % (name, name)
492 rst.append('\n%s\n' % msg)
507 rst.append('\n%s\n' % msg)
493 except KeyError:
508 except KeyError:
494 pass
509 pass
495
510
496 # options
511 # options
497 if not ui.quiet and entry[1]:
512 if not ui.quiet and entry[1]:
498 rst.append(optrst(_("options"), entry[1], ui.verbose))
513 rst.append(optrst(_("options"), entry[1], ui.verbose))
499
514
500 if ui.verbose:
515 if ui.verbose:
501 rst.append(optrst(_("global options"),
516 rst.append(optrst(_("global options"),
502 commands.globalopts, ui.verbose))
517 commands.globalopts, ui.verbose))
503
518
504 if not ui.verbose:
519 if not ui.verbose:
505 if not full:
520 if not full:
506 rst.append(_("\n(use 'hg %s -h' to show more help)\n")
521 rst.append(_("\n(use 'hg %s -h' to show more help)\n")
507 % name)
522 % name)
508 elif not ui.quiet:
523 elif not ui.quiet:
509 rst.append(_('\n(some details hidden, use --verbose '
524 rst.append(_('\n(some details hidden, use --verbose '
510 'to show complete help)'))
525 'to show complete help)'))
511
526
512 return rst
527 return rst
513
528
514 def helplist(select=None, **opts):
529 def helplist(select=None, **opts):
515 # Category -> list of commands
530 # Category -> list of commands
516 cats = {}
531 cats = {}
517 # Command -> short description
532 # Command -> short description
518 h = {}
533 h = {}
519 # Command -> string showing synonyms
534 # Command -> string showing synonyms
520 syns = {}
535 syns = {}
521 for c, e in commands.table.iteritems():
536 for c, e in commands.table.iteritems():
522 fs = cmdutil.parsealiases(c)
537 fs = cmdutil.parsealiases(c)
523 f = fs[0]
538 f = fs[0]
524 syns[f] = ', '.join(fs)
539 syns[f] = ', '.join(fs)
525 func = e[0]
540 func = e[0]
526 if select and not select(f):
541 if select and not select(f):
527 continue
542 continue
543 # Only list built-in commands (defined in commands.py) and aliases
544 # (defined in dispatch.py), but not any other extensions.
545 # We don't want a circular dependency between this file and
546 # dispatch, so reference that by name.
547 # TODO(rdamazio): Just show commands from all extensions.
528 if (not select and name != 'shortlist' and
548 if (not select and name != 'shortlist' and
529 func.__module__ != commands.__name__):
549 func.__module__ != commands.__name__ and
550 func.__module__ != 'mercurial.dispatch'):
530 continue
551 continue
531 if name == "shortlist":
532 if not getattr(func, 'helpbasic', False):
533 continue
534 doc = pycompat.getdoc(func)
552 doc = pycompat.getdoc(func)
535 if filtercmd(ui, f, name, doc):
553 if filtercmd(ui, f, func, name, doc):
536 continue
554 continue
537 doc = gettext(doc)
555 doc = gettext(doc)
538 if not doc:
556 if not doc:
539 doc = _("(no help text available)")
557 doc = _("(no help text available)")
540 h[f] = doc.splitlines()[0].rstrip()
558 h[f] = doc.splitlines()[0].rstrip()
541
559
542 cat = getattr(func, 'helpcategory', None) or (
560 cat = getattr(func, 'helpcategory', None) or (
543 registrar.command.CATEGORY_NONE)
561 registrar.command.CATEGORY_NONE)
544 cats.setdefault(cat, []).append(f)
562 cats.setdefault(cat, []).append(f)
545
563
546 rst = []
564 rst = []
547 if not h:
565 if not h:
548 if not ui.quiet:
566 if not ui.quiet:
549 rst.append(_('no commands defined\n'))
567 rst.append(_('no commands defined\n'))
550 return rst
568 return rst
551
569
552 # Output top header.
570 # Output top header.
553 if not ui.quiet:
571 if not ui.quiet:
554 if name == "shortlist":
572 if name == "shortlist":
555 rst.append(_('basic commands:\n\n'))
573 rst.append(_('basic commands:\n\n'))
556 elif name == "debug":
574 elif name == "debug":
557 rst.append(_('debug commands (internal and unsupported):\n\n'))
575 rst.append(_('debug commands (internal and unsupported):\n\n'))
558 else:
576 else:
559 rst.append(_('list of commands:\n'))
577 rst.append(_('list of commands:\n'))
560
578
561 def appendcmds(cmds):
579 def appendcmds(cmds):
562 cmds = sorted(cmds)
580 cmds = sorted(cmds)
563 for c in cmds:
581 for c in cmds:
564 if ui.verbose:
582 if ui.verbose:
565 rst.append(" :%s: %s\n" % (syns[c], h[c]))
583 rst.append(" :%s: %s\n" % (syns[c], h[c]))
566 else:
584 else:
567 rst.append(' :%s: %s\n' % (c, h[c]))
585 rst.append(' :%s: %s\n' % (c, h[c]))
568
586
569 if name in ('shortlist', 'debug'):
587 if name in ('shortlist', 'debug'):
570 # List without categories.
588 # List without categories.
571 appendcmds(h)
589 appendcmds(h)
572 else:
590 else:
573 # Check that all categories have an order.
591 # Check that all categories have an order.
574 missing_order = set(cats.keys()) - set(CATEGORY_ORDER)
592 missing_order = set(cats.keys()) - set(CATEGORY_ORDER)
575 if missing_order:
593 if missing_order:
576 ui.develwarn('help categories missing from CATEGORY_ORDER: %s' %
594 ui.develwarn('help categories missing from CATEGORY_ORDER: %s' %
577 missing_order)
595 missing_order)
578
596
579 # List per category.
597 # List per category.
580 for cat in CATEGORY_ORDER:
598 for cat in CATEGORY_ORDER:
581 catfns = cats.get(cat, [])
599 catfns = cats.get(cat, [])
582 if catfns:
600 if catfns:
583 if len(cats) > 1:
601 if len(cats) > 1:
584 catname = gettext(CATEGORY_NAMES[cat])
602 catname = gettext(CATEGORY_NAMES[cat])
585 rst.append("\n%s:\n" % catname)
603 rst.append("\n%s:\n" % catname)
586 rst.append("\n")
604 rst.append("\n")
587 appendcmds(catfns)
605 appendcmds(catfns)
588
606
589 ex = opts.get
607 ex = opts.get
590 anyopts = (ex(r'keyword') or not (ex(r'command') or ex(r'extension')))
608 anyopts = (ex(r'keyword') or not (ex(r'command') or ex(r'extension')))
591 if not name and anyopts:
609 if not name and anyopts:
592 exts = listexts(_('enabled extensions:'), extensions.enabled())
610 exts = listexts(_('enabled extensions:'), extensions.enabled())
593 if exts:
611 if exts:
594 rst.append('\n')
612 rst.append('\n')
595 rst.extend(exts)
613 rst.extend(exts)
596
614
597 rst.append(_("\nadditional help topics:\n"))
615 rst.append(_("\nadditional help topics:\n"))
598 # Group commands by category.
616 # Group commands by category.
599 topiccats = {}
617 topiccats = {}
600 for topic in helptable:
618 for topic in helptable:
601 names, header, doc = topic[0:3]
619 names, header, doc = topic[0:3]
602 if len(topic) > 3 and topic[3]:
620 if len(topic) > 3 and topic[3]:
603 category = topic[3]
621 category = topic[3]
604 else:
622 else:
605 category = TOPIC_CATEGORY_NONE
623 category = TOPIC_CATEGORY_NONE
606
624
607 topicname = names[0]
625 topicname = names[0]
608 if not filtertopic(ui, topicname):
626 if not filtertopic(ui, topicname):
609 topiccats.setdefault(category, []).append(
627 topiccats.setdefault(category, []).append(
610 (topicname, header))
628 (topicname, header))
611
629
612 # Check that all categories have an order.
630 # Check that all categories have an order.
613 missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER)
631 missing_order = set(topiccats.keys()) - set(TOPIC_CATEGORY_ORDER)
614 if missing_order:
632 if missing_order:
615 ui.develwarn(
633 ui.develwarn(
616 'help categories missing from TOPIC_CATEGORY_ORDER: %s' %
634 'help categories missing from TOPIC_CATEGORY_ORDER: %s' %
617 missing_order)
635 missing_order)
618
636
619 # Output topics per category.
637 # Output topics per category.
620 for cat in TOPIC_CATEGORY_ORDER:
638 for cat in TOPIC_CATEGORY_ORDER:
621 topics = topiccats.get(cat, [])
639 topics = topiccats.get(cat, [])
622 if topics:
640 if topics:
623 if len(topiccats) > 1:
641 if len(topiccats) > 1:
624 catname = gettext(TOPIC_CATEGORY_NAMES[cat])
642 catname = gettext(TOPIC_CATEGORY_NAMES[cat])
625 rst.append("\n%s:\n" % catname)
643 rst.append("\n%s:\n" % catname)
626 rst.append("\n")
644 rst.append("\n")
627 for t, desc in topics:
645 for t, desc in topics:
628 rst.append(" :%s: %s\n" % (t, desc))
646 rst.append(" :%s: %s\n" % (t, desc))
629
647
630 if ui.quiet:
648 if ui.quiet:
631 pass
649 pass
632 elif ui.verbose:
650 elif ui.verbose:
633 rst.append('\n%s\n' % optrst(_("global options"),
651 rst.append('\n%s\n' % optrst(_("global options"),
634 commands.globalopts, ui.verbose))
652 commands.globalopts, ui.verbose))
635 if name == 'shortlist':
653 if name == 'shortlist':
636 rst.append(_("\n(use 'hg help' for the full list "
654 rst.append(_("\n(use 'hg help' for the full list "
637 "of commands)\n"))
655 "of commands)\n"))
638 else:
656 else:
639 if name == 'shortlist':
657 if name == 'shortlist':
640 rst.append(_("\n(use 'hg help' for the full list of commands "
658 rst.append(_("\n(use 'hg help' for the full list of commands "
641 "or 'hg -v' for details)\n"))
659 "or 'hg -v' for details)\n"))
642 elif name and not full:
660 elif name and not full:
643 rst.append(_("\n(use 'hg help %s' to show the full help "
661 rst.append(_("\n(use 'hg help %s' to show the full help "
644 "text)\n") % name)
662 "text)\n") % name)
645 elif name and syns and name in syns.keys():
663 elif name and syns and name in syns.keys():
646 rst.append(_("\n(use 'hg help -v -e %s' to show built-in "
664 rst.append(_("\n(use 'hg help -v -e %s' to show built-in "
647 "aliases and global options)\n") % name)
665 "aliases and global options)\n") % name)
648 else:
666 else:
649 rst.append(_("\n(use 'hg help -v%s' to show built-in aliases "
667 rst.append(_("\n(use 'hg help -v%s' to show built-in aliases "
650 "and global options)\n")
668 "and global options)\n")
651 % (name and " " + name or ""))
669 % (name and " " + name or ""))
652 return rst
670 return rst
653
671
654 def helptopic(name, subtopic=None):
672 def helptopic(name, subtopic=None):
655 # Look for sub-topic entry first.
673 # Look for sub-topic entry first.
656 header, doc = None, None
674 header, doc = None, None
657 if subtopic and name in subtopics:
675 if subtopic and name in subtopics:
658 for names, header, doc in subtopics[name]:
676 for names, header, doc in subtopics[name]:
659 if subtopic in names:
677 if subtopic in names:
660 break
678 break
661
679
662 if not header:
680 if not header:
663 for topic in helptable:
681 for topic in helptable:
664 names, header, doc = topic[0:3]
682 names, header, doc = topic[0:3]
665 if name in names:
683 if name in names:
666 break
684 break
667 else:
685 else:
668 raise error.UnknownCommand(name)
686 raise error.UnknownCommand(name)
669
687
670 rst = [minirst.section(header)]
688 rst = [minirst.section(header)]
671
689
672 # description
690 # description
673 if not doc:
691 if not doc:
674 rst.append(" %s\n" % _("(no help text available)"))
692 rst.append(" %s\n" % _("(no help text available)"))
675 if callable(doc):
693 if callable(doc):
676 rst += [" %s\n" % l for l in doc(ui).splitlines()]
694 rst += [" %s\n" % l for l in doc(ui).splitlines()]
677
695
678 if not ui.verbose:
696 if not ui.verbose:
679 omitted = _('(some details hidden, use --verbose'
697 omitted = _('(some details hidden, use --verbose'
680 ' to show complete help)')
698 ' to show complete help)')
681 indicateomitted(rst, omitted)
699 indicateomitted(rst, omitted)
682
700
683 try:
701 try:
684 cmdutil.findcmd(name, commands.table)
702 cmdutil.findcmd(name, commands.table)
685 rst.append(_("\nuse 'hg help -c %s' to see help for "
703 rst.append(_("\nuse 'hg help -c %s' to see help for "
686 "the %s command\n") % (name, name))
704 "the %s command\n") % (name, name))
687 except error.UnknownCommand:
705 except error.UnknownCommand:
688 pass
706 pass
689 return rst
707 return rst
690
708
691 def helpext(name, subtopic=None):
709 def helpext(name, subtopic=None):
692 try:
710 try:
693 mod = extensions.find(name)
711 mod = extensions.find(name)
694 doc = gettext(pycompat.getdoc(mod)) or _('no help text available')
712 doc = gettext(pycompat.getdoc(mod)) or _('no help text available')
695 except KeyError:
713 except KeyError:
696 mod = None
714 mod = None
697 doc = extensions.disabledext(name)
715 doc = extensions.disabledext(name)
698 if not doc:
716 if not doc:
699 raise error.UnknownCommand(name)
717 raise error.UnknownCommand(name)
700
718
701 if '\n' not in doc:
719 if '\n' not in doc:
702 head, tail = doc, ""
720 head, tail = doc, ""
703 else:
721 else:
704 head, tail = doc.split('\n', 1)
722 head, tail = doc.split('\n', 1)
705 rst = [_('%s extension - %s\n\n') % (name.rpartition('.')[-1], head)]
723 rst = [_('%s extension - %s\n\n') % (name.rpartition('.')[-1], head)]
706 if tail:
724 if tail:
707 rst.extend(tail.splitlines(True))
725 rst.extend(tail.splitlines(True))
708 rst.append('\n')
726 rst.append('\n')
709
727
710 if not ui.verbose:
728 if not ui.verbose:
711 omitted = _('(some details hidden, use --verbose'
729 omitted = _('(some details hidden, use --verbose'
712 ' to show complete help)')
730 ' to show complete help)')
713 indicateomitted(rst, omitted)
731 indicateomitted(rst, omitted)
714
732
715 if mod:
733 if mod:
716 try:
734 try:
717 ct = mod.cmdtable
735 ct = mod.cmdtable
718 except AttributeError:
736 except AttributeError:
719 ct = {}
737 ct = {}
720 modcmds = set([c.partition('|')[0] for c in ct])
738 modcmds = set([c.partition('|')[0] for c in ct])
721 rst.extend(helplist(modcmds.__contains__))
739 rst.extend(helplist(modcmds.__contains__))
722 else:
740 else:
723 rst.append(_("(use 'hg help extensions' for information on enabling"
741 rst.append(_("(use 'hg help extensions' for information on enabling"
724 " extensions)\n"))
742 " extensions)\n"))
725 return rst
743 return rst
726
744
727 def helpextcmd(name, subtopic=None):
745 def helpextcmd(name, subtopic=None):
728 cmd, ext, doc = extensions.disabledcmd(ui, name,
746 cmd, ext, doc = extensions.disabledcmd(ui, name,
729 ui.configbool('ui', 'strict'))
747 ui.configbool('ui', 'strict'))
730 doc = doc.splitlines()[0]
748 doc = doc.splitlines()[0]
731
749
732 rst = listexts(_("'%s' is provided by the following "
750 rst = listexts(_("'%s' is provided by the following "
733 "extension:") % cmd, {ext: doc}, indent=4,
751 "extension:") % cmd, {ext: doc}, indent=4,
734 showdeprecated=True)
752 showdeprecated=True)
735 rst.append('\n')
753 rst.append('\n')
736 rst.append(_("(use 'hg help extensions' for information on enabling "
754 rst.append(_("(use 'hg help extensions' for information on enabling "
737 "extensions)\n"))
755 "extensions)\n"))
738 return rst
756 return rst
739
757
740
758
741 rst = []
759 rst = []
742 kw = opts.get('keyword')
760 kw = opts.get('keyword')
743 if kw or name is None and any(opts[o] for o in opts):
761 if kw or name is None and any(opts[o] for o in opts):
744 matches = topicmatch(ui, commands, name or '')
762 matches = topicmatch(ui, commands, name or '')
745 helpareas = []
763 helpareas = []
746 if opts.get('extension'):
764 if opts.get('extension'):
747 helpareas += [('extensions', _('Extensions'))]
765 helpareas += [('extensions', _('Extensions'))]
748 if opts.get('command'):
766 if opts.get('command'):
749 helpareas += [('commands', _('Commands'))]
767 helpareas += [('commands', _('Commands'))]
750 if not helpareas:
768 if not helpareas:
751 helpareas = [('topics', _('Topics')),
769 helpareas = [('topics', _('Topics')),
752 ('commands', _('Commands')),
770 ('commands', _('Commands')),
753 ('extensions', _('Extensions')),
771 ('extensions', _('Extensions')),
754 ('extensioncommands', _('Extension Commands'))]
772 ('extensioncommands', _('Extension Commands'))]
755 for t, title in helpareas:
773 for t, title in helpareas:
756 if matches[t]:
774 if matches[t]:
757 rst.append('%s:\n\n' % title)
775 rst.append('%s:\n\n' % title)
758 rst.extend(minirst.maketable(sorted(matches[t]), 1))
776 rst.extend(minirst.maketable(sorted(matches[t]), 1))
759 rst.append('\n')
777 rst.append('\n')
760 if not rst:
778 if not rst:
761 msg = _('no matches')
779 msg = _('no matches')
762 hint = _("try 'hg help' for a list of topics")
780 hint = _("try 'hg help' for a list of topics")
763 raise error.Abort(msg, hint=hint)
781 raise error.Abort(msg, hint=hint)
764 elif name and name != 'shortlist':
782 elif name and name != 'shortlist':
765 queries = []
783 queries = []
766 if unknowncmd:
784 if unknowncmd:
767 queries += [helpextcmd]
785 queries += [helpextcmd]
768 if opts.get('extension'):
786 if opts.get('extension'):
769 queries += [helpext]
787 queries += [helpext]
770 if opts.get('command'):
788 if opts.get('command'):
771 queries += [helpcmd]
789 queries += [helpcmd]
772 if not queries:
790 if not queries:
773 queries = (helptopic, helpcmd, helpext, helpextcmd)
791 queries = (helptopic, helpcmd, helpext, helpextcmd)
774 for f in queries:
792 for f in queries:
775 try:
793 try:
776 rst = f(name, subtopic)
794 rst = f(name, subtopic)
777 break
795 break
778 except error.UnknownCommand:
796 except error.UnknownCommand:
779 pass
797 pass
780 else:
798 else:
781 if unknowncmd:
799 if unknowncmd:
782 raise error.UnknownCommand(name)
800 raise error.UnknownCommand(name)
783 else:
801 else:
784 msg = _('no such help topic: %s') % name
802 msg = _('no such help topic: %s') % name
785 hint = _("try 'hg help --keyword %s'") % name
803 hint = _("try 'hg help --keyword %s'") % name
786 raise error.Abort(msg, hint=hint)
804 raise error.Abort(msg, hint=hint)
787 else:
805 else:
788 # program name
806 # program name
789 if not ui.quiet:
807 if not ui.quiet:
790 rst = [_("Mercurial Distributed SCM\n"), '\n']
808 rst = [_("Mercurial Distributed SCM\n"), '\n']
791 rst.extend(helplist(None, **pycompat.strkwargs(opts)))
809 rst.extend(helplist(None, **pycompat.strkwargs(opts)))
792
810
793 return ''.join(rst)
811 return ''.join(rst)
794
812
795 def formattedhelp(ui, commands, fullname, keep=None, unknowncmd=False,
813 def formattedhelp(ui, commands, fullname, keep=None, unknowncmd=False,
796 full=True, **opts):
814 full=True, **opts):
797 """get help for a given topic (as a dotted name) as rendered rst
815 """get help for a given topic (as a dotted name) as rendered rst
798
816
799 Either returns the rendered help text or raises an exception.
817 Either returns the rendered help text or raises an exception.
800 """
818 """
801 if keep is None:
819 if keep is None:
802 keep = []
820 keep = []
803 else:
821 else:
804 keep = list(keep) # make a copy so we can mutate this later
822 keep = list(keep) # make a copy so we can mutate this later
805
823
806 # <fullname> := <name>[.<subtopic][.<section>]
824 # <fullname> := <name>[.<subtopic][.<section>]
807 name = subtopic = section = None
825 name = subtopic = section = None
808 if fullname is not None:
826 if fullname is not None:
809 nameparts = fullname.split('.')
827 nameparts = fullname.split('.')
810 name = nameparts.pop(0)
828 name = nameparts.pop(0)
811 if nameparts and name in subtopics:
829 if nameparts and name in subtopics:
812 subtopic = nameparts.pop(0)
830 subtopic = nameparts.pop(0)
813 if nameparts:
831 if nameparts:
814 section = encoding.lower('.'.join(nameparts))
832 section = encoding.lower('.'.join(nameparts))
815
833
816 textwidth = ui.configint('ui', 'textwidth')
834 textwidth = ui.configint('ui', 'textwidth')
817 termwidth = ui.termwidth() - 2
835 termwidth = ui.termwidth() - 2
818 if textwidth <= 0 or termwidth < textwidth:
836 if textwidth <= 0 or termwidth < textwidth:
819 textwidth = termwidth
837 textwidth = termwidth
820 text = help_(ui, commands, name,
838 text = help_(ui, commands, name,
821 subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts)
839 subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts)
822
840
823 blocks, pruned = minirst.parse(text, keep=keep)
841 blocks, pruned = minirst.parse(text, keep=keep)
824 if 'verbose' in pruned:
842 if 'verbose' in pruned:
825 keep.append('omitted')
843 keep.append('omitted')
826 else:
844 else:
827 keep.append('notomitted')
845 keep.append('notomitted')
828 blocks, pruned = minirst.parse(text, keep=keep)
846 blocks, pruned = minirst.parse(text, keep=keep)
829 if section:
847 if section:
830 blocks = minirst.filtersections(blocks, section)
848 blocks = minirst.filtersections(blocks, section)
831
849
832 # We could have been given a weird ".foo" section without a name
850 # We could have been given a weird ".foo" section without a name
833 # to look for, or we could have simply failed to found "foo.bar"
851 # to look for, or we could have simply failed to found "foo.bar"
834 # because bar isn't a section of foo
852 # because bar isn't a section of foo
835 if section and not (blocks and name):
853 if section and not (blocks and name):
836 raise error.Abort(_("help section not found: %s") % fullname)
854 raise error.Abort(_("help section not found: %s") % fullname)
837
855
838 return minirst.formatplain(blocks, textwidth)
856 return minirst.formatplain(blocks, textwidth)
@@ -1,487 +1,491 b''
1 # registrar.py - utilities to register function for specific purpose
1 # registrar.py - utilities to register function for specific purpose
2 #
2 #
3 # Copyright FUJIWARA Katsunori <foozy@lares.dti.ne.jp> and others
3 # Copyright FUJIWARA Katsunori <foozy@lares.dti.ne.jp> and others
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 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 from . import (
10 from . import (
11 configitems,
11 configitems,
12 error,
12 error,
13 pycompat,
13 pycompat,
14 util,
14 util,
15 )
15 )
16
16
17 # unlike the other registered items, config options are neither functions or
17 # unlike the other registered items, config options are neither functions or
18 # classes. Registering the option is just small function call.
18 # classes. Registering the option is just small function call.
19 #
19 #
20 # We still add the official API to the registrar module for consistency with
20 # We still add the official API to the registrar module for consistency with
21 # the other items extensions want might to register.
21 # the other items extensions want might to register.
22 configitem = configitems.getitemregister
22 configitem = configitems.getitemregister
23
23
24 class _funcregistrarbase(object):
24 class _funcregistrarbase(object):
25 """Base of decorator to register a function for specific purpose
25 """Base of decorator to register a function for specific purpose
26
26
27 This decorator stores decorated functions into own dict 'table'.
27 This decorator stores decorated functions into own dict 'table'.
28
28
29 The least derived class can be defined by overriding 'formatdoc',
29 The least derived class can be defined by overriding 'formatdoc',
30 for example::
30 for example::
31
31
32 class keyword(_funcregistrarbase):
32 class keyword(_funcregistrarbase):
33 _docformat = ":%s: %s"
33 _docformat = ":%s: %s"
34
34
35 This should be used as below:
35 This should be used as below:
36
36
37 keyword = registrar.keyword()
37 keyword = registrar.keyword()
38
38
39 @keyword('bar')
39 @keyword('bar')
40 def barfunc(*args, **kwargs):
40 def barfunc(*args, **kwargs):
41 '''Explanation of bar keyword ....
41 '''Explanation of bar keyword ....
42 '''
42 '''
43 pass
43 pass
44
44
45 In this case:
45 In this case:
46
46
47 - 'barfunc' is stored as 'bar' in '_table' of an instance 'keyword' above
47 - 'barfunc' is stored as 'bar' in '_table' of an instance 'keyword' above
48 - 'barfunc.__doc__' becomes ":bar: Explanation of bar keyword"
48 - 'barfunc.__doc__' becomes ":bar: Explanation of bar keyword"
49 """
49 """
50 def __init__(self, table=None):
50 def __init__(self, table=None):
51 if table is None:
51 if table is None:
52 self._table = {}
52 self._table = {}
53 else:
53 else:
54 self._table = table
54 self._table = table
55
55
56 def __call__(self, decl, *args, **kwargs):
56 def __call__(self, decl, *args, **kwargs):
57 return lambda func: self._doregister(func, decl, *args, **kwargs)
57 return lambda func: self._doregister(func, decl, *args, **kwargs)
58
58
59 def _doregister(self, func, decl, *args, **kwargs):
59 def _doregister(self, func, decl, *args, **kwargs):
60 name = self._getname(decl)
60 name = self._getname(decl)
61
61
62 if name in self._table:
62 if name in self._table:
63 msg = 'duplicate registration for name: "%s"' % name
63 msg = 'duplicate registration for name: "%s"' % name
64 raise error.ProgrammingError(msg)
64 raise error.ProgrammingError(msg)
65
65
66 if func.__doc__ and not util.safehasattr(func, '_origdoc'):
66 if func.__doc__ and not util.safehasattr(func, '_origdoc'):
67 doc = pycompat.sysbytes(func.__doc__).strip()
67 doc = pycompat.sysbytes(func.__doc__).strip()
68 func._origdoc = doc
68 func._origdoc = doc
69 func.__doc__ = pycompat.sysstr(self._formatdoc(decl, doc))
69 func.__doc__ = pycompat.sysstr(self._formatdoc(decl, doc))
70
70
71 self._table[name] = func
71 self._table[name] = func
72 self._extrasetup(name, func, *args, **kwargs)
72 self._extrasetup(name, func, *args, **kwargs)
73
73
74 return func
74 return func
75
75
76 def _parsefuncdecl(self, decl):
76 def _parsefuncdecl(self, decl):
77 """Parse function declaration and return the name of function in it
77 """Parse function declaration and return the name of function in it
78 """
78 """
79 i = decl.find('(')
79 i = decl.find('(')
80 if i >= 0:
80 if i >= 0:
81 return decl[:i]
81 return decl[:i]
82 else:
82 else:
83 return decl
83 return decl
84
84
85 def _getname(self, decl):
85 def _getname(self, decl):
86 """Return the name of the registered function from decl
86 """Return the name of the registered function from decl
87
87
88 Derived class should override this, if it allows more
88 Derived class should override this, if it allows more
89 descriptive 'decl' string than just a name.
89 descriptive 'decl' string than just a name.
90 """
90 """
91 return decl
91 return decl
92
92
93 _docformat = None
93 _docformat = None
94
94
95 def _formatdoc(self, decl, doc):
95 def _formatdoc(self, decl, doc):
96 """Return formatted document of the registered function for help
96 """Return formatted document of the registered function for help
97
97
98 'doc' is '__doc__.strip()' of the registered function.
98 'doc' is '__doc__.strip()' of the registered function.
99 """
99 """
100 return self._docformat % (decl, doc)
100 return self._docformat % (decl, doc)
101
101
102 def _extrasetup(self, name, func):
102 def _extrasetup(self, name, func):
103 """Execute exra setup for registered function, if needed
103 """Execute exra setup for registered function, if needed
104 """
104 """
105
105
106 class command(_funcregistrarbase):
106 class command(_funcregistrarbase):
107 """Decorator to register a command function to table
107 """Decorator to register a command function to table
108
108
109 This class receives a command table as its argument. The table should
109 This class receives a command table as its argument. The table should
110 be a dict.
110 be a dict.
111
111
112 The created object can be used as a decorator for adding commands to
112 The created object can be used as a decorator for adding commands to
113 that command table. This accepts multiple arguments to define a command.
113 that command table. This accepts multiple arguments to define a command.
114
114
115 The first argument is the command name (as bytes).
115 The first argument is the command name (as bytes).
116
116
117 The `options` keyword argument is an iterable of tuples defining command
117 The `options` keyword argument is an iterable of tuples defining command
118 arguments. See ``mercurial.fancyopts.fancyopts()`` for the format of each
118 arguments. See ``mercurial.fancyopts.fancyopts()`` for the format of each
119 tuple.
119 tuple.
120
120
121 The `synopsis` argument defines a short, one line summary of how to use the
121 The `synopsis` argument defines a short, one line summary of how to use the
122 command. This shows up in the help output.
122 command. This shows up in the help output.
123
123
124 There are three arguments that control what repository (if any) is found
124 There are three arguments that control what repository (if any) is found
125 and passed to the decorated function: `norepo`, `optionalrepo`, and
125 and passed to the decorated function: `norepo`, `optionalrepo`, and
126 `inferrepo`.
126 `inferrepo`.
127
127
128 The `norepo` argument defines whether the command does not require a
128 The `norepo` argument defines whether the command does not require a
129 local repository. Most commands operate against a repository, thus the
129 local repository. Most commands operate against a repository, thus the
130 default is False. When True, no repository will be passed.
130 default is False. When True, no repository will be passed.
131
131
132 The `optionalrepo` argument defines whether the command optionally requires
132 The `optionalrepo` argument defines whether the command optionally requires
133 a local repository. If no repository can be found, None will be passed
133 a local repository. If no repository can be found, None will be passed
134 to the decorated function.
134 to the decorated function.
135
135
136 The `inferrepo` argument defines whether to try to find a repository from
136 The `inferrepo` argument defines whether to try to find a repository from
137 the command line arguments. If True, arguments will be examined for
137 the command line arguments. If True, arguments will be examined for
138 potential repository locations. See ``findrepo()``. If a repository is
138 potential repository locations. See ``findrepo()``. If a repository is
139 found, it will be used and passed to the decorated function.
139 found, it will be used and passed to the decorated function.
140
140
141 The `intents` argument defines a set of intended actions or capabilities
141 The `intents` argument defines a set of intended actions or capabilities
142 the command is taking. These intents can be used to affect the construction
142 the command is taking. These intents can be used to affect the construction
143 of the repository object passed to the command. For example, commands
143 of the repository object passed to the command. For example, commands
144 declaring that they are read-only could receive a repository that doesn't
144 declaring that they are read-only could receive a repository that doesn't
145 have any methods allowing repository mutation. Other intents could be used
145 have any methods allowing repository mutation. Other intents could be used
146 to prevent the command from running if the requested intent could not be
146 to prevent the command from running if the requested intent could not be
147 fulfilled.
147 fulfilled.
148
148
149 If `helpcategory` is set (usually to one of the constants in the help
149 If `helpcategory` is set (usually to one of the constants in the help
150 module), the command will be displayed under that category in the help's
150 module), the command will be displayed under that category in the help's
151 list of commands.
151 list of commands.
152
152
153 The following intents are defined:
153 The following intents are defined:
154
154
155 readonly
155 readonly
156 The command is read-only
156 The command is read-only
157
157
158 The signature of the decorated function looks like this:
158 The signature of the decorated function looks like this:
159 def cmd(ui[, repo] [, <args>] [, <options>])
159 def cmd(ui[, repo] [, <args>] [, <options>])
160
160
161 `repo` is required if `norepo` is False.
161 `repo` is required if `norepo` is False.
162 `<args>` are positional args (or `*args`) arguments, of non-option
162 `<args>` are positional args (or `*args`) arguments, of non-option
163 arguments from the command line.
163 arguments from the command line.
164 `<options>` are keyword arguments (or `**options`) of option arguments
164 `<options>` are keyword arguments (or `**options`) of option arguments
165 from the command line.
165 from the command line.
166
166
167 See the WritingExtensions and MercurialApi documentation for more exhaustive
167 See the WritingExtensions and MercurialApi documentation for more exhaustive
168 descriptions and examples.
168 descriptions and examples.
169 """
169 """
170
170
171 # Command categories for grouping them in help output.
171 # Command categories for grouping them in help output.
172 # These can also be specified for aliases, like:
173 # [alias]
174 # myalias = something
175 # myalias:category = repo
172 CATEGORY_REPO_CREATION = 'repo'
176 CATEGORY_REPO_CREATION = 'repo'
173 CATEGORY_REMOTE_REPO_MANAGEMENT = 'remote'
177 CATEGORY_REMOTE_REPO_MANAGEMENT = 'remote'
174 CATEGORY_COMMITTING = 'commit'
178 CATEGORY_COMMITTING = 'commit'
175 CATEGORY_CHANGE_MANAGEMENT = 'management'
179 CATEGORY_CHANGE_MANAGEMENT = 'management'
176 CATEGORY_CHANGE_ORGANIZATION = 'organization'
180 CATEGORY_CHANGE_ORGANIZATION = 'organization'
177 CATEGORY_FILE_CONTENTS = 'files'
181 CATEGORY_FILE_CONTENTS = 'files'
178 CATEGORY_CHANGE_NAVIGATION = 'navigation'
182 CATEGORY_CHANGE_NAVIGATION = 'navigation'
179 CATEGORY_WORKING_DIRECTORY = 'wdir'
183 CATEGORY_WORKING_DIRECTORY = 'wdir'
180 CATEGORY_IMPORT_EXPORT = 'import'
184 CATEGORY_IMPORT_EXPORT = 'import'
181 CATEGORY_MAINTENANCE = 'maintenance'
185 CATEGORY_MAINTENANCE = 'maintenance'
182 CATEGORY_HELP = 'help'
186 CATEGORY_HELP = 'help'
183 CATEGORY_MISC = 'misc'
187 CATEGORY_MISC = 'misc'
184 CATEGORY_NONE = 'none'
188 CATEGORY_NONE = 'none'
185
189
186 def _doregister(self, func, name, options=(), synopsis=None,
190 def _doregister(self, func, name, options=(), synopsis=None,
187 norepo=False, optionalrepo=False, inferrepo=False,
191 norepo=False, optionalrepo=False, inferrepo=False,
188 intents=None, helpcategory=None, helpbasic=False):
192 intents=None, helpcategory=None, helpbasic=False):
189 func.norepo = norepo
193 func.norepo = norepo
190 func.optionalrepo = optionalrepo
194 func.optionalrepo = optionalrepo
191 func.inferrepo = inferrepo
195 func.inferrepo = inferrepo
192 func.intents = intents or set()
196 func.intents = intents or set()
193 func.helpcategory = helpcategory
197 func.helpcategory = helpcategory
194 func.helpbasic = helpbasic
198 func.helpbasic = helpbasic
195 if synopsis:
199 if synopsis:
196 self._table[name] = func, list(options), synopsis
200 self._table[name] = func, list(options), synopsis
197 else:
201 else:
198 self._table[name] = func, list(options)
202 self._table[name] = func, list(options)
199 return func
203 return func
200
204
201 INTENT_READONLY = b'readonly'
205 INTENT_READONLY = b'readonly'
202
206
203 class revsetpredicate(_funcregistrarbase):
207 class revsetpredicate(_funcregistrarbase):
204 """Decorator to register revset predicate
208 """Decorator to register revset predicate
205
209
206 Usage::
210 Usage::
207
211
208 revsetpredicate = registrar.revsetpredicate()
212 revsetpredicate = registrar.revsetpredicate()
209
213
210 @revsetpredicate('mypredicate(arg1, arg2[, arg3])')
214 @revsetpredicate('mypredicate(arg1, arg2[, arg3])')
211 def mypredicatefunc(repo, subset, x):
215 def mypredicatefunc(repo, subset, x):
212 '''Explanation of this revset predicate ....
216 '''Explanation of this revset predicate ....
213 '''
217 '''
214 pass
218 pass
215
219
216 The first string argument is used also in online help.
220 The first string argument is used also in online help.
217
221
218 Optional argument 'safe' indicates whether a predicate is safe for
222 Optional argument 'safe' indicates whether a predicate is safe for
219 DoS attack (False by default).
223 DoS attack (False by default).
220
224
221 Optional argument 'takeorder' indicates whether a predicate function
225 Optional argument 'takeorder' indicates whether a predicate function
222 takes ordering policy as the last argument.
226 takes ordering policy as the last argument.
223
227
224 Optional argument 'weight' indicates the estimated run-time cost, useful
228 Optional argument 'weight' indicates the estimated run-time cost, useful
225 for static optimization, default is 1. Higher weight means more expensive.
229 for static optimization, default is 1. Higher weight means more expensive.
226 Usually, revsets that are fast and return only one revision has a weight of
230 Usually, revsets that are fast and return only one revision has a weight of
227 0.5 (ex. a symbol); revsets with O(changelog) complexity and read only the
231 0.5 (ex. a symbol); revsets with O(changelog) complexity and read only the
228 changelog have weight 10 (ex. author); revsets reading manifest deltas have
232 changelog have weight 10 (ex. author); revsets reading manifest deltas have
229 weight 30 (ex. adds); revset reading manifest contents have weight 100
233 weight 30 (ex. adds); revset reading manifest contents have weight 100
230 (ex. contains). Note: those values are flexible. If the revset has a
234 (ex. contains). Note: those values are flexible. If the revset has a
231 same big-O time complexity as 'contains', but with a smaller constant, it
235 same big-O time complexity as 'contains', but with a smaller constant, it
232 might have a weight of 90.
236 might have a weight of 90.
233
237
234 'revsetpredicate' instance in example above can be used to
238 'revsetpredicate' instance in example above can be used to
235 decorate multiple functions.
239 decorate multiple functions.
236
240
237 Decorated functions are registered automatically at loading
241 Decorated functions are registered automatically at loading
238 extension, if an instance named as 'revsetpredicate' is used for
242 extension, if an instance named as 'revsetpredicate' is used for
239 decorating in extension.
243 decorating in extension.
240
244
241 Otherwise, explicit 'revset.loadpredicate()' is needed.
245 Otherwise, explicit 'revset.loadpredicate()' is needed.
242 """
246 """
243 _getname = _funcregistrarbase._parsefuncdecl
247 _getname = _funcregistrarbase._parsefuncdecl
244 _docformat = "``%s``\n %s"
248 _docformat = "``%s``\n %s"
245
249
246 def _extrasetup(self, name, func, safe=False, takeorder=False, weight=1):
250 def _extrasetup(self, name, func, safe=False, takeorder=False, weight=1):
247 func._safe = safe
251 func._safe = safe
248 func._takeorder = takeorder
252 func._takeorder = takeorder
249 func._weight = weight
253 func._weight = weight
250
254
251 class filesetpredicate(_funcregistrarbase):
255 class filesetpredicate(_funcregistrarbase):
252 """Decorator to register fileset predicate
256 """Decorator to register fileset predicate
253
257
254 Usage::
258 Usage::
255
259
256 filesetpredicate = registrar.filesetpredicate()
260 filesetpredicate = registrar.filesetpredicate()
257
261
258 @filesetpredicate('mypredicate()')
262 @filesetpredicate('mypredicate()')
259 def mypredicatefunc(mctx, x):
263 def mypredicatefunc(mctx, x):
260 '''Explanation of this fileset predicate ....
264 '''Explanation of this fileset predicate ....
261 '''
265 '''
262 pass
266 pass
263
267
264 The first string argument is used also in online help.
268 The first string argument is used also in online help.
265
269
266 Optional argument 'callstatus' indicates whether a predicate
270 Optional argument 'callstatus' indicates whether a predicate
267 implies 'matchctx.status()' at runtime or not (False, by
271 implies 'matchctx.status()' at runtime or not (False, by
268 default).
272 default).
269
273
270 Optional argument 'weight' indicates the estimated run-time cost, useful
274 Optional argument 'weight' indicates the estimated run-time cost, useful
271 for static optimization, default is 1. Higher weight means more expensive.
275 for static optimization, default is 1. Higher weight means more expensive.
272 There are predefined weights in the 'filesetlang' module.
276 There are predefined weights in the 'filesetlang' module.
273
277
274 ====== =============================================================
278 ====== =============================================================
275 Weight Description and examples
279 Weight Description and examples
276 ====== =============================================================
280 ====== =============================================================
277 0.5 basic match patterns (e.g. a symbol)
281 0.5 basic match patterns (e.g. a symbol)
278 10 computing status (e.g. added()) or accessing a few files
282 10 computing status (e.g. added()) or accessing a few files
279 30 reading file content for each (e.g. grep())
283 30 reading file content for each (e.g. grep())
280 50 scanning working directory (ignored())
284 50 scanning working directory (ignored())
281 ====== =============================================================
285 ====== =============================================================
282
286
283 'filesetpredicate' instance in example above can be used to
287 'filesetpredicate' instance in example above can be used to
284 decorate multiple functions.
288 decorate multiple functions.
285
289
286 Decorated functions are registered automatically at loading
290 Decorated functions are registered automatically at loading
287 extension, if an instance named as 'filesetpredicate' is used for
291 extension, if an instance named as 'filesetpredicate' is used for
288 decorating in extension.
292 decorating in extension.
289
293
290 Otherwise, explicit 'fileset.loadpredicate()' is needed.
294 Otherwise, explicit 'fileset.loadpredicate()' is needed.
291 """
295 """
292 _getname = _funcregistrarbase._parsefuncdecl
296 _getname = _funcregistrarbase._parsefuncdecl
293 _docformat = "``%s``\n %s"
297 _docformat = "``%s``\n %s"
294
298
295 def _extrasetup(self, name, func, callstatus=False, weight=1):
299 def _extrasetup(self, name, func, callstatus=False, weight=1):
296 func._callstatus = callstatus
300 func._callstatus = callstatus
297 func._weight = weight
301 func._weight = weight
298
302
299 class _templateregistrarbase(_funcregistrarbase):
303 class _templateregistrarbase(_funcregistrarbase):
300 """Base of decorator to register functions as template specific one
304 """Base of decorator to register functions as template specific one
301 """
305 """
302 _docformat = ":%s: %s"
306 _docformat = ":%s: %s"
303
307
304 class templatekeyword(_templateregistrarbase):
308 class templatekeyword(_templateregistrarbase):
305 """Decorator to register template keyword
309 """Decorator to register template keyword
306
310
307 Usage::
311 Usage::
308
312
309 templatekeyword = registrar.templatekeyword()
313 templatekeyword = registrar.templatekeyword()
310
314
311 # new API (since Mercurial 4.6)
315 # new API (since Mercurial 4.6)
312 @templatekeyword('mykeyword', requires={'repo', 'ctx'})
316 @templatekeyword('mykeyword', requires={'repo', 'ctx'})
313 def mykeywordfunc(context, mapping):
317 def mykeywordfunc(context, mapping):
314 '''Explanation of this template keyword ....
318 '''Explanation of this template keyword ....
315 '''
319 '''
316 pass
320 pass
317
321
318 # old API (DEPRECATED)
322 # old API (DEPRECATED)
319 @templatekeyword('mykeyword')
323 @templatekeyword('mykeyword')
320 def mykeywordfunc(repo, ctx, templ, cache, revcache, **args):
324 def mykeywordfunc(repo, ctx, templ, cache, revcache, **args):
321 '''Explanation of this template keyword ....
325 '''Explanation of this template keyword ....
322 '''
326 '''
323 pass
327 pass
324
328
325 The first string argument is used also in online help.
329 The first string argument is used also in online help.
326
330
327 Optional argument 'requires' should be a collection of resource names
331 Optional argument 'requires' should be a collection of resource names
328 which the template keyword depends on. This also serves as a flag to
332 which the template keyword depends on. This also serves as a flag to
329 switch to the new API. If 'requires' is unspecified, all template
333 switch to the new API. If 'requires' is unspecified, all template
330 keywords and resources are expanded to the function arguments.
334 keywords and resources are expanded to the function arguments.
331
335
332 'templatekeyword' instance in example above can be used to
336 'templatekeyword' instance in example above can be used to
333 decorate multiple functions.
337 decorate multiple functions.
334
338
335 Decorated functions are registered automatically at loading
339 Decorated functions are registered automatically at loading
336 extension, if an instance named as 'templatekeyword' is used for
340 extension, if an instance named as 'templatekeyword' is used for
337 decorating in extension.
341 decorating in extension.
338
342
339 Otherwise, explicit 'templatekw.loadkeyword()' is needed.
343 Otherwise, explicit 'templatekw.loadkeyword()' is needed.
340 """
344 """
341
345
342 def _extrasetup(self, name, func, requires=None):
346 def _extrasetup(self, name, func, requires=None):
343 func._requires = requires
347 func._requires = requires
344
348
345 class templatefilter(_templateregistrarbase):
349 class templatefilter(_templateregistrarbase):
346 """Decorator to register template filer
350 """Decorator to register template filer
347
351
348 Usage::
352 Usage::
349
353
350 templatefilter = registrar.templatefilter()
354 templatefilter = registrar.templatefilter()
351
355
352 @templatefilter('myfilter', intype=bytes)
356 @templatefilter('myfilter', intype=bytes)
353 def myfilterfunc(text):
357 def myfilterfunc(text):
354 '''Explanation of this template filter ....
358 '''Explanation of this template filter ....
355 '''
359 '''
356 pass
360 pass
357
361
358 The first string argument is used also in online help.
362 The first string argument is used also in online help.
359
363
360 Optional argument 'intype' defines the type of the input argument,
364 Optional argument 'intype' defines the type of the input argument,
361 which should be (bytes, int, templateutil.date, or None for any.)
365 which should be (bytes, int, templateutil.date, or None for any.)
362
366
363 'templatefilter' instance in example above can be used to
367 'templatefilter' instance in example above can be used to
364 decorate multiple functions.
368 decorate multiple functions.
365
369
366 Decorated functions are registered automatically at loading
370 Decorated functions are registered automatically at loading
367 extension, if an instance named as 'templatefilter' is used for
371 extension, if an instance named as 'templatefilter' is used for
368 decorating in extension.
372 decorating in extension.
369
373
370 Otherwise, explicit 'templatefilters.loadkeyword()' is needed.
374 Otherwise, explicit 'templatefilters.loadkeyword()' is needed.
371 """
375 """
372
376
373 def _extrasetup(self, name, func, intype=None):
377 def _extrasetup(self, name, func, intype=None):
374 func._intype = intype
378 func._intype = intype
375
379
376 class templatefunc(_templateregistrarbase):
380 class templatefunc(_templateregistrarbase):
377 """Decorator to register template function
381 """Decorator to register template function
378
382
379 Usage::
383 Usage::
380
384
381 templatefunc = registrar.templatefunc()
385 templatefunc = registrar.templatefunc()
382
386
383 @templatefunc('myfunc(arg1, arg2[, arg3])', argspec='arg1 arg2 arg3',
387 @templatefunc('myfunc(arg1, arg2[, arg3])', argspec='arg1 arg2 arg3',
384 requires={'ctx'})
388 requires={'ctx'})
385 def myfuncfunc(context, mapping, args):
389 def myfuncfunc(context, mapping, args):
386 '''Explanation of this template function ....
390 '''Explanation of this template function ....
387 '''
391 '''
388 pass
392 pass
389
393
390 The first string argument is used also in online help.
394 The first string argument is used also in online help.
391
395
392 If optional 'argspec' is defined, the function will receive 'args' as
396 If optional 'argspec' is defined, the function will receive 'args' as
393 a dict of named arguments. Otherwise 'args' is a list of positional
397 a dict of named arguments. Otherwise 'args' is a list of positional
394 arguments.
398 arguments.
395
399
396 Optional argument 'requires' should be a collection of resource names
400 Optional argument 'requires' should be a collection of resource names
397 which the template function depends on.
401 which the template function depends on.
398
402
399 'templatefunc' instance in example above can be used to
403 'templatefunc' instance in example above can be used to
400 decorate multiple functions.
404 decorate multiple functions.
401
405
402 Decorated functions are registered automatically at loading
406 Decorated functions are registered automatically at loading
403 extension, if an instance named as 'templatefunc' is used for
407 extension, if an instance named as 'templatefunc' is used for
404 decorating in extension.
408 decorating in extension.
405
409
406 Otherwise, explicit 'templatefuncs.loadfunction()' is needed.
410 Otherwise, explicit 'templatefuncs.loadfunction()' is needed.
407 """
411 """
408 _getname = _funcregistrarbase._parsefuncdecl
412 _getname = _funcregistrarbase._parsefuncdecl
409
413
410 def _extrasetup(self, name, func, argspec=None, requires=()):
414 def _extrasetup(self, name, func, argspec=None, requires=()):
411 func._argspec = argspec
415 func._argspec = argspec
412 func._requires = requires
416 func._requires = requires
413
417
414 class internalmerge(_funcregistrarbase):
418 class internalmerge(_funcregistrarbase):
415 """Decorator to register in-process merge tool
419 """Decorator to register in-process merge tool
416
420
417 Usage::
421 Usage::
418
422
419 internalmerge = registrar.internalmerge()
423 internalmerge = registrar.internalmerge()
420
424
421 @internalmerge('mymerge', internalmerge.mergeonly,
425 @internalmerge('mymerge', internalmerge.mergeonly,
422 onfailure=None, precheck=None,
426 onfailure=None, precheck=None,
423 binary=False, symlink=False):
427 binary=False, symlink=False):
424 def mymergefunc(repo, mynode, orig, fcd, fco, fca,
428 def mymergefunc(repo, mynode, orig, fcd, fco, fca,
425 toolconf, files, labels=None):
429 toolconf, files, labels=None):
426 '''Explanation of this internal merge tool ....
430 '''Explanation of this internal merge tool ....
427 '''
431 '''
428 return 1, False # means "conflicted", "no deletion needed"
432 return 1, False # means "conflicted", "no deletion needed"
429
433
430 The first string argument is used to compose actual merge tool name,
434 The first string argument is used to compose actual merge tool name,
431 ":name" and "internal:name" (the latter is historical one).
435 ":name" and "internal:name" (the latter is historical one).
432
436
433 The second argument is one of merge types below:
437 The second argument is one of merge types below:
434
438
435 ========== ======== ======== =========
439 ========== ======== ======== =========
436 merge type precheck premerge fullmerge
440 merge type precheck premerge fullmerge
437 ========== ======== ======== =========
441 ========== ======== ======== =========
438 nomerge x x x
442 nomerge x x x
439 mergeonly o x o
443 mergeonly o x o
440 fullmerge o o o
444 fullmerge o o o
441 ========== ======== ======== =========
445 ========== ======== ======== =========
442
446
443 Optional argument 'onfailure' is the format of warning message
447 Optional argument 'onfailure' is the format of warning message
444 to be used at failure of merging (target filename is specified
448 to be used at failure of merging (target filename is specified
445 at formatting). Or, None or so, if warning message should be
449 at formatting). Or, None or so, if warning message should be
446 suppressed.
450 suppressed.
447
451
448 Optional argument 'precheck' is the function to be used
452 Optional argument 'precheck' is the function to be used
449 before actual invocation of internal merge tool itself.
453 before actual invocation of internal merge tool itself.
450 It takes as same arguments as internal merge tool does, other than
454 It takes as same arguments as internal merge tool does, other than
451 'files' and 'labels'. If it returns false value, merging is aborted
455 'files' and 'labels'. If it returns false value, merging is aborted
452 immediately (and file is marked as "unresolved").
456 immediately (and file is marked as "unresolved").
453
457
454 Optional argument 'binary' is a binary files capability of internal
458 Optional argument 'binary' is a binary files capability of internal
455 merge tool. 'nomerge' merge type implies binary=True.
459 merge tool. 'nomerge' merge type implies binary=True.
456
460
457 Optional argument 'symlink' is a symlinks capability of inetrnal
461 Optional argument 'symlink' is a symlinks capability of inetrnal
458 merge function. 'nomerge' merge type implies symlink=True.
462 merge function. 'nomerge' merge type implies symlink=True.
459
463
460 'internalmerge' instance in example above can be used to
464 'internalmerge' instance in example above can be used to
461 decorate multiple functions.
465 decorate multiple functions.
462
466
463 Decorated functions are registered automatically at loading
467 Decorated functions are registered automatically at loading
464 extension, if an instance named as 'internalmerge' is used for
468 extension, if an instance named as 'internalmerge' is used for
465 decorating in extension.
469 decorating in extension.
466
470
467 Otherwise, explicit 'filemerge.loadinternalmerge()' is needed.
471 Otherwise, explicit 'filemerge.loadinternalmerge()' is needed.
468 """
472 """
469 _docformat = "``:%s``\n %s"
473 _docformat = "``:%s``\n %s"
470
474
471 # merge type definitions:
475 # merge type definitions:
472 nomerge = None
476 nomerge = None
473 mergeonly = 'mergeonly' # just the full merge, no premerge
477 mergeonly = 'mergeonly' # just the full merge, no premerge
474 fullmerge = 'fullmerge' # both premerge and merge
478 fullmerge = 'fullmerge' # both premerge and merge
475
479
476 def _extrasetup(self, name, func, mergetype,
480 def _extrasetup(self, name, func, mergetype,
477 onfailure=None, precheck=None,
481 onfailure=None, precheck=None,
478 binary=False, symlink=False):
482 binary=False, symlink=False):
479 func.mergetype = mergetype
483 func.mergetype = mergetype
480 func.onfailure = onfailure
484 func.onfailure = onfailure
481 func.precheck = precheck
485 func.precheck = precheck
482
486
483 binarycap = binary or mergetype == self.nomerge
487 binarycap = binary or mergetype == self.nomerge
484 symlinkcap = symlink or mergetype == self.nomerge
488 symlinkcap = symlink or mergetype == self.nomerge
485
489
486 # actual capabilities, which this internal merge tool has
490 # actual capabilities, which this internal merge tool has
487 func.capabilities = {"binary": binarycap, "symlink": symlinkcap}
491 func.capabilities = {"binary": binarycap, "symlink": symlinkcap}
@@ -1,718 +1,718 b''
1 $ HGFOO=BAR; export HGFOO
1 $ HGFOO=BAR; export HGFOO
2 $ cat >> $HGRCPATH <<EOF
2 $ cat >> $HGRCPATH <<EOF
3 > [alias]
3 > [alias]
4 > # should clobber ci but not commit (issue2993)
4 > # should clobber ci but not commit (issue2993)
5 > ci = version
5 > ci = version
6 > myinit = init
6 > myinit = init
7 > myinit:doc = This is my documented alias for init.
7 > myinit:doc = This is my documented alias for init.
8 > myinit:help = [OPTIONS] [BLA] [BLE]
8 > myinit:help = [OPTIONS] [BLA] [BLE]
9 > mycommit = commit
9 > mycommit = commit
10 > mycommit:doc = This is my alias with only doc.
10 > mycommit:doc = This is my alias with only doc.
11 > optionalrepo = showconfig alias.myinit
11 > optionalrepo = showconfig alias.myinit
12 > cleanstatus = status -c
12 > cleanstatus = status -c
13 > cleanstatus:help = [ONLYHELPHERE]
13 > cleanstatus:help = [ONLYHELPHERE]
14 > unknown = bargle
14 > unknown = bargle
15 > ambiguous = s
15 > ambiguous = s
16 > recursive = recursive
16 > recursive = recursive
17 > disabled = email
17 > disabled = email
18 > nodefinition =
18 > nodefinition =
19 > noclosingquotation = '
19 > noclosingquotation = '
20 > no--cwd = status --cwd elsewhere
20 > no--cwd = status --cwd elsewhere
21 > no-R = status -R elsewhere
21 > no-R = status -R elsewhere
22 > no--repo = status --repo elsewhere
22 > no--repo = status --repo elsewhere
23 > no--repository = status --repository elsewhere
23 > no--repository = status --repository elsewhere
24 > no--config = status --config a.config=1
24 > no--config = status --config a.config=1
25 > mylog = log
25 > mylog = log
26 > lognull = log -r null
26 > lognull = log -r null
27 > lognull:doc = Logs the null rev
27 > lognull:doc = Logs the null rev
28 > lognull:help = foo bar baz
28 > lognull:help = foo bar baz
29 > shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
29 > shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
30 > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
30 > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
31 > dln = lognull --debug
31 > dln = lognull --debug
32 > recursivedoc = dln
32 > recursivedoc = dln
33 > recursivedoc:doc = Logs the null rev in debug mode
33 > recursivedoc:doc = Logs the null rev in debug mode
34 > nousage = rollback
34 > nousage = rollback
35 > put = export -r 0 -o "\$FOO/%R.diff"
35 > put = export -r 0 -o "\$FOO/%R.diff"
36 > blank = !printf '\n'
36 > blank = !printf '\n'
37 > self = !printf '\$0\n'
37 > self = !printf '\$0\n'
38 > echoall = !printf '\$@\n'
38 > echoall = !printf '\$@\n'
39 > echo1 = !printf '\$1\n'
39 > echo1 = !printf '\$1\n'
40 > echo2 = !printf '\$2\n'
40 > echo2 = !printf '\$2\n'
41 > echo13 = !printf '\$1 \$3\n'
41 > echo13 = !printf '\$1 \$3\n'
42 > echotokens = !printf "%s\n" "\$@"
42 > echotokens = !printf "%s\n" "\$@"
43 > count = !hg log -r "\$@" --template=. | wc -c | sed -e 's/ //g'
43 > count = !hg log -r "\$@" --template=. | wc -c | sed -e 's/ //g'
44 > mcount = !hg log \$@ --template=. | wc -c | sed -e 's/ //g'
44 > mcount = !hg log \$@ --template=. | wc -c | sed -e 's/ //g'
45 > rt = root
45 > rt = root
46 > tglog = log -G --template "{rev}:{node|short}: '{desc}' {branches}\n"
46 > tglog = log -G --template "{rev}:{node|short}: '{desc}' {branches}\n"
47 > idalias = id
47 > idalias = id
48 > idaliaslong = id
48 > idaliaslong = id
49 > idaliasshell = !echo test
49 > idaliasshell = !echo test
50 > parentsshell1 = !echo one
50 > parentsshell1 = !echo one
51 > parentsshell2 = !echo two
51 > parentsshell2 = !echo two
52 > escaped1 = !printf 'test\$\$test\n'
52 > escaped1 = !printf 'test\$\$test\n'
53 > escaped2 = !sh -c 'echo "HGFOO is \$\$HGFOO"'
53 > escaped2 = !sh -c 'echo "HGFOO is \$\$HGFOO"'
54 > escaped3 = !sh -c 'echo "\$1 is \$\$\$1"'
54 > escaped3 = !sh -c 'echo "\$1 is \$\$\$1"'
55 > escaped4 = !printf '\$\$0 \$\$@\n'
55 > escaped4 = !printf '\$\$0 \$\$@\n'
56 > exit1 = !sh -c 'exit 1'
56 > exit1 = !sh -c 'exit 1'
57 >
57 >
58 > [defaults]
58 > [defaults]
59 > mylog = -q
59 > mylog = -q
60 > lognull = -q
60 > lognull = -q
61 > log = -v
61 > log = -v
62 > EOF
62 > EOF
63
63
64 basic
64 basic
65
65
66 $ hg myinit alias
66 $ hg myinit alias
67
67
68 help
68 help
69
69
70 $ hg help -c | grep myinit
70 $ hg help -c | grep myinit
71 myinit This is my documented alias for init.
71 myinit This is my documented alias for init.
72 $ hg help -c | grep mycommit
72 $ hg help -c | grep mycommit
73 mycommit This is my alias with only doc.
73 mycommit This is my alias with only doc.
74 $ hg help -c | grep cleanstatus
74 $ hg help -c | grep cleanstatus
75 cleanstatus show changed files in the working directory
75 [1]
76 $ hg help -c | grep lognull
76 $ hg help -c | grep lognull
77 lognull Logs the null rev
77 lognull Logs the null rev
78 $ hg help -c | grep dln
78 $ hg help -c | grep dln
79 dln Logs the null rev
79 [1]
80 $ hg help -c | grep recursivedoc
80 $ hg help -c | grep recursivedoc
81 recursivedoc Logs the null rev in debug mode
81 recursivedoc Logs the null rev in debug mode
82 $ hg help myinit
82 $ hg help myinit
83 hg myinit [OPTIONS] [BLA] [BLE]
83 hg myinit [OPTIONS] [BLA] [BLE]
84
84
85 alias for: hg init
85 alias for: hg init
86
86
87 This is my documented alias for init.
87 This is my documented alias for init.
88
88
89 defined by: * (glob)
89 defined by: * (glob)
90 */* (glob) (?)
90 */* (glob) (?)
91 */* (glob) (?)
91 */* (glob) (?)
92 */* (glob) (?)
92 */* (glob) (?)
93
93
94 options:
94 options:
95
95
96 -e --ssh CMD specify ssh command to use
96 -e --ssh CMD specify ssh command to use
97 --remotecmd CMD specify hg command to run on the remote side
97 --remotecmd CMD specify hg command to run on the remote side
98 --insecure do not verify server certificate (ignoring web.cacerts
98 --insecure do not verify server certificate (ignoring web.cacerts
99 config)
99 config)
100
100
101 (some details hidden, use --verbose to show complete help)
101 (some details hidden, use --verbose to show complete help)
102
102
103 $ hg help mycommit
103 $ hg help mycommit
104 hg mycommit [OPTION]... [FILE]...
104 hg mycommit [OPTION]... [FILE]...
105
105
106 alias for: hg commit
106 alias for: hg commit
107
107
108 This is my alias with only doc.
108 This is my alias with only doc.
109
109
110 defined by: * (glob)
110 defined by: * (glob)
111 */* (glob) (?)
111 */* (glob) (?)
112 */* (glob) (?)
112 */* (glob) (?)
113 */* (glob) (?)
113 */* (glob) (?)
114
114
115 options ([+] can be repeated):
115 options ([+] can be repeated):
116
116
117 -A --addremove mark new/missing files as added/removed before
117 -A --addremove mark new/missing files as added/removed before
118 committing
118 committing
119 --close-branch mark a branch head as closed
119 --close-branch mark a branch head as closed
120 --amend amend the parent of the working directory
120 --amend amend the parent of the working directory
121 -s --secret use the secret phase for committing
121 -s --secret use the secret phase for committing
122 -e --edit invoke editor on commit messages
122 -e --edit invoke editor on commit messages
123 -i --interactive use interactive mode
123 -i --interactive use interactive mode
124 -I --include PATTERN [+] include names matching the given patterns
124 -I --include PATTERN [+] include names matching the given patterns
125 -X --exclude PATTERN [+] exclude names matching the given patterns
125 -X --exclude PATTERN [+] exclude names matching the given patterns
126 -m --message TEXT use text as commit message
126 -m --message TEXT use text as commit message
127 -l --logfile FILE read commit message from file
127 -l --logfile FILE read commit message from file
128 -d --date DATE record the specified date as commit date
128 -d --date DATE record the specified date as commit date
129 -u --user USER record the specified user as committer
129 -u --user USER record the specified user as committer
130 -S --subrepos recurse into subrepositories
130 -S --subrepos recurse into subrepositories
131
131
132 (some details hidden, use --verbose to show complete help)
132 (some details hidden, use --verbose to show complete help)
133
133
134 $ hg help cleanstatus
134 $ hg help cleanstatus
135 hg cleanstatus [ONLYHELPHERE]
135 hg cleanstatus [ONLYHELPHERE]
136
136
137 alias for: hg status -c
137 alias for: hg status -c
138
138
139 show changed files in the working directory
139 show changed files in the working directory
140
140
141 Show status of files in the repository. If names are given, only files
141 Show status of files in the repository. If names are given, only files
142 that match are shown. Files that are clean or ignored or the source of a
142 that match are shown. Files that are clean or ignored or the source of a
143 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
143 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
144 -C/--copies or -A/--all are given. Unless options described with "show
144 -C/--copies or -A/--all are given. Unless options described with "show
145 only ..." are given, the options -mardu are used.
145 only ..." are given, the options -mardu are used.
146
146
147 Option -q/--quiet hides untracked (unknown and ignored) files unless
147 Option -q/--quiet hides untracked (unknown and ignored) files unless
148 explicitly requested with -u/--unknown or -i/--ignored.
148 explicitly requested with -u/--unknown or -i/--ignored.
149
149
150 Note:
150 Note:
151 'hg status' may appear to disagree with diff if permissions have
151 'hg status' may appear to disagree with diff if permissions have
152 changed or a merge has occurred. The standard diff format does not
152 changed or a merge has occurred. The standard diff format does not
153 report permission changes and diff only reports changes relative to one
153 report permission changes and diff only reports changes relative to one
154 merge parent.
154 merge parent.
155
155
156 If one revision is given, it is used as the base revision. If two
156 If one revision is given, it is used as the base revision. If two
157 revisions are given, the differences between them are shown. The --change
157 revisions are given, the differences between them are shown. The --change
158 option can also be used as a shortcut to list the changed files of a
158 option can also be used as a shortcut to list the changed files of a
159 revision from its first parent.
159 revision from its first parent.
160
160
161 The codes used to show the status of files are:
161 The codes used to show the status of files are:
162
162
163 M = modified
163 M = modified
164 A = added
164 A = added
165 R = removed
165 R = removed
166 C = clean
166 C = clean
167 ! = missing (deleted by non-hg command, but still tracked)
167 ! = missing (deleted by non-hg command, but still tracked)
168 ? = not tracked
168 ? = not tracked
169 I = ignored
169 I = ignored
170 = origin of the previous file (with --copies)
170 = origin of the previous file (with --copies)
171
171
172 Returns 0 on success.
172 Returns 0 on success.
173
173
174 defined by: * (glob)
174 defined by: * (glob)
175 */* (glob) (?)
175 */* (glob) (?)
176 */* (glob) (?)
176 */* (glob) (?)
177 */* (glob) (?)
177 */* (glob) (?)
178
178
179 options ([+] can be repeated):
179 options ([+] can be repeated):
180
180
181 -A --all show status of all files
181 -A --all show status of all files
182 -m --modified show only modified files
182 -m --modified show only modified files
183 -a --added show only added files
183 -a --added show only added files
184 -r --removed show only removed files
184 -r --removed show only removed files
185 -d --deleted show only deleted (but tracked) files
185 -d --deleted show only deleted (but tracked) files
186 -c --clean show only files without changes
186 -c --clean show only files without changes
187 -u --unknown show only unknown (not tracked) files
187 -u --unknown show only unknown (not tracked) files
188 -i --ignored show only ignored files
188 -i --ignored show only ignored files
189 -n --no-status hide status prefix
189 -n --no-status hide status prefix
190 -C --copies show source of copied files
190 -C --copies show source of copied files
191 -0 --print0 end filenames with NUL, for use with xargs
191 -0 --print0 end filenames with NUL, for use with xargs
192 --rev REV [+] show difference from revision
192 --rev REV [+] show difference from revision
193 --change REV list the changed files of a revision
193 --change REV list the changed files of a revision
194 -I --include PATTERN [+] include names matching the given patterns
194 -I --include PATTERN [+] include names matching the given patterns
195 -X --exclude PATTERN [+] exclude names matching the given patterns
195 -X --exclude PATTERN [+] exclude names matching the given patterns
196 -S --subrepos recurse into subrepositories
196 -S --subrepos recurse into subrepositories
197 -T --template TEMPLATE display with template
197 -T --template TEMPLATE display with template
198
198
199 (some details hidden, use --verbose to show complete help)
199 (some details hidden, use --verbose to show complete help)
200
200
201 $ hg help recursivedoc | head -n 5
201 $ hg help recursivedoc | head -n 5
202 hg recursivedoc foo bar baz
202 hg recursivedoc foo bar baz
203
203
204 alias for: hg dln
204 alias for: hg dln
205
205
206 Logs the null rev in debug mode
206 Logs the null rev in debug mode
207
207
208 unknown
208 unknown
209
209
210 $ hg unknown
210 $ hg unknown
211 abort: alias 'unknown' resolves to unknown command 'bargle'
211 abort: alias 'unknown' resolves to unknown command 'bargle'
212 [255]
212 [255]
213 $ hg help unknown
213 $ hg help unknown
214 alias 'unknown' resolves to unknown command 'bargle'
214 alias 'unknown' resolves to unknown command 'bargle'
215
215
216
216
217 ambiguous
217 ambiguous
218
218
219 $ hg ambiguous
219 $ hg ambiguous
220 abort: alias 'ambiguous' resolves to ambiguous command 's'
220 abort: alias 'ambiguous' resolves to ambiguous command 's'
221 [255]
221 [255]
222 $ hg help ambiguous
222 $ hg help ambiguous
223 alias 'ambiguous' resolves to ambiguous command 's'
223 alias 'ambiguous' resolves to ambiguous command 's'
224
224
225
225
226 recursive
226 recursive
227
227
228 $ hg recursive
228 $ hg recursive
229 abort: alias 'recursive' resolves to unknown command 'recursive'
229 abort: alias 'recursive' resolves to unknown command 'recursive'
230 [255]
230 [255]
231 $ hg help recursive
231 $ hg help recursive
232 alias 'recursive' resolves to unknown command 'recursive'
232 alias 'recursive' resolves to unknown command 'recursive'
233
233
234
234
235 disabled
235 disabled
236
236
237 $ hg disabled
237 $ hg disabled
238 abort: alias 'disabled' resolves to unknown command 'email'
238 abort: alias 'disabled' resolves to unknown command 'email'
239 ('email' is provided by 'patchbomb' extension)
239 ('email' is provided by 'patchbomb' extension)
240 [255]
240 [255]
241 $ hg help disabled
241 $ hg help disabled
242 alias 'disabled' resolves to unknown command 'email'
242 alias 'disabled' resolves to unknown command 'email'
243
243
244 'email' is provided by the following extension:
244 'email' is provided by the following extension:
245
245
246 patchbomb command to send changesets as (a series of) patch emails
246 patchbomb command to send changesets as (a series of) patch emails
247
247
248 (use 'hg help extensions' for information on enabling extensions)
248 (use 'hg help extensions' for information on enabling extensions)
249
249
250
250
251 no definition
251 no definition
252
252
253 $ hg nodef
253 $ hg nodef
254 abort: no definition for alias 'nodefinition'
254 abort: no definition for alias 'nodefinition'
255 [255]
255 [255]
256 $ hg help nodef
256 $ hg help nodef
257 no definition for alias 'nodefinition'
257 no definition for alias 'nodefinition'
258
258
259
259
260 no closing quotation
260 no closing quotation
261
261
262 $ hg noclosing
262 $ hg noclosing
263 abort: error in definition for alias 'noclosingquotation': No closing quotation
263 abort: error in definition for alias 'noclosingquotation': No closing quotation
264 [255]
264 [255]
265 $ hg help noclosing
265 $ hg help noclosing
266 error in definition for alias 'noclosingquotation': No closing quotation
266 error in definition for alias 'noclosingquotation': No closing quotation
267
267
268 "--" in alias definition should be preserved
268 "--" in alias definition should be preserved
269
269
270 $ hg --config alias.dash='cat --' -R alias dash -r0
270 $ hg --config alias.dash='cat --' -R alias dash -r0
271 abort: -r0 not under root '$TESTTMP/alias'
271 abort: -r0 not under root '$TESTTMP/alias'
272 (consider using '--cwd alias')
272 (consider using '--cwd alias')
273 [255]
273 [255]
274
274
275 invalid options
275 invalid options
276
276
277 $ hg no--cwd
277 $ hg no--cwd
278 abort: error in definition for alias 'no--cwd': --cwd may only be given on the command line
278 abort: error in definition for alias 'no--cwd': --cwd may only be given on the command line
279 [255]
279 [255]
280 $ hg help no--cwd
280 $ hg help no--cwd
281 error in definition for alias 'no--cwd': --cwd may only be given on the
281 error in definition for alias 'no--cwd': --cwd may only be given on the
282 command line
282 command line
283 $ hg no-R
283 $ hg no-R
284 abort: error in definition for alias 'no-R': -R may only be given on the command line
284 abort: error in definition for alias 'no-R': -R may only be given on the command line
285 [255]
285 [255]
286 $ hg help no-R
286 $ hg help no-R
287 error in definition for alias 'no-R': -R may only be given on the command line
287 error in definition for alias 'no-R': -R may only be given on the command line
288 $ hg no--repo
288 $ hg no--repo
289 abort: error in definition for alias 'no--repo': --repo may only be given on the command line
289 abort: error in definition for alias 'no--repo': --repo may only be given on the command line
290 [255]
290 [255]
291 $ hg help no--repo
291 $ hg help no--repo
292 error in definition for alias 'no--repo': --repo may only be given on the
292 error in definition for alias 'no--repo': --repo may only be given on the
293 command line
293 command line
294 $ hg no--repository
294 $ hg no--repository
295 abort: error in definition for alias 'no--repository': --repository may only be given on the command line
295 abort: error in definition for alias 'no--repository': --repository may only be given on the command line
296 [255]
296 [255]
297 $ hg help no--repository
297 $ hg help no--repository
298 error in definition for alias 'no--repository': --repository may only be given
298 error in definition for alias 'no--repository': --repository may only be given
299 on the command line
299 on the command line
300 $ hg no--config
300 $ hg no--config
301 abort: error in definition for alias 'no--config': --config may only be given on the command line
301 abort: error in definition for alias 'no--config': --config may only be given on the command line
302 [255]
302 [255]
303 $ hg no --config alias.no='--repo elsewhere --cwd elsewhere status'
303 $ hg no --config alias.no='--repo elsewhere --cwd elsewhere status'
304 abort: error in definition for alias 'no': --repo/--cwd may only be given on the command line
304 abort: error in definition for alias 'no': --repo/--cwd may only be given on the command line
305 [255]
305 [255]
306 $ hg no --config alias.no='--repo elsewhere'
306 $ hg no --config alias.no='--repo elsewhere'
307 abort: error in definition for alias 'no': --repo may only be given on the command line
307 abort: error in definition for alias 'no': --repo may only be given on the command line
308 [255]
308 [255]
309
309
310 optional repository
310 optional repository
311
311
312 #if no-outer-repo
312 #if no-outer-repo
313 $ hg optionalrepo
313 $ hg optionalrepo
314 init
314 init
315 #endif
315 #endif
316 $ cd alias
316 $ cd alias
317 $ cat > .hg/hgrc <<EOF
317 $ cat > .hg/hgrc <<EOF
318 > [alias]
318 > [alias]
319 > myinit = init -q
319 > myinit = init -q
320 > EOF
320 > EOF
321 $ hg optionalrepo
321 $ hg optionalrepo
322 init -q
322 init -q
323
323
324 no usage
324 no usage
325
325
326 $ hg nousage
326 $ hg nousage
327 no rollback information available
327 no rollback information available
328 [1]
328 [1]
329
329
330 $ echo foo > foo
330 $ echo foo > foo
331 $ hg commit -Amfoo
331 $ hg commit -Amfoo
332 adding foo
332 adding foo
333
333
334 infer repository
334 infer repository
335
335
336 $ cd ..
336 $ cd ..
337
337
338 #if no-outer-repo
338 #if no-outer-repo
339 $ hg shortlog alias/foo
339 $ hg shortlog alias/foo
340 0 e63c23eaa88a | 1970-01-01 00:00 +0000
340 0 e63c23eaa88a | 1970-01-01 00:00 +0000
341 #endif
341 #endif
342
342
343 $ cd alias
343 $ cd alias
344
344
345 with opts
345 with opts
346
346
347 $ hg cleanst
347 $ hg cleanst
348 C foo
348 C foo
349
349
350
350
351 with opts and whitespace
351 with opts and whitespace
352
352
353 $ hg shortlog
353 $ hg shortlog
354 0 e63c23eaa88a | 1970-01-01 00:00 +0000
354 0 e63c23eaa88a | 1970-01-01 00:00 +0000
355
355
356 positional arguments
356 positional arguments
357
357
358 $ hg positional
358 $ hg positional
359 abort: too few arguments for command alias
359 abort: too few arguments for command alias
360 [255]
360 [255]
361 $ hg positional a
361 $ hg positional a
362 abort: too few arguments for command alias
362 abort: too few arguments for command alias
363 [255]
363 [255]
364 $ hg positional 'node|short' rev
364 $ hg positional 'node|short' rev
365 0 e63c23eaa88a | 1970-01-01 00:00 +0000
365 0 e63c23eaa88a | 1970-01-01 00:00 +0000
366
366
367 interaction with defaults
367 interaction with defaults
368
368
369 $ hg mylog
369 $ hg mylog
370 0:e63c23eaa88a
370 0:e63c23eaa88a
371 $ hg lognull
371 $ hg lognull
372 -1:000000000000
372 -1:000000000000
373
373
374
374
375 properly recursive
375 properly recursive
376
376
377 $ hg dln
377 $ hg dln
378 changeset: -1:0000000000000000000000000000000000000000
378 changeset: -1:0000000000000000000000000000000000000000
379 phase: public
379 phase: public
380 parent: -1:0000000000000000000000000000000000000000
380 parent: -1:0000000000000000000000000000000000000000
381 parent: -1:0000000000000000000000000000000000000000
381 parent: -1:0000000000000000000000000000000000000000
382 manifest: -1:0000000000000000000000000000000000000000
382 manifest: -1:0000000000000000000000000000000000000000
383 user:
383 user:
384 date: Thu Jan 01 00:00:00 1970 +0000
384 date: Thu Jan 01 00:00:00 1970 +0000
385 extra: branch=default
385 extra: branch=default
386
386
387
387
388
388
389 path expanding
389 path expanding
390
390
391 $ FOO=`pwd` hg put
391 $ FOO=`pwd` hg put
392 $ cat 0.diff
392 $ cat 0.diff
393 # HG changeset patch
393 # HG changeset patch
394 # User test
394 # User test
395 # Date 0 0
395 # Date 0 0
396 # Thu Jan 01 00:00:00 1970 +0000
396 # Thu Jan 01 00:00:00 1970 +0000
397 # Node ID e63c23eaa88ae77967edcf4ea194d31167c478b0
397 # Node ID e63c23eaa88ae77967edcf4ea194d31167c478b0
398 # Parent 0000000000000000000000000000000000000000
398 # Parent 0000000000000000000000000000000000000000
399 foo
399 foo
400
400
401 diff -r 000000000000 -r e63c23eaa88a foo
401 diff -r 000000000000 -r e63c23eaa88a foo
402 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
402 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
403 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
403 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
404 @@ -0,0 +1,1 @@
404 @@ -0,0 +1,1 @@
405 +foo
405 +foo
406
406
407
407
408 simple shell aliases
408 simple shell aliases
409
409
410 $ hg blank
410 $ hg blank
411
411
412 $ hg blank foo
412 $ hg blank foo
413
413
414 $ hg self
414 $ hg self
415 self
415 self
416 $ hg echoall
416 $ hg echoall
417
417
418 $ hg echoall foo
418 $ hg echoall foo
419 foo
419 foo
420 $ hg echoall 'test $2' foo
420 $ hg echoall 'test $2' foo
421 test $2 foo
421 test $2 foo
422 $ hg echoall 'test $@' foo '$@'
422 $ hg echoall 'test $@' foo '$@'
423 test $@ foo $@
423 test $@ foo $@
424 $ hg echoall 'test "$@"' foo '"$@"'
424 $ hg echoall 'test "$@"' foo '"$@"'
425 test "$@" foo "$@"
425 test "$@" foo "$@"
426 $ hg echo1 foo bar baz
426 $ hg echo1 foo bar baz
427 foo
427 foo
428 $ hg echo2 foo bar baz
428 $ hg echo2 foo bar baz
429 bar
429 bar
430 $ hg echo13 foo bar baz test
430 $ hg echo13 foo bar baz test
431 foo baz
431 foo baz
432 $ hg echo2 foo
432 $ hg echo2 foo
433
433
434 $ hg echotokens
434 $ hg echotokens
435
435
436 $ hg echotokens foo 'bar $1 baz'
436 $ hg echotokens foo 'bar $1 baz'
437 foo
437 foo
438 bar $1 baz
438 bar $1 baz
439 $ hg echotokens 'test $2' foo
439 $ hg echotokens 'test $2' foo
440 test $2
440 test $2
441 foo
441 foo
442 $ hg echotokens 'test $@' foo '$@'
442 $ hg echotokens 'test $@' foo '$@'
443 test $@
443 test $@
444 foo
444 foo
445 $@
445 $@
446 $ hg echotokens 'test "$@"' foo '"$@"'
446 $ hg echotokens 'test "$@"' foo '"$@"'
447 test "$@"
447 test "$@"
448 foo
448 foo
449 "$@"
449 "$@"
450 $ echo bar > bar
450 $ echo bar > bar
451 $ hg commit -qA -m bar
451 $ hg commit -qA -m bar
452 $ hg count .
452 $ hg count .
453 1
453 1
454 $ hg count 'branch(default)'
454 $ hg count 'branch(default)'
455 2
455 2
456 $ hg mcount -r '"branch(default)"'
456 $ hg mcount -r '"branch(default)"'
457 2
457 2
458
458
459 $ hg tglog
459 $ hg tglog
460 @ 1:042423737847: 'bar'
460 @ 1:042423737847: 'bar'
461 |
461 |
462 o 0:e63c23eaa88a: 'foo'
462 o 0:e63c23eaa88a: 'foo'
463
463
464
464
465
465
466 shadowing
466 shadowing
467
467
468 $ hg i
468 $ hg i
469 hg: command 'i' is ambiguous:
469 hg: command 'i' is ambiguous:
470 idalias idaliaslong idaliasshell identify import incoming init
470 idalias idaliaslong idaliasshell identify import incoming init
471 [255]
471 [255]
472 $ hg id
472 $ hg id
473 042423737847 tip
473 042423737847 tip
474 $ hg ida
474 $ hg ida
475 hg: command 'ida' is ambiguous:
475 hg: command 'ida' is ambiguous:
476 idalias idaliaslong idaliasshell
476 idalias idaliaslong idaliasshell
477 [255]
477 [255]
478 $ hg idalias
478 $ hg idalias
479 042423737847 tip
479 042423737847 tip
480 $ hg idaliasl
480 $ hg idaliasl
481 042423737847 tip
481 042423737847 tip
482 $ hg idaliass
482 $ hg idaliass
483 test
483 test
484 $ hg parentsshell
484 $ hg parentsshell
485 hg: command 'parentsshell' is ambiguous:
485 hg: command 'parentsshell' is ambiguous:
486 parentsshell1 parentsshell2
486 parentsshell1 parentsshell2
487 [255]
487 [255]
488 $ hg parentsshell1
488 $ hg parentsshell1
489 one
489 one
490 $ hg parentsshell2
490 $ hg parentsshell2
491 two
491 two
492
492
493
493
494 shell aliases with global options
494 shell aliases with global options
495
495
496 $ hg init sub
496 $ hg init sub
497 $ cd sub
497 $ cd sub
498 $ hg count 'branch(default)'
498 $ hg count 'branch(default)'
499 abort: unknown revision 'default'!
499 abort: unknown revision 'default'!
500 0
500 0
501 $ hg -v count 'branch(default)'
501 $ hg -v count 'branch(default)'
502 abort: unknown revision 'default'!
502 abort: unknown revision 'default'!
503 0
503 0
504 $ hg -R .. count 'branch(default)'
504 $ hg -R .. count 'branch(default)'
505 abort: unknown revision 'default'!
505 abort: unknown revision 'default'!
506 0
506 0
507 $ hg --cwd .. count 'branch(default)'
507 $ hg --cwd .. count 'branch(default)'
508 2
508 2
509 $ hg echoall --cwd ..
509 $ hg echoall --cwd ..
510
510
511
511
512 "--" passed to shell alias should be preserved
512 "--" passed to shell alias should be preserved
513
513
514 $ hg --config alias.printf='!printf "$@"' printf '%s %s %s\n' -- --cwd ..
514 $ hg --config alias.printf='!printf "$@"' printf '%s %s %s\n' -- --cwd ..
515 -- --cwd ..
515 -- --cwd ..
516
516
517 repo specific shell aliases
517 repo specific shell aliases
518
518
519 $ cat >> .hg/hgrc <<EOF
519 $ cat >> .hg/hgrc <<EOF
520 > [alias]
520 > [alias]
521 > subalias = !echo sub
521 > subalias = !echo sub
522 > EOF
522 > EOF
523 $ cat >> ../.hg/hgrc <<EOF
523 $ cat >> ../.hg/hgrc <<EOF
524 > [alias]
524 > [alias]
525 > mainalias = !echo main
525 > mainalias = !echo main
526 > EOF
526 > EOF
527
527
528
528
529 shell alias defined in current repo
529 shell alias defined in current repo
530
530
531 $ hg subalias
531 $ hg subalias
532 sub
532 sub
533 $ hg --cwd .. subalias > /dev/null
533 $ hg --cwd .. subalias > /dev/null
534 hg: unknown command 'subalias'
534 hg: unknown command 'subalias'
535 (did you mean idalias?)
535 (did you mean idalias?)
536 [255]
536 [255]
537 $ hg -R .. subalias > /dev/null
537 $ hg -R .. subalias > /dev/null
538 hg: unknown command 'subalias'
538 hg: unknown command 'subalias'
539 (did you mean idalias?)
539 (did you mean idalias?)
540 [255]
540 [255]
541
541
542
542
543 shell alias defined in other repo
543 shell alias defined in other repo
544
544
545 $ hg mainalias > /dev/null
545 $ hg mainalias > /dev/null
546 hg: unknown command 'mainalias'
546 hg: unknown command 'mainalias'
547 (did you mean idalias?)
547 (did you mean idalias?)
548 [255]
548 [255]
549 $ hg -R .. mainalias
549 $ hg -R .. mainalias
550 main
550 main
551 $ hg --cwd .. mainalias
551 $ hg --cwd .. mainalias
552 main
552 main
553
553
554 typos get useful suggestions
554 typos get useful suggestions
555 $ hg --cwd .. manalias
555 $ hg --cwd .. manalias
556 hg: unknown command 'manalias'
556 hg: unknown command 'manalias'
557 (did you mean one of idalias, mainalias, manifest?)
557 (did you mean one of idalias, mainalias, manifest?)
558 [255]
558 [255]
559
559
560 shell aliases with escaped $ chars
560 shell aliases with escaped $ chars
561
561
562 $ hg escaped1
562 $ hg escaped1
563 test$test
563 test$test
564 $ hg escaped2
564 $ hg escaped2
565 HGFOO is BAR
565 HGFOO is BAR
566 $ hg escaped3 HGFOO
566 $ hg escaped3 HGFOO
567 HGFOO is BAR
567 HGFOO is BAR
568 $ hg escaped4 test
568 $ hg escaped4 test
569 $0 $@
569 $0 $@
570
570
571 abbreviated name, which matches against both shell alias and the
571 abbreviated name, which matches against both shell alias and the
572 command provided extension, should be aborted.
572 command provided extension, should be aborted.
573
573
574 $ cat >> .hg/hgrc <<EOF
574 $ cat >> .hg/hgrc <<EOF
575 > [extensions]
575 > [extensions]
576 > hgext.rebase =
576 > hgext.rebase =
577 > EOF
577 > EOF
578 #if windows
578 #if windows
579 $ cat >> .hg/hgrc <<EOF
579 $ cat >> .hg/hgrc <<EOF
580 > [alias]
580 > [alias]
581 > rebate = !echo this is %HG_ARGS%
581 > rebate = !echo this is %HG_ARGS%
582 > EOF
582 > EOF
583 #else
583 #else
584 $ cat >> .hg/hgrc <<EOF
584 $ cat >> .hg/hgrc <<EOF
585 > [alias]
585 > [alias]
586 > rebate = !echo this is \$HG_ARGS
586 > rebate = !echo this is \$HG_ARGS
587 > EOF
587 > EOF
588 #endif
588 #endif
589 $ cat >> .hg/hgrc <<EOF
589 $ cat >> .hg/hgrc <<EOF
590 > rebate:doc = This is my alias which just prints something.
590 > rebate:doc = This is my alias which just prints something.
591 > rebate:help = [MYARGS]
591 > rebate:help = [MYARGS]
592 > EOF
592 > EOF
593 $ hg reba
593 $ hg reba
594 hg: command 'reba' is ambiguous:
594 hg: command 'reba' is ambiguous:
595 rebase rebate
595 rebase rebate
596 [255]
596 [255]
597 $ hg rebat
597 $ hg rebat
598 this is rebate
598 this is rebate
599 $ hg rebat --foo-bar
599 $ hg rebat --foo-bar
600 this is rebate --foo-bar
600 this is rebate --foo-bar
601
601
602 help for a shell alias
602 help for a shell alias
603
603
604 $ hg help -c | grep rebate
604 $ hg help -c | grep rebate
605 rebate This is my alias which just prints something.
605 rebate This is my alias which just prints something.
606 $ hg help rebate
606 $ hg help rebate
607 hg rebate [MYARGS]
607 hg rebate [MYARGS]
608
608
609 shell alias for: echo this is %HG_ARGS% (windows !)
609 shell alias for: echo this is %HG_ARGS% (windows !)
610 shell alias for: echo this is $HG_ARGS (no-windows !)
610 shell alias for: echo this is $HG_ARGS (no-windows !)
611
611
612 This is my alias which just prints something.
612 This is my alias which just prints something.
613
613
614 defined by:* (glob)
614 defined by:* (glob)
615 */* (glob) (?)
615 */* (glob) (?)
616 */* (glob) (?)
616 */* (glob) (?)
617 */* (glob) (?)
617 */* (glob) (?)
618
618
619 (some details hidden, use --verbose to show complete help)
619 (some details hidden, use --verbose to show complete help)
620
620
621 invalid character in user-specified help
621 invalid character in user-specified help
622
622
623 >>> with open('.hg/hgrc', 'ab') as f:
623 >>> with open('.hg/hgrc', 'ab') as f:
624 ... f.write(b'[alias]\n'
624 ... f.write(b'[alias]\n'
625 ... b'invaliddoc = log\n'
625 ... b'invaliddoc = log\n'
626 ... b'invaliddoc:doc = \xc0\n'
626 ... b'invaliddoc:doc = \xc0\n'
627 ... b'invalidhelp = log\n'
627 ... b'invalidhelp = log\n'
628 ... b'invalidhelp:help = \xc0\n') and None
628 ... b'invalidhelp:help = \xc0\n') and None
629 $ hg help invaliddoc
629 $ hg help invaliddoc
630 non-ASCII character in alias definition 'invaliddoc:doc'
630 non-ASCII character in alias definition 'invaliddoc:doc'
631 $ hg help invalidhelp
631 $ hg help invalidhelp
632 non-ASCII character in alias definition 'invalidhelp:help'
632 non-ASCII character in alias definition 'invalidhelp:help'
633 $ hg invaliddoc
633 $ hg invaliddoc
634 abort: non-ASCII character in alias definition 'invaliddoc:doc'
634 abort: non-ASCII character in alias definition 'invaliddoc:doc'
635 [255]
635 [255]
636 $ hg invalidhelp
636 $ hg invalidhelp
637 abort: non-ASCII character in alias definition 'invalidhelp:help'
637 abort: non-ASCII character in alias definition 'invalidhelp:help'
638 [255]
638 [255]
639
639
640 invalid arguments
640 invalid arguments
641
641
642 $ hg rt foo
642 $ hg rt foo
643 hg rt: invalid arguments
643 hg rt: invalid arguments
644 hg rt
644 hg rt
645
645
646 alias for: hg root
646 alias for: hg root
647
647
648 (use 'hg rt -h' to show more help)
648 (use 'hg rt -h' to show more help)
649 [255]
649 [255]
650
650
651 invalid global arguments for normal commands, aliases, and shell aliases
651 invalid global arguments for normal commands, aliases, and shell aliases
652
652
653 $ hg --invalid root
653 $ hg --invalid root
654 hg: option --invalid not recognized
654 hg: option --invalid not recognized
655 (use 'hg help -v' for a list of global options)
655 (use 'hg help -v' for a list of global options)
656 [255]
656 [255]
657 $ hg --invalid mylog
657 $ hg --invalid mylog
658 hg: option --invalid not recognized
658 hg: option --invalid not recognized
659 (use 'hg help -v' for a list of global options)
659 (use 'hg help -v' for a list of global options)
660 [255]
660 [255]
661 $ hg --invalid blank
661 $ hg --invalid blank
662 hg: option --invalid not recognized
662 hg: option --invalid not recognized
663 (use 'hg help -v' for a list of global options)
663 (use 'hg help -v' for a list of global options)
664 [255]
664 [255]
665
665
666 environment variable changes in alias commands
666 environment variable changes in alias commands
667
667
668 $ cat > $TESTTMP/expandalias.py <<EOF
668 $ cat > $TESTTMP/expandalias.py <<EOF
669 > import os
669 > import os
670 > from mercurial import cmdutil, commands, registrar
670 > from mercurial import cmdutil, commands, registrar
671 > cmdtable = {}
671 > cmdtable = {}
672 > command = registrar.command(cmdtable)
672 > command = registrar.command(cmdtable)
673 > @command(b'expandalias')
673 > @command(b'expandalias')
674 > def expandalias(ui, repo, name):
674 > def expandalias(ui, repo, name):
675 > alias = cmdutil.findcmd(name, commands.table)[1][0]
675 > alias = cmdutil.findcmd(name, commands.table)[1][0]
676 > ui.write(b'%s args: %s\n' % (name, b' '.join(alias.args)))
676 > ui.write(b'%s args: %s\n' % (name, b' '.join(alias.args)))
677 > os.environ['COUNT'] = '2'
677 > os.environ['COUNT'] = '2'
678 > ui.write(b'%s args: %s (with COUNT=2)\n' % (name, b' '.join(alias.args)))
678 > ui.write(b'%s args: %s (with COUNT=2)\n' % (name, b' '.join(alias.args)))
679 > EOF
679 > EOF
680
680
681 $ cat >> $HGRCPATH <<'EOF'
681 $ cat >> $HGRCPATH <<'EOF'
682 > [extensions]
682 > [extensions]
683 > expandalias = $TESTTMP/expandalias.py
683 > expandalias = $TESTTMP/expandalias.py
684 > [alias]
684 > [alias]
685 > showcount = log -T "$COUNT" -r .
685 > showcount = log -T "$COUNT" -r .
686 > EOF
686 > EOF
687
687
688 $ COUNT=1 hg expandalias showcount
688 $ COUNT=1 hg expandalias showcount
689 showcount args: -T 1 -r .
689 showcount args: -T 1 -r .
690 showcount args: -T 2 -r . (with COUNT=2)
690 showcount args: -T 2 -r . (with COUNT=2)
691
691
692 This should show id:
692 This should show id:
693
693
694 $ hg --config alias.log='id' log
694 $ hg --config alias.log='id' log
695 000000000000 tip
695 000000000000 tip
696
696
697 This shouldn't:
697 This shouldn't:
698
698
699 $ hg --config alias.log='id' history
699 $ hg --config alias.log='id' history
700
700
701 $ cd ../..
701 $ cd ../..
702
702
703 return code of command and shell aliases:
703 return code of command and shell aliases:
704
704
705 $ hg mycommit -R alias
705 $ hg mycommit -R alias
706 nothing changed
706 nothing changed
707 [1]
707 [1]
708 $ hg exit1
708 $ hg exit1
709 [1]
709 [1]
710
710
711 #if no-outer-repo
711 #if no-outer-repo
712 $ hg root
712 $ hg root
713 abort: no repository found in '$TESTTMP' (.hg not found)!
713 abort: no repository found in '$TESTTMP' (.hg not found)!
714 [255]
714 [255]
715 $ hg --config alias.hgroot='!hg root' hgroot
715 $ hg --config alias.hgroot='!hg root' hgroot
716 abort: no repository found in '$TESTTMP' (.hg not found)!
716 abort: no repository found in '$TESTTMP' (.hg not found)!
717 [255]
717 [255]
718 #endif
718 #endif
@@ -1,3902 +1,3930 b''
1 Short help:
1 Short help:
2
2
3 $ hg
3 $ hg
4 Mercurial Distributed SCM
4 Mercurial Distributed SCM
5
5
6 basic commands:
6 basic commands:
7
7
8 add add the specified files on the next commit
8 add add the specified files on the next commit
9 annotate show changeset information by line for each file
9 annotate show changeset information by line for each file
10 clone make a copy of an existing repository
10 clone make a copy of an existing repository
11 commit commit the specified files or all outstanding changes
11 commit commit the specified files or all outstanding changes
12 diff diff repository (or selected files)
12 diff diff repository (or selected files)
13 export dump the header and diffs for one or more changesets
13 export dump the header and diffs for one or more changesets
14 forget forget the specified files on the next commit
14 forget forget the specified files on the next commit
15 init create a new repository in the given directory
15 init create a new repository in the given directory
16 log show revision history of entire repository or files
16 log show revision history of entire repository or files
17 merge merge another revision into working directory
17 merge merge another revision into working directory
18 pull pull changes from the specified source
18 pull pull changes from the specified source
19 push push changes to the specified destination
19 push push changes to the specified destination
20 remove remove the specified files on the next commit
20 remove remove the specified files on the next commit
21 serve start stand-alone webserver
21 serve start stand-alone webserver
22 status show changed files in the working directory
22 status show changed files in the working directory
23 summary summarize working directory state
23 summary summarize working directory state
24 update update working directory (or switch revisions)
24 update update working directory (or switch revisions)
25
25
26 (use 'hg help' for the full list of commands or 'hg -v' for details)
26 (use 'hg help' for the full list of commands or 'hg -v' for details)
27
27
28 $ hg -q
28 $ hg -q
29 add add the specified files on the next commit
29 add add the specified files on the next commit
30 annotate show changeset information by line for each file
30 annotate show changeset information by line for each file
31 clone make a copy of an existing repository
31 clone make a copy of an existing repository
32 commit commit the specified files or all outstanding changes
32 commit commit the specified files or all outstanding changes
33 diff diff repository (or selected files)
33 diff diff repository (or selected files)
34 export dump the header and diffs for one or more changesets
34 export dump the header and diffs for one or more changesets
35 forget forget the specified files on the next commit
35 forget forget the specified files on the next commit
36 init create a new repository in the given directory
36 init create a new repository in the given directory
37 log show revision history of entire repository or files
37 log show revision history of entire repository or files
38 merge merge another revision into working directory
38 merge merge another revision into working directory
39 pull pull changes from the specified source
39 pull pull changes from the specified source
40 push push changes to the specified destination
40 push push changes to the specified destination
41 remove remove the specified files on the next commit
41 remove remove the specified files on the next commit
42 serve start stand-alone webserver
42 serve start stand-alone webserver
43 status show changed files in the working directory
43 status show changed files in the working directory
44 summary summarize working directory state
44 summary summarize working directory state
45 update update working directory (or switch revisions)
45 update update working directory (or switch revisions)
46
46
47 Extra extensions will be printed in help output in a non-reliable order since
47 Extra extensions will be printed in help output in a non-reliable order since
48 the extension is unknown.
48 the extension is unknown.
49 #if no-extraextensions
49 #if no-extraextensions
50
50
51 $ hg help
51 $ hg help
52 Mercurial Distributed SCM
52 Mercurial Distributed SCM
53
53
54 list of commands:
54 list of commands:
55
55
56 Repository creation:
56 Repository creation:
57
57
58 clone make a copy of an existing repository
58 clone make a copy of an existing repository
59 init create a new repository in the given directory
59 init create a new repository in the given directory
60
60
61 Remote repository management:
61 Remote repository management:
62
62
63 incoming show new changesets found in source
63 incoming show new changesets found in source
64 outgoing show changesets not found in the destination
64 outgoing show changesets not found in the destination
65 paths show aliases for remote repositories
65 paths show aliases for remote repositories
66 pull pull changes from the specified source
66 pull pull changes from the specified source
67 push push changes to the specified destination
67 push push changes to the specified destination
68 serve start stand-alone webserver
68 serve start stand-alone webserver
69
69
70 Change creation:
70 Change creation:
71
71
72 commit commit the specified files or all outstanding changes
72 commit commit the specified files or all outstanding changes
73
73
74 Change manipulation:
74 Change manipulation:
75
75
76 backout reverse effect of earlier changeset
76 backout reverse effect of earlier changeset
77 graft copy changes from other branches onto the current branch
77 graft copy changes from other branches onto the current branch
78 merge merge another revision into working directory
78 merge merge another revision into working directory
79
79
80 Change organization:
80 Change organization:
81
81
82 bookmarks create a new bookmark or list existing bookmarks
82 bookmarks create a new bookmark or list existing bookmarks
83 branch set or show the current branch name
83 branch set or show the current branch name
84 branches list repository named branches
84 branches list repository named branches
85 phase set or show the current phase name
85 phase set or show the current phase name
86 tag add one or more tags for the current or given revision
86 tag add one or more tags for the current or given revision
87 tags list repository tags
87 tags list repository tags
88
88
89 File content management:
89 File content management:
90
90
91 annotate show changeset information by line for each file
91 annotate show changeset information by line for each file
92 cat output the current or given revision of files
92 cat output the current or given revision of files
93 copy mark files as copied for the next commit
93 copy mark files as copied for the next commit
94 diff diff repository (or selected files)
94 diff diff repository (or selected files)
95 grep search revision history for a pattern in specified files
95 grep search revision history for a pattern in specified files
96
96
97 Change navigation:
97 Change navigation:
98
98
99 bisect subdivision search of changesets
99 bisect subdivision search of changesets
100 heads show branch heads
100 heads show branch heads
101 identify identify the working directory or specified revision
101 identify identify the working directory or specified revision
102 log show revision history of entire repository or files
102 log show revision history of entire repository or files
103
103
104 Working directory management:
104 Working directory management:
105
105
106 add add the specified files on the next commit
106 add add the specified files on the next commit
107 addremove add all new files, delete all missing files
107 addremove add all new files, delete all missing files
108 files list tracked files
108 files list tracked files
109 forget forget the specified files on the next commit
109 forget forget the specified files on the next commit
110 remove remove the specified files on the next commit
110 remove remove the specified files on the next commit
111 rename rename files; equivalent of copy + remove
111 rename rename files; equivalent of copy + remove
112 resolve redo merges or set/view the merge status of files
112 resolve redo merges or set/view the merge status of files
113 revert restore files to their checkout state
113 revert restore files to their checkout state
114 root print the root (top) of the current working directory
114 root print the root (top) of the current working directory
115 status show changed files in the working directory
115 status show changed files in the working directory
116 summary summarize working directory state
116 summary summarize working directory state
117 update update working directory (or switch revisions)
117 update update working directory (or switch revisions)
118
118
119 Change import/export:
119 Change import/export:
120
120
121 archive create an unversioned archive of a repository revision
121 archive create an unversioned archive of a repository revision
122 bundle create a bundle file
122 bundle create a bundle file
123 export dump the header and diffs for one or more changesets
123 export dump the header and diffs for one or more changesets
124 import import an ordered set of patches
124 import import an ordered set of patches
125 unbundle apply one or more bundle files
125 unbundle apply one or more bundle files
126
126
127 Repository maintenance:
127 Repository maintenance:
128
128
129 manifest output the current or given revision of the project manifest
129 manifest output the current or given revision of the project manifest
130 recover roll back an interrupted transaction
130 recover roll back an interrupted transaction
131 verify verify the integrity of the repository
131 verify verify the integrity of the repository
132
132
133 Help:
133 Help:
134
134
135 config show combined config settings from all hgrc files
135 config show combined config settings from all hgrc files
136 help show help for a given topic or a help overview
136 help show help for a given topic or a help overview
137 version output version and copyright information
137 version output version and copyright information
138
138
139 additional help topics:
139 additional help topics:
140
140
141 Mercurial identifiers:
141 Mercurial identifiers:
142
142
143 filesets Specifying File Sets
143 filesets Specifying File Sets
144 hgignore Syntax for Mercurial Ignore Files
144 hgignore Syntax for Mercurial Ignore Files
145 patterns File Name Patterns
145 patterns File Name Patterns
146 revisions Specifying Revisions
146 revisions Specifying Revisions
147 urls URL Paths
147 urls URL Paths
148
148
149 Mercurial output:
149 Mercurial output:
150
150
151 color Colorizing Outputs
151 color Colorizing Outputs
152 dates Date Formats
152 dates Date Formats
153 diffs Diff Formats
153 diffs Diff Formats
154 templating Template Usage
154 templating Template Usage
155
155
156 Mercurial configuration:
156 Mercurial configuration:
157
157
158 config Configuration Files
158 config Configuration Files
159 environment Environment Variables
159 environment Environment Variables
160 extensions Using Additional Features
160 extensions Using Additional Features
161 flags Command-line flags
161 flags Command-line flags
162 hgweb Configuring hgweb
162 hgweb Configuring hgweb
163 merge-tools Merge Tools
163 merge-tools Merge Tools
164 pager Pager Support
164 pager Pager Support
165
165
166 Concepts:
166 Concepts:
167
167
168 bundlespec Bundle File Formats
168 bundlespec Bundle File Formats
169 glossary Glossary
169 glossary Glossary
170 phases Working with Phases
170 phases Working with Phases
171 subrepos Subrepositories
171 subrepos Subrepositories
172
172
173 Miscellaneous:
173 Miscellaneous:
174
174
175 deprecated Deprecated Features
175 deprecated Deprecated Features
176 internals Technical implementation topics
176 internals Technical implementation topics
177 scripting Using Mercurial from scripts and automation
177 scripting Using Mercurial from scripts and automation
178
178
179 (use 'hg help -v' to show built-in aliases and global options)
179 (use 'hg help -v' to show built-in aliases and global options)
180
180
181 $ hg -q help
181 $ hg -q help
182 Repository creation:
182 Repository creation:
183
183
184 clone make a copy of an existing repository
184 clone make a copy of an existing repository
185 init create a new repository in the given directory
185 init create a new repository in the given directory
186
186
187 Remote repository management:
187 Remote repository management:
188
188
189 incoming show new changesets found in source
189 incoming show new changesets found in source
190 outgoing show changesets not found in the destination
190 outgoing show changesets not found in the destination
191 paths show aliases for remote repositories
191 paths show aliases for remote repositories
192 pull pull changes from the specified source
192 pull pull changes from the specified source
193 push push changes to the specified destination
193 push push changes to the specified destination
194 serve start stand-alone webserver
194 serve start stand-alone webserver
195
195
196 Change creation:
196 Change creation:
197
197
198 commit commit the specified files or all outstanding changes
198 commit commit the specified files or all outstanding changes
199
199
200 Change manipulation:
200 Change manipulation:
201
201
202 backout reverse effect of earlier changeset
202 backout reverse effect of earlier changeset
203 graft copy changes from other branches onto the current branch
203 graft copy changes from other branches onto the current branch
204 merge merge another revision into working directory
204 merge merge another revision into working directory
205
205
206 Change organization:
206 Change organization:
207
207
208 bookmarks create a new bookmark or list existing bookmarks
208 bookmarks create a new bookmark or list existing bookmarks
209 branch set or show the current branch name
209 branch set or show the current branch name
210 branches list repository named branches
210 branches list repository named branches
211 phase set or show the current phase name
211 phase set or show the current phase name
212 tag add one or more tags for the current or given revision
212 tag add one or more tags for the current or given revision
213 tags list repository tags
213 tags list repository tags
214
214
215 File content management:
215 File content management:
216
216
217 annotate show changeset information by line for each file
217 annotate show changeset information by line for each file
218 cat output the current or given revision of files
218 cat output the current or given revision of files
219 copy mark files as copied for the next commit
219 copy mark files as copied for the next commit
220 diff diff repository (or selected files)
220 diff diff repository (or selected files)
221 grep search revision history for a pattern in specified files
221 grep search revision history for a pattern in specified files
222
222
223 Change navigation:
223 Change navigation:
224
224
225 bisect subdivision search of changesets
225 bisect subdivision search of changesets
226 heads show branch heads
226 heads show branch heads
227 identify identify the working directory or specified revision
227 identify identify the working directory or specified revision
228 log show revision history of entire repository or files
228 log show revision history of entire repository or files
229
229
230 Working directory management:
230 Working directory management:
231
231
232 add add the specified files on the next commit
232 add add the specified files on the next commit
233 addremove add all new files, delete all missing files
233 addremove add all new files, delete all missing files
234 files list tracked files
234 files list tracked files
235 forget forget the specified files on the next commit
235 forget forget the specified files on the next commit
236 remove remove the specified files on the next commit
236 remove remove the specified files on the next commit
237 rename rename files; equivalent of copy + remove
237 rename rename files; equivalent of copy + remove
238 resolve redo merges or set/view the merge status of files
238 resolve redo merges or set/view the merge status of files
239 revert restore files to their checkout state
239 revert restore files to their checkout state
240 root print the root (top) of the current working directory
240 root print the root (top) of the current working directory
241 status show changed files in the working directory
241 status show changed files in the working directory
242 summary summarize working directory state
242 summary summarize working directory state
243 update update working directory (or switch revisions)
243 update update working directory (or switch revisions)
244
244
245 Change import/export:
245 Change import/export:
246
246
247 archive create an unversioned archive of a repository revision
247 archive create an unversioned archive of a repository revision
248 bundle create a bundle file
248 bundle create a bundle file
249 export dump the header and diffs for one or more changesets
249 export dump the header and diffs for one or more changesets
250 import import an ordered set of patches
250 import import an ordered set of patches
251 unbundle apply one or more bundle files
251 unbundle apply one or more bundle files
252
252
253 Repository maintenance:
253 Repository maintenance:
254
254
255 manifest output the current or given revision of the project manifest
255 manifest output the current or given revision of the project manifest
256 recover roll back an interrupted transaction
256 recover roll back an interrupted transaction
257 verify verify the integrity of the repository
257 verify verify the integrity of the repository
258
258
259 Help:
259 Help:
260
260
261 config show combined config settings from all hgrc files
261 config show combined config settings from all hgrc files
262 help show help for a given topic or a help overview
262 help show help for a given topic or a help overview
263 version output version and copyright information
263 version output version and copyright information
264
264
265 additional help topics:
265 additional help topics:
266
266
267 Mercurial identifiers:
267 Mercurial identifiers:
268
268
269 filesets Specifying File Sets
269 filesets Specifying File Sets
270 hgignore Syntax for Mercurial Ignore Files
270 hgignore Syntax for Mercurial Ignore Files
271 patterns File Name Patterns
271 patterns File Name Patterns
272 revisions Specifying Revisions
272 revisions Specifying Revisions
273 urls URL Paths
273 urls URL Paths
274
274
275 Mercurial output:
275 Mercurial output:
276
276
277 color Colorizing Outputs
277 color Colorizing Outputs
278 dates Date Formats
278 dates Date Formats
279 diffs Diff Formats
279 diffs Diff Formats
280 templating Template Usage
280 templating Template Usage
281
281
282 Mercurial configuration:
282 Mercurial configuration:
283
283
284 config Configuration Files
284 config Configuration Files
285 environment Environment Variables
285 environment Environment Variables
286 extensions Using Additional Features
286 extensions Using Additional Features
287 flags Command-line flags
287 flags Command-line flags
288 hgweb Configuring hgweb
288 hgweb Configuring hgweb
289 merge-tools Merge Tools
289 merge-tools Merge Tools
290 pager Pager Support
290 pager Pager Support
291
291
292 Concepts:
292 Concepts:
293
293
294 bundlespec Bundle File Formats
294 bundlespec Bundle File Formats
295 glossary Glossary
295 glossary Glossary
296 phases Working with Phases
296 phases Working with Phases
297 subrepos Subrepositories
297 subrepos Subrepositories
298
298
299 Miscellaneous:
299 Miscellaneous:
300
300
301 deprecated Deprecated Features
301 deprecated Deprecated Features
302 internals Technical implementation topics
302 internals Technical implementation topics
303 scripting Using Mercurial from scripts and automation
303 scripting Using Mercurial from scripts and automation
304
304
305 Test extension help:
305 Test extension help:
306 $ hg help extensions --config extensions.rebase= --config extensions.children=
306 $ hg help extensions --config extensions.rebase= --config extensions.children=
307 Using Additional Features
307 Using Additional Features
308 """""""""""""""""""""""""
308 """""""""""""""""""""""""
309
309
310 Mercurial has the ability to add new features through the use of
310 Mercurial has the ability to add new features through the use of
311 extensions. Extensions may add new commands, add options to existing
311 extensions. Extensions may add new commands, add options to existing
312 commands, change the default behavior of commands, or implement hooks.
312 commands, change the default behavior of commands, or implement hooks.
313
313
314 To enable the "foo" extension, either shipped with Mercurial or in the
314 To enable the "foo" extension, either shipped with Mercurial or in the
315 Python search path, create an entry for it in your configuration file,
315 Python search path, create an entry for it in your configuration file,
316 like this:
316 like this:
317
317
318 [extensions]
318 [extensions]
319 foo =
319 foo =
320
320
321 You may also specify the full path to an extension:
321 You may also specify the full path to an extension:
322
322
323 [extensions]
323 [extensions]
324 myfeature = ~/.hgext/myfeature.py
324 myfeature = ~/.hgext/myfeature.py
325
325
326 See 'hg help config' for more information on configuration files.
326 See 'hg help config' for more information on configuration files.
327
327
328 Extensions are not loaded by default for a variety of reasons: they can
328 Extensions are not loaded by default for a variety of reasons: they can
329 increase startup overhead; they may be meant for advanced usage only; they
329 increase startup overhead; they may be meant for advanced usage only; they
330 may provide potentially dangerous abilities (such as letting you destroy
330 may provide potentially dangerous abilities (such as letting you destroy
331 or modify history); they might not be ready for prime time; or they may
331 or modify history); they might not be ready for prime time; or they may
332 alter some usual behaviors of stock Mercurial. It is thus up to the user
332 alter some usual behaviors of stock Mercurial. It is thus up to the user
333 to activate extensions as needed.
333 to activate extensions as needed.
334
334
335 To explicitly disable an extension enabled in a configuration file of
335 To explicitly disable an extension enabled in a configuration file of
336 broader scope, prepend its path with !:
336 broader scope, prepend its path with !:
337
337
338 [extensions]
338 [extensions]
339 # disabling extension bar residing in /path/to/extension/bar.py
339 # disabling extension bar residing in /path/to/extension/bar.py
340 bar = !/path/to/extension/bar.py
340 bar = !/path/to/extension/bar.py
341 # ditto, but no path was supplied for extension baz
341 # ditto, but no path was supplied for extension baz
342 baz = !
342 baz = !
343
343
344 enabled extensions:
344 enabled extensions:
345
345
346 children command to display child changesets (DEPRECATED)
346 children command to display child changesets (DEPRECATED)
347 rebase command to move sets of revisions to a different ancestor
347 rebase command to move sets of revisions to a different ancestor
348
348
349 disabled extensions:
349 disabled extensions:
350
350
351 acl hooks for controlling repository access
351 acl hooks for controlling repository access
352 blackbox log repository events to a blackbox for debugging
352 blackbox log repository events to a blackbox for debugging
353 bugzilla hooks for integrating with the Bugzilla bug tracker
353 bugzilla hooks for integrating with the Bugzilla bug tracker
354 censor erase file content at a given revision
354 censor erase file content at a given revision
355 churn command to display statistics about repository history
355 churn command to display statistics about repository history
356 clonebundles advertise pre-generated bundles to seed clones
356 clonebundles advertise pre-generated bundles to seed clones
357 closehead close arbitrary heads without checking them out first
357 closehead close arbitrary heads without checking them out first
358 convert import revisions from foreign VCS repositories into
358 convert import revisions from foreign VCS repositories into
359 Mercurial
359 Mercurial
360 eol automatically manage newlines in repository files
360 eol automatically manage newlines in repository files
361 extdiff command to allow external programs to compare revisions
361 extdiff command to allow external programs to compare revisions
362 factotum http authentication with factotum
362 factotum http authentication with factotum
363 githelp try mapping git commands to Mercurial commands
363 githelp try mapping git commands to Mercurial commands
364 gpg commands to sign and verify changesets
364 gpg commands to sign and verify changesets
365 hgk browse the repository in a graphical way
365 hgk browse the repository in a graphical way
366 highlight syntax highlighting for hgweb (requires Pygments)
366 highlight syntax highlighting for hgweb (requires Pygments)
367 histedit interactive history editing
367 histedit interactive history editing
368 keyword expand keywords in tracked files
368 keyword expand keywords in tracked files
369 largefiles track large binary files
369 largefiles track large binary files
370 mq manage a stack of patches
370 mq manage a stack of patches
371 notify hooks for sending email push notifications
371 notify hooks for sending email push notifications
372 patchbomb command to send changesets as (a series of) patch emails
372 patchbomb command to send changesets as (a series of) patch emails
373 purge command to delete untracked files from the working
373 purge command to delete untracked files from the working
374 directory
374 directory
375 relink recreates hardlinks between repository clones
375 relink recreates hardlinks between repository clones
376 schemes extend schemes with shortcuts to repository swarms
376 schemes extend schemes with shortcuts to repository swarms
377 share share a common history between several working directories
377 share share a common history between several working directories
378 shelve save and restore changes to the working directory
378 shelve save and restore changes to the working directory
379 strip strip changesets and their descendants from history
379 strip strip changesets and their descendants from history
380 transplant command to transplant changesets from another branch
380 transplant command to transplant changesets from another branch
381 win32mbcs allow the use of MBCS paths with problematic encodings
381 win32mbcs allow the use of MBCS paths with problematic encodings
382 zeroconf discover and advertise repositories on the local network
382 zeroconf discover and advertise repositories on the local network
383
383
384 #endif
384 #endif
385
385
386 Verify that deprecated extensions are included if --verbose:
386 Verify that deprecated extensions are included if --verbose:
387
387
388 $ hg -v help extensions | grep children
388 $ hg -v help extensions | grep children
389 children command to display child changesets (DEPRECATED)
389 children command to display child changesets (DEPRECATED)
390
390
391 Verify that extension keywords appear in help templates
391 Verify that extension keywords appear in help templates
392
392
393 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
393 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
394
394
395 Test short command list with verbose option
395 Test short command list with verbose option
396
396
397 $ hg -v help shortlist
397 $ hg -v help shortlist
398 Mercurial Distributed SCM
398 Mercurial Distributed SCM
399
399
400 basic commands:
400 basic commands:
401
401
402 add add the specified files on the next commit
402 add add the specified files on the next commit
403 annotate, blame
403 annotate, blame
404 show changeset information by line for each file
404 show changeset information by line for each file
405 clone make a copy of an existing repository
405 clone make a copy of an existing repository
406 commit, ci commit the specified files or all outstanding changes
406 commit, ci commit the specified files or all outstanding changes
407 diff diff repository (or selected files)
407 diff diff repository (or selected files)
408 export dump the header and diffs for one or more changesets
408 export dump the header and diffs for one or more changesets
409 forget forget the specified files on the next commit
409 forget forget the specified files on the next commit
410 init create a new repository in the given directory
410 init create a new repository in the given directory
411 log, history show revision history of entire repository or files
411 log, history show revision history of entire repository or files
412 merge merge another revision into working directory
412 merge merge another revision into working directory
413 pull pull changes from the specified source
413 pull pull changes from the specified source
414 push push changes to the specified destination
414 push push changes to the specified destination
415 remove, rm remove the specified files on the next commit
415 remove, rm remove the specified files on the next commit
416 serve start stand-alone webserver
416 serve start stand-alone webserver
417 status, st show changed files in the working directory
417 status, st show changed files in the working directory
418 summary, sum summarize working directory state
418 summary, sum summarize working directory state
419 update, up, checkout, co
419 update, up, checkout, co
420 update working directory (or switch revisions)
420 update working directory (or switch revisions)
421
421
422 global options ([+] can be repeated):
422 global options ([+] can be repeated):
423
423
424 -R --repository REPO repository root directory or name of overlay bundle
424 -R --repository REPO repository root directory or name of overlay bundle
425 file
425 file
426 --cwd DIR change working directory
426 --cwd DIR change working directory
427 -y --noninteractive do not prompt, automatically pick the first choice for
427 -y --noninteractive do not prompt, automatically pick the first choice for
428 all prompts
428 all prompts
429 -q --quiet suppress output
429 -q --quiet suppress output
430 -v --verbose enable additional output
430 -v --verbose enable additional output
431 --color TYPE when to colorize (boolean, always, auto, never, or
431 --color TYPE when to colorize (boolean, always, auto, never, or
432 debug)
432 debug)
433 --config CONFIG [+] set/override config option (use 'section.name=value')
433 --config CONFIG [+] set/override config option (use 'section.name=value')
434 --debug enable debugging output
434 --debug enable debugging output
435 --debugger start debugger
435 --debugger start debugger
436 --encoding ENCODE set the charset encoding (default: ascii)
436 --encoding ENCODE set the charset encoding (default: ascii)
437 --encodingmode MODE set the charset encoding mode (default: strict)
437 --encodingmode MODE set the charset encoding mode (default: strict)
438 --traceback always print a traceback on exception
438 --traceback always print a traceback on exception
439 --time time how long the command takes
439 --time time how long the command takes
440 --profile print command execution profile
440 --profile print command execution profile
441 --version output version information and exit
441 --version output version information and exit
442 -h --help display help and exit
442 -h --help display help and exit
443 --hidden consider hidden changesets
443 --hidden consider hidden changesets
444 --pager TYPE when to paginate (boolean, always, auto, or never)
444 --pager TYPE when to paginate (boolean, always, auto, or never)
445 (default: auto)
445 (default: auto)
446
446
447 (use 'hg help' for the full list of commands)
447 (use 'hg help' for the full list of commands)
448
448
449 $ hg add -h
449 $ hg add -h
450 hg add [OPTION]... [FILE]...
450 hg add [OPTION]... [FILE]...
451
451
452 add the specified files on the next commit
452 add the specified files on the next commit
453
453
454 Schedule files to be version controlled and added to the repository.
454 Schedule files to be version controlled and added to the repository.
455
455
456 The files will be added to the repository at the next commit. To undo an
456 The files will be added to the repository at the next commit. To undo an
457 add before that, see 'hg forget'.
457 add before that, see 'hg forget'.
458
458
459 If no names are given, add all files to the repository (except files
459 If no names are given, add all files to the repository (except files
460 matching ".hgignore").
460 matching ".hgignore").
461
461
462 Returns 0 if all files are successfully added.
462 Returns 0 if all files are successfully added.
463
463
464 options ([+] can be repeated):
464 options ([+] can be repeated):
465
465
466 -I --include PATTERN [+] include names matching the given patterns
466 -I --include PATTERN [+] include names matching the given patterns
467 -X --exclude PATTERN [+] exclude names matching the given patterns
467 -X --exclude PATTERN [+] exclude names matching the given patterns
468 -S --subrepos recurse into subrepositories
468 -S --subrepos recurse into subrepositories
469 -n --dry-run do not perform actions, just print output
469 -n --dry-run do not perform actions, just print output
470
470
471 (some details hidden, use --verbose to show complete help)
471 (some details hidden, use --verbose to show complete help)
472
472
473 Verbose help for add
473 Verbose help for add
474
474
475 $ hg add -hv
475 $ hg add -hv
476 hg add [OPTION]... [FILE]...
476 hg add [OPTION]... [FILE]...
477
477
478 add the specified files on the next commit
478 add the specified files on the next commit
479
479
480 Schedule files to be version controlled and added to the repository.
480 Schedule files to be version controlled and added to the repository.
481
481
482 The files will be added to the repository at the next commit. To undo an
482 The files will be added to the repository at the next commit. To undo an
483 add before that, see 'hg forget'.
483 add before that, see 'hg forget'.
484
484
485 If no names are given, add all files to the repository (except files
485 If no names are given, add all files to the repository (except files
486 matching ".hgignore").
486 matching ".hgignore").
487
487
488 Examples:
488 Examples:
489
489
490 - New (unknown) files are added automatically by 'hg add':
490 - New (unknown) files are added automatically by 'hg add':
491
491
492 $ ls
492 $ ls
493 foo.c
493 foo.c
494 $ hg status
494 $ hg status
495 ? foo.c
495 ? foo.c
496 $ hg add
496 $ hg add
497 adding foo.c
497 adding foo.c
498 $ hg status
498 $ hg status
499 A foo.c
499 A foo.c
500
500
501 - Specific files to be added can be specified:
501 - Specific files to be added can be specified:
502
502
503 $ ls
503 $ ls
504 bar.c foo.c
504 bar.c foo.c
505 $ hg status
505 $ hg status
506 ? bar.c
506 ? bar.c
507 ? foo.c
507 ? foo.c
508 $ hg add bar.c
508 $ hg add bar.c
509 $ hg status
509 $ hg status
510 A bar.c
510 A bar.c
511 ? foo.c
511 ? foo.c
512
512
513 Returns 0 if all files are successfully added.
513 Returns 0 if all files are successfully added.
514
514
515 options ([+] can be repeated):
515 options ([+] can be repeated):
516
516
517 -I --include PATTERN [+] include names matching the given patterns
517 -I --include PATTERN [+] include names matching the given patterns
518 -X --exclude PATTERN [+] exclude names matching the given patterns
518 -X --exclude PATTERN [+] exclude names matching the given patterns
519 -S --subrepos recurse into subrepositories
519 -S --subrepos recurse into subrepositories
520 -n --dry-run do not perform actions, just print output
520 -n --dry-run do not perform actions, just print output
521
521
522 global options ([+] can be repeated):
522 global options ([+] can be repeated):
523
523
524 -R --repository REPO repository root directory or name of overlay bundle
524 -R --repository REPO repository root directory or name of overlay bundle
525 file
525 file
526 --cwd DIR change working directory
526 --cwd DIR change working directory
527 -y --noninteractive do not prompt, automatically pick the first choice for
527 -y --noninteractive do not prompt, automatically pick the first choice for
528 all prompts
528 all prompts
529 -q --quiet suppress output
529 -q --quiet suppress output
530 -v --verbose enable additional output
530 -v --verbose enable additional output
531 --color TYPE when to colorize (boolean, always, auto, never, or
531 --color TYPE when to colorize (boolean, always, auto, never, or
532 debug)
532 debug)
533 --config CONFIG [+] set/override config option (use 'section.name=value')
533 --config CONFIG [+] set/override config option (use 'section.name=value')
534 --debug enable debugging output
534 --debug enable debugging output
535 --debugger start debugger
535 --debugger start debugger
536 --encoding ENCODE set the charset encoding (default: ascii)
536 --encoding ENCODE set the charset encoding (default: ascii)
537 --encodingmode MODE set the charset encoding mode (default: strict)
537 --encodingmode MODE set the charset encoding mode (default: strict)
538 --traceback always print a traceback on exception
538 --traceback always print a traceback on exception
539 --time time how long the command takes
539 --time time how long the command takes
540 --profile print command execution profile
540 --profile print command execution profile
541 --version output version information and exit
541 --version output version information and exit
542 -h --help display help and exit
542 -h --help display help and exit
543 --hidden consider hidden changesets
543 --hidden consider hidden changesets
544 --pager TYPE when to paginate (boolean, always, auto, or never)
544 --pager TYPE when to paginate (boolean, always, auto, or never)
545 (default: auto)
545 (default: auto)
546
546
547 Test the textwidth config option
547 Test the textwidth config option
548
548
549 $ hg root -h --config ui.textwidth=50
549 $ hg root -h --config ui.textwidth=50
550 hg root
550 hg root
551
551
552 print the root (top) of the current working
552 print the root (top) of the current working
553 directory
553 directory
554
554
555 Print the root directory of the current
555 Print the root directory of the current
556 repository.
556 repository.
557
557
558 Returns 0 on success.
558 Returns 0 on success.
559
559
560 (some details hidden, use --verbose to show
560 (some details hidden, use --verbose to show
561 complete help)
561 complete help)
562
562
563 Test help option with version option
563 Test help option with version option
564
564
565 $ hg add -h --version
565 $ hg add -h --version
566 Mercurial Distributed SCM (version *) (glob)
566 Mercurial Distributed SCM (version *) (glob)
567 (see https://mercurial-scm.org for more information)
567 (see https://mercurial-scm.org for more information)
568
568
569 Copyright (C) 2005-* Matt Mackall and others (glob)
569 Copyright (C) 2005-* Matt Mackall and others (glob)
570 This is free software; see the source for copying conditions. There is NO
570 This is free software; see the source for copying conditions. There is NO
571 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
571 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
572
572
573 $ hg add --skjdfks
573 $ hg add --skjdfks
574 hg add: option --skjdfks not recognized
574 hg add: option --skjdfks not recognized
575 hg add [OPTION]... [FILE]...
575 hg add [OPTION]... [FILE]...
576
576
577 add the specified files on the next commit
577 add the specified files on the next commit
578
578
579 options ([+] can be repeated):
579 options ([+] can be repeated):
580
580
581 -I --include PATTERN [+] include names matching the given patterns
581 -I --include PATTERN [+] include names matching the given patterns
582 -X --exclude PATTERN [+] exclude names matching the given patterns
582 -X --exclude PATTERN [+] exclude names matching the given patterns
583 -S --subrepos recurse into subrepositories
583 -S --subrepos recurse into subrepositories
584 -n --dry-run do not perform actions, just print output
584 -n --dry-run do not perform actions, just print output
585
585
586 (use 'hg add -h' to show more help)
586 (use 'hg add -h' to show more help)
587 [255]
587 [255]
588
588
589 Test ambiguous command help
589 Test ambiguous command help
590
590
591 $ hg help ad
591 $ hg help ad
592 list of commands:
592 list of commands:
593
593
594 add add the specified files on the next commit
594 add add the specified files on the next commit
595 addremove add all new files, delete all missing files
595 addremove add all new files, delete all missing files
596
596
597 (use 'hg help -v ad' to show built-in aliases and global options)
597 (use 'hg help -v ad' to show built-in aliases and global options)
598
598
599 Test command without options
599 Test command without options
600
600
601 $ hg help verify
601 $ hg help verify
602 hg verify
602 hg verify
603
603
604 verify the integrity of the repository
604 verify the integrity of the repository
605
605
606 Verify the integrity of the current repository.
606 Verify the integrity of the current repository.
607
607
608 This will perform an extensive check of the repository's integrity,
608 This will perform an extensive check of the repository's integrity,
609 validating the hashes and checksums of each entry in the changelog,
609 validating the hashes and checksums of each entry in the changelog,
610 manifest, and tracked files, as well as the integrity of their crosslinks
610 manifest, and tracked files, as well as the integrity of their crosslinks
611 and indices.
611 and indices.
612
612
613 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
613 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
614 information about recovery from corruption of the repository.
614 information about recovery from corruption of the repository.
615
615
616 Returns 0 on success, 1 if errors are encountered.
616 Returns 0 on success, 1 if errors are encountered.
617
617
618 (some details hidden, use --verbose to show complete help)
618 (some details hidden, use --verbose to show complete help)
619
619
620 $ hg help diff
620 $ hg help diff
621 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
621 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
622
622
623 diff repository (or selected files)
623 diff repository (or selected files)
624
624
625 Show differences between revisions for the specified files.
625 Show differences between revisions for the specified files.
626
626
627 Differences between files are shown using the unified diff format.
627 Differences between files are shown using the unified diff format.
628
628
629 Note:
629 Note:
630 'hg diff' may generate unexpected results for merges, as it will
630 'hg diff' may generate unexpected results for merges, as it will
631 default to comparing against the working directory's first parent
631 default to comparing against the working directory's first parent
632 changeset if no revisions are specified.
632 changeset if no revisions are specified.
633
633
634 When two revision arguments are given, then changes are shown between
634 When two revision arguments are given, then changes are shown between
635 those revisions. If only one revision is specified then that revision is
635 those revisions. If only one revision is specified then that revision is
636 compared to the working directory, and, when no revisions are specified,
636 compared to the working directory, and, when no revisions are specified,
637 the working directory files are compared to its first parent.
637 the working directory files are compared to its first parent.
638
638
639 Alternatively you can specify -c/--change with a revision to see the
639 Alternatively you can specify -c/--change with a revision to see the
640 changes in that changeset relative to its first parent.
640 changes in that changeset relative to its first parent.
641
641
642 Without the -a/--text option, diff will avoid generating diffs of files it
642 Without the -a/--text option, diff will avoid generating diffs of files it
643 detects as binary. With -a, diff will generate a diff anyway, probably
643 detects as binary. With -a, diff will generate a diff anyway, probably
644 with undesirable results.
644 with undesirable results.
645
645
646 Use the -g/--git option to generate diffs in the git extended diff format.
646 Use the -g/--git option to generate diffs in the git extended diff format.
647 For more information, read 'hg help diffs'.
647 For more information, read 'hg help diffs'.
648
648
649 Returns 0 on success.
649 Returns 0 on success.
650
650
651 options ([+] can be repeated):
651 options ([+] can be repeated):
652
652
653 -r --rev REV [+] revision
653 -r --rev REV [+] revision
654 -c --change REV change made by revision
654 -c --change REV change made by revision
655 -a --text treat all files as text
655 -a --text treat all files as text
656 -g --git use git extended diff format
656 -g --git use git extended diff format
657 --binary generate binary diffs in git mode (default)
657 --binary generate binary diffs in git mode (default)
658 --nodates omit dates from diff headers
658 --nodates omit dates from diff headers
659 --noprefix omit a/ and b/ prefixes from filenames
659 --noprefix omit a/ and b/ prefixes from filenames
660 -p --show-function show which function each change is in
660 -p --show-function show which function each change is in
661 --reverse produce a diff that undoes the changes
661 --reverse produce a diff that undoes the changes
662 -w --ignore-all-space ignore white space when comparing lines
662 -w --ignore-all-space ignore white space when comparing lines
663 -b --ignore-space-change ignore changes in the amount of white space
663 -b --ignore-space-change ignore changes in the amount of white space
664 -B --ignore-blank-lines ignore changes whose lines are all blank
664 -B --ignore-blank-lines ignore changes whose lines are all blank
665 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
665 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
666 -U --unified NUM number of lines of context to show
666 -U --unified NUM number of lines of context to show
667 --stat output diffstat-style summary of changes
667 --stat output diffstat-style summary of changes
668 --root DIR produce diffs relative to subdirectory
668 --root DIR produce diffs relative to subdirectory
669 -I --include PATTERN [+] include names matching the given patterns
669 -I --include PATTERN [+] include names matching the given patterns
670 -X --exclude PATTERN [+] exclude names matching the given patterns
670 -X --exclude PATTERN [+] exclude names matching the given patterns
671 -S --subrepos recurse into subrepositories
671 -S --subrepos recurse into subrepositories
672
672
673 (some details hidden, use --verbose to show complete help)
673 (some details hidden, use --verbose to show complete help)
674
674
675 $ hg help status
675 $ hg help status
676 hg status [OPTION]... [FILE]...
676 hg status [OPTION]... [FILE]...
677
677
678 aliases: st
678 aliases: st
679
679
680 show changed files in the working directory
680 show changed files in the working directory
681
681
682 Show status of files in the repository. If names are given, only files
682 Show status of files in the repository. If names are given, only files
683 that match are shown. Files that are clean or ignored or the source of a
683 that match are shown. Files that are clean or ignored or the source of a
684 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
684 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
685 -C/--copies or -A/--all are given. Unless options described with "show
685 -C/--copies or -A/--all are given. Unless options described with "show
686 only ..." are given, the options -mardu are used.
686 only ..." are given, the options -mardu are used.
687
687
688 Option -q/--quiet hides untracked (unknown and ignored) files unless
688 Option -q/--quiet hides untracked (unknown and ignored) files unless
689 explicitly requested with -u/--unknown or -i/--ignored.
689 explicitly requested with -u/--unknown or -i/--ignored.
690
690
691 Note:
691 Note:
692 'hg status' may appear to disagree with diff if permissions have
692 'hg status' may appear to disagree with diff if permissions have
693 changed or a merge has occurred. The standard diff format does not
693 changed or a merge has occurred. The standard diff format does not
694 report permission changes and diff only reports changes relative to one
694 report permission changes and diff only reports changes relative to one
695 merge parent.
695 merge parent.
696
696
697 If one revision is given, it is used as the base revision. If two
697 If one revision is given, it is used as the base revision. If two
698 revisions are given, the differences between them are shown. The --change
698 revisions are given, the differences between them are shown. The --change
699 option can also be used as a shortcut to list the changed files of a
699 option can also be used as a shortcut to list the changed files of a
700 revision from its first parent.
700 revision from its first parent.
701
701
702 The codes used to show the status of files are:
702 The codes used to show the status of files are:
703
703
704 M = modified
704 M = modified
705 A = added
705 A = added
706 R = removed
706 R = removed
707 C = clean
707 C = clean
708 ! = missing (deleted by non-hg command, but still tracked)
708 ! = missing (deleted by non-hg command, but still tracked)
709 ? = not tracked
709 ? = not tracked
710 I = ignored
710 I = ignored
711 = origin of the previous file (with --copies)
711 = origin of the previous file (with --copies)
712
712
713 Returns 0 on success.
713 Returns 0 on success.
714
714
715 options ([+] can be repeated):
715 options ([+] can be repeated):
716
716
717 -A --all show status of all files
717 -A --all show status of all files
718 -m --modified show only modified files
718 -m --modified show only modified files
719 -a --added show only added files
719 -a --added show only added files
720 -r --removed show only removed files
720 -r --removed show only removed files
721 -d --deleted show only deleted (but tracked) files
721 -d --deleted show only deleted (but tracked) files
722 -c --clean show only files without changes
722 -c --clean show only files without changes
723 -u --unknown show only unknown (not tracked) files
723 -u --unknown show only unknown (not tracked) files
724 -i --ignored show only ignored files
724 -i --ignored show only ignored files
725 -n --no-status hide status prefix
725 -n --no-status hide status prefix
726 -C --copies show source of copied files
726 -C --copies show source of copied files
727 -0 --print0 end filenames with NUL, for use with xargs
727 -0 --print0 end filenames with NUL, for use with xargs
728 --rev REV [+] show difference from revision
728 --rev REV [+] show difference from revision
729 --change REV list the changed files of a revision
729 --change REV list the changed files of a revision
730 -I --include PATTERN [+] include names matching the given patterns
730 -I --include PATTERN [+] include names matching the given patterns
731 -X --exclude PATTERN [+] exclude names matching the given patterns
731 -X --exclude PATTERN [+] exclude names matching the given patterns
732 -S --subrepos recurse into subrepositories
732 -S --subrepos recurse into subrepositories
733 -T --template TEMPLATE display with template
733 -T --template TEMPLATE display with template
734
734
735 (some details hidden, use --verbose to show complete help)
735 (some details hidden, use --verbose to show complete help)
736
736
737 $ hg -q help status
737 $ hg -q help status
738 hg status [OPTION]... [FILE]...
738 hg status [OPTION]... [FILE]...
739
739
740 show changed files in the working directory
740 show changed files in the working directory
741
741
742 $ hg help foo
742 $ hg help foo
743 abort: no such help topic: foo
743 abort: no such help topic: foo
744 (try 'hg help --keyword foo')
744 (try 'hg help --keyword foo')
745 [255]
745 [255]
746
746
747 $ hg skjdfks
747 $ hg skjdfks
748 hg: unknown command 'skjdfks'
748 hg: unknown command 'skjdfks'
749 (use 'hg help' for a list of commands)
749 (use 'hg help' for a list of commands)
750 [255]
750 [255]
751
751
752 Typoed command gives suggestion
752 Typoed command gives suggestion
753 $ hg puls
753 $ hg puls
754 hg: unknown command 'puls'
754 hg: unknown command 'puls'
755 (did you mean one of pull, push?)
755 (did you mean one of pull, push?)
756 [255]
756 [255]
757
757
758 Not enabled extension gets suggested
758 Not enabled extension gets suggested
759
759
760 $ hg rebase
760 $ hg rebase
761 hg: unknown command 'rebase'
761 hg: unknown command 'rebase'
762 'rebase' is provided by the following extension:
762 'rebase' is provided by the following extension:
763
763
764 rebase command to move sets of revisions to a different ancestor
764 rebase command to move sets of revisions to a different ancestor
765
765
766 (use 'hg help extensions' for information on enabling extensions)
766 (use 'hg help extensions' for information on enabling extensions)
767 [255]
767 [255]
768
768
769 Disabled extension gets suggested
769 Disabled extension gets suggested
770 $ hg --config extensions.rebase=! rebase
770 $ hg --config extensions.rebase=! rebase
771 hg: unknown command 'rebase'
771 hg: unknown command 'rebase'
772 'rebase' is provided by the following extension:
772 'rebase' is provided by the following extension:
773
773
774 rebase command to move sets of revisions to a different ancestor
774 rebase command to move sets of revisions to a different ancestor
775
775
776 (use 'hg help extensions' for information on enabling extensions)
776 (use 'hg help extensions' for information on enabling extensions)
777 [255]
777 [255]
778
778
779 Make sure that we don't run afoul of the help system thinking that
779 Make sure that we don't run afoul of the help system thinking that
780 this is a section and erroring out weirdly.
780 this is a section and erroring out weirdly.
781
781
782 $ hg .log
782 $ hg .log
783 hg: unknown command '.log'
783 hg: unknown command '.log'
784 (did you mean log?)
784 (did you mean log?)
785 [255]
785 [255]
786
786
787 $ hg log.
787 $ hg log.
788 hg: unknown command 'log.'
788 hg: unknown command 'log.'
789 (did you mean log?)
789 (did you mean log?)
790 [255]
790 [255]
791 $ hg pu.lh
791 $ hg pu.lh
792 hg: unknown command 'pu.lh'
792 hg: unknown command 'pu.lh'
793 (did you mean one of pull, push?)
793 (did you mean one of pull, push?)
794 [255]
794 [255]
795
795
796 $ cat > helpext.py <<EOF
796 $ cat > helpext.py <<EOF
797 > import os
797 > import os
798 > from mercurial import commands, fancyopts, registrar
798 > from mercurial import commands, fancyopts, registrar
799 >
799 >
800 > def func(arg):
800 > def func(arg):
801 > return '%sfoo' % arg
801 > return '%sfoo' % arg
802 > class customopt(fancyopts.customopt):
802 > class customopt(fancyopts.customopt):
803 > def newstate(self, oldstate, newparam, abort):
803 > def newstate(self, oldstate, newparam, abort):
804 > return '%sbar' % oldstate
804 > return '%sbar' % oldstate
805 > cmdtable = {}
805 > cmdtable = {}
806 > command = registrar.command(cmdtable)
806 > command = registrar.command(cmdtable)
807 >
807 >
808 > @command(b'nohelp',
808 > @command(b'nohelp',
809 > [(b'', b'longdesc', 3, b'x'*67),
809 > [(b'', b'longdesc', 3, b'x'*67),
810 > (b'n', b'', None, b'normal desc'),
810 > (b'n', b'', None, b'normal desc'),
811 > (b'', b'newline', b'', b'line1\nline2'),
811 > (b'', b'newline', b'', b'line1\nline2'),
812 > (b'', b'callableopt', func, b'adds foo'),
812 > (b'', b'callableopt', func, b'adds foo'),
813 > (b'', b'customopt', customopt(''), b'adds bar'),
813 > (b'', b'customopt', customopt(''), b'adds bar'),
814 > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')],
814 > (b'', b'customopt-withdefault', customopt('foo'), b'adds bar')],
815 > b'hg nohelp',
815 > b'hg nohelp',
816 > norepo=True)
816 > norepo=True)
817 > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
817 > @command(b'debugoptADV', [(b'', b'aopt', None, b'option is (ADVANCED)')])
818 > @command(b'debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
818 > @command(b'debugoptDEP', [(b'', b'dopt', None, b'option is (DEPRECATED)')])
819 > @command(b'debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
819 > @command(b'debugoptEXP', [(b'', b'eopt', None, b'option is (EXPERIMENTAL)')])
820 > def nohelp(ui, *args, **kwargs):
820 > def nohelp(ui, *args, **kwargs):
821 > pass
821 > pass
822 >
822 >
823 > def uisetup(ui):
823 > def uisetup(ui):
824 > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
824 > ui.setconfig(b'alias', b'shellalias', b'!echo hi', b'helpext')
825 > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
825 > ui.setconfig(b'alias', b'hgalias', b'summary', b'helpext')
826 > ui.setconfig(b'alias', b'hgalias:doc', b'My doc', b'helpext')
827 > ui.setconfig(b'alias', b'hgalias:category', b'navigation', b'helpext')
828 > ui.setconfig(b'alias', b'hgaliasnodoc', b'summary', b'helpext')
826 >
829 >
827 > EOF
830 > EOF
828 $ echo '[extensions]' >> $HGRCPATH
831 $ echo '[extensions]' >> $HGRCPATH
829 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
832 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
830
833
831 Test for aliases
834 Test for aliases
832
835
836 $ hg help | grep hgalias
837 hgalias My doc
838
833 $ hg help hgalias
839 $ hg help hgalias
834 hg hgalias [--remote]
840 hg hgalias [--remote]
835
841
836 alias for: hg summary
842 alias for: hg summary
837
843
844 My doc
845
846 defined by: helpext
847
848 options:
849
850 --remote check for push and pull
851
852 (some details hidden, use --verbose to show complete help)
853 $ hg help hgaliasnodoc
854 hg hgaliasnodoc [--remote]
855
856 alias for: hg summary
857
838 summarize working directory state
858 summarize working directory state
839
859
840 This generates a brief summary of the working directory state, including
860 This generates a brief summary of the working directory state, including
841 parents, branch, commit status, phase and available updates.
861 parents, branch, commit status, phase and available updates.
842
862
843 With the --remote option, this will check the default paths for incoming
863 With the --remote option, this will check the default paths for incoming
844 and outgoing changes. This can be time-consuming.
864 and outgoing changes. This can be time-consuming.
845
865
846 Returns 0 on success.
866 Returns 0 on success.
847
867
848 defined by: helpext
868 defined by: helpext
849
869
850 options:
870 options:
851
871
852 --remote check for push and pull
872 --remote check for push and pull
853
873
854 (some details hidden, use --verbose to show complete help)
874 (some details hidden, use --verbose to show complete help)
855
875
856 $ hg help shellalias
876 $ hg help shellalias
857 hg shellalias
877 hg shellalias
858
878
859 shell alias for: echo hi
879 shell alias for: echo hi
860
880
861 (no help text available)
881 (no help text available)
862
882
863 defined by: helpext
883 defined by: helpext
864
884
865 (some details hidden, use --verbose to show complete help)
885 (some details hidden, use --verbose to show complete help)
866
886
867 Test command with no help text
887 Test command with no help text
868
888
869 $ hg help nohelp
889 $ hg help nohelp
870 hg nohelp
890 hg nohelp
871
891
872 (no help text available)
892 (no help text available)
873
893
874 options:
894 options:
875
895
876 --longdesc VALUE
896 --longdesc VALUE
877 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
897 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
878 xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
898 xxxxxxxxxxxxxxxxxxxxxxx (default: 3)
879 -n -- normal desc
899 -n -- normal desc
880 --newline VALUE line1 line2
900 --newline VALUE line1 line2
881 --callableopt VALUE adds foo
901 --callableopt VALUE adds foo
882 --customopt VALUE adds bar
902 --customopt VALUE adds bar
883 --customopt-withdefault VALUE adds bar (default: foo)
903 --customopt-withdefault VALUE adds bar (default: foo)
884
904
885 (some details hidden, use --verbose to show complete help)
905 (some details hidden, use --verbose to show complete help)
886
906
887 $ hg help -k nohelp
907 $ hg help -k nohelp
888 Commands:
908 Commands:
889
909
890 nohelp hg nohelp
910 nohelp hg nohelp
891
911
892 Extension Commands:
912 Extension Commands:
893
913
894 nohelp (no help text available)
914 nohelp (no help text available)
895
915
896 Test that default list of commands omits extension commands
916 Test that default list of commands omits extension commands
897
917
898 #if no-extraextensions
918 #if no-extraextensions
899
919
900 $ hg help
920 $ hg help
901 Mercurial Distributed SCM
921 Mercurial Distributed SCM
902
922
903 list of commands:
923 list of commands:
904
924
905 Repository creation:
925 Repository creation:
906
926
907 clone make a copy of an existing repository
927 clone make a copy of an existing repository
908 init create a new repository in the given directory
928 init create a new repository in the given directory
909
929
910 Remote repository management:
930 Remote repository management:
911
931
912 incoming show new changesets found in source
932 incoming show new changesets found in source
913 outgoing show changesets not found in the destination
933 outgoing show changesets not found in the destination
914 paths show aliases for remote repositories
934 paths show aliases for remote repositories
915 pull pull changes from the specified source
935 pull pull changes from the specified source
916 push push changes to the specified destination
936 push push changes to the specified destination
917 serve start stand-alone webserver
937 serve start stand-alone webserver
918
938
919 Change creation:
939 Change creation:
920
940
921 commit commit the specified files or all outstanding changes
941 commit commit the specified files or all outstanding changes
922
942
923 Change manipulation:
943 Change manipulation:
924
944
925 backout reverse effect of earlier changeset
945 backout reverse effect of earlier changeset
926 graft copy changes from other branches onto the current branch
946 graft copy changes from other branches onto the current branch
927 merge merge another revision into working directory
947 merge merge another revision into working directory
928
948
929 Change organization:
949 Change organization:
930
950
931 bookmarks create a new bookmark or list existing bookmarks
951 bookmarks create a new bookmark or list existing bookmarks
932 branch set or show the current branch name
952 branch set or show the current branch name
933 branches list repository named branches
953 branches list repository named branches
934 phase set or show the current phase name
954 phase set or show the current phase name
935 tag add one or more tags for the current or given revision
955 tag add one or more tags for the current or given revision
936 tags list repository tags
956 tags list repository tags
937
957
938 File content management:
958 File content management:
939
959
940 annotate show changeset information by line for each file
960 annotate show changeset information by line for each file
941 cat output the current or given revision of files
961 cat output the current or given revision of files
942 copy mark files as copied for the next commit
962 copy mark files as copied for the next commit
943 diff diff repository (or selected files)
963 diff diff repository (or selected files)
944 grep search revision history for a pattern in specified files
964 grep search revision history for a pattern in specified files
945
965
946 Change navigation:
966 Change navigation:
947
967
948 bisect subdivision search of changesets
968 bisect subdivision search of changesets
949 heads show branch heads
969 heads show branch heads
970 hgalias My doc
950 identify identify the working directory or specified revision
971 identify identify the working directory or specified revision
951 log show revision history of entire repository or files
972 log show revision history of entire repository or files
952
973
953 Working directory management:
974 Working directory management:
954
975
955 add add the specified files on the next commit
976 add add the specified files on the next commit
956 addremove add all new files, delete all missing files
977 addremove add all new files, delete all missing files
957 files list tracked files
978 files list tracked files
958 forget forget the specified files on the next commit
979 forget forget the specified files on the next commit
959 remove remove the specified files on the next commit
980 remove remove the specified files on the next commit
960 rename rename files; equivalent of copy + remove
981 rename rename files; equivalent of copy + remove
961 resolve redo merges or set/view the merge status of files
982 resolve redo merges or set/view the merge status of files
962 revert restore files to their checkout state
983 revert restore files to their checkout state
963 root print the root (top) of the current working directory
984 root print the root (top) of the current working directory
964 status show changed files in the working directory
985 status show changed files in the working directory
965 summary summarize working directory state
986 summary summarize working directory state
966 update update working directory (or switch revisions)
987 update update working directory (or switch revisions)
967
988
968 Change import/export:
989 Change import/export:
969
990
970 archive create an unversioned archive of a repository revision
991 archive create an unversioned archive of a repository revision
971 bundle create a bundle file
992 bundle create a bundle file
972 export dump the header and diffs for one or more changesets
993 export dump the header and diffs for one or more changesets
973 import import an ordered set of patches
994 import import an ordered set of patches
974 unbundle apply one or more bundle files
995 unbundle apply one or more bundle files
975
996
976 Repository maintenance:
997 Repository maintenance:
977
998
978 manifest output the current or given revision of the project manifest
999 manifest output the current or given revision of the project manifest
979 recover roll back an interrupted transaction
1000 recover roll back an interrupted transaction
980 verify verify the integrity of the repository
1001 verify verify the integrity of the repository
981
1002
982 Help:
1003 Help:
983
1004
984 config show combined config settings from all hgrc files
1005 config show combined config settings from all hgrc files
985 help show help for a given topic or a help overview
1006 help show help for a given topic or a help overview
986 version output version and copyright information
1007 version output version and copyright information
987
1008
988 enabled extensions:
1009 enabled extensions:
989
1010
990 helpext (no help text available)
1011 helpext (no help text available)
991
1012
992 additional help topics:
1013 additional help topics:
993
1014
994 Mercurial identifiers:
1015 Mercurial identifiers:
995
1016
996 filesets Specifying File Sets
1017 filesets Specifying File Sets
997 hgignore Syntax for Mercurial Ignore Files
1018 hgignore Syntax for Mercurial Ignore Files
998 patterns File Name Patterns
1019 patterns File Name Patterns
999 revisions Specifying Revisions
1020 revisions Specifying Revisions
1000 urls URL Paths
1021 urls URL Paths
1001
1022
1002 Mercurial output:
1023 Mercurial output:
1003
1024
1004 color Colorizing Outputs
1025 color Colorizing Outputs
1005 dates Date Formats
1026 dates Date Formats
1006 diffs Diff Formats
1027 diffs Diff Formats
1007 templating Template Usage
1028 templating Template Usage
1008
1029
1009 Mercurial configuration:
1030 Mercurial configuration:
1010
1031
1011 config Configuration Files
1032 config Configuration Files
1012 environment Environment Variables
1033 environment Environment Variables
1013 extensions Using Additional Features
1034 extensions Using Additional Features
1014 flags Command-line flags
1035 flags Command-line flags
1015 hgweb Configuring hgweb
1036 hgweb Configuring hgweb
1016 merge-tools Merge Tools
1037 merge-tools Merge Tools
1017 pager Pager Support
1038 pager Pager Support
1018
1039
1019 Concepts:
1040 Concepts:
1020
1041
1021 bundlespec Bundle File Formats
1042 bundlespec Bundle File Formats
1022 glossary Glossary
1043 glossary Glossary
1023 phases Working with Phases
1044 phases Working with Phases
1024 subrepos Subrepositories
1045 subrepos Subrepositories
1025
1046
1026 Miscellaneous:
1047 Miscellaneous:
1027
1048
1028 deprecated Deprecated Features
1049 deprecated Deprecated Features
1029 internals Technical implementation topics
1050 internals Technical implementation topics
1030 scripting Using Mercurial from scripts and automation
1051 scripting Using Mercurial from scripts and automation
1031
1052
1032 (use 'hg help -v' to show built-in aliases and global options)
1053 (use 'hg help -v' to show built-in aliases and global options)
1033
1054
1034 #endif
1055 #endif
1035
1056
1036 Test list of internal help commands
1057 Test list of internal help commands
1037
1058
1038 $ hg help debug
1059 $ hg help debug
1039 debug commands (internal and unsupported):
1060 debug commands (internal and unsupported):
1040
1061
1041 debugancestor
1062 debugancestor
1042 find the ancestor revision of two revisions in a given index
1063 find the ancestor revision of two revisions in a given index
1043 debugapplystreamclonebundle
1064 debugapplystreamclonebundle
1044 apply a stream clone bundle file
1065 apply a stream clone bundle file
1045 debugbuilddag
1066 debugbuilddag
1046 builds a repo with a given DAG from scratch in the current
1067 builds a repo with a given DAG from scratch in the current
1047 empty repo
1068 empty repo
1048 debugbundle lists the contents of a bundle
1069 debugbundle lists the contents of a bundle
1049 debugcapabilities
1070 debugcapabilities
1050 lists the capabilities of a remote peer
1071 lists the capabilities of a remote peer
1051 debugcheckstate
1072 debugcheckstate
1052 validate the correctness of the current dirstate
1073 validate the correctness of the current dirstate
1053 debugcolor show available color, effects or style
1074 debugcolor show available color, effects or style
1054 debugcommands
1075 debugcommands
1055 list all available commands and options
1076 list all available commands and options
1056 debugcomplete
1077 debugcomplete
1057 returns the completion list associated with the given command
1078 returns the completion list associated with the given command
1058 debugcreatestreamclonebundle
1079 debugcreatestreamclonebundle
1059 create a stream clone bundle file
1080 create a stream clone bundle file
1060 debugdag format the changelog or an index DAG as a concise textual
1081 debugdag format the changelog or an index DAG as a concise textual
1061 description
1082 description
1062 debugdata dump the contents of a data file revision
1083 debugdata dump the contents of a data file revision
1063 debugdate parse and display a date
1084 debugdate parse and display a date
1064 debugdeltachain
1085 debugdeltachain
1065 dump information about delta chains in a revlog
1086 dump information about delta chains in a revlog
1066 debugdirstate
1087 debugdirstate
1067 show the contents of the current dirstate
1088 show the contents of the current dirstate
1068 debugdiscovery
1089 debugdiscovery
1069 runs the changeset discovery protocol in isolation
1090 runs the changeset discovery protocol in isolation
1070 debugdownload
1091 debugdownload
1071 download a resource using Mercurial logic and config
1092 download a resource using Mercurial logic and config
1072 debugextensions
1093 debugextensions
1073 show information about active extensions
1094 show information about active extensions
1074 debugfileset parse and apply a fileset specification
1095 debugfileset parse and apply a fileset specification
1075 debugformat display format information about the current repository
1096 debugformat display format information about the current repository
1076 debugfsinfo show information detected about current filesystem
1097 debugfsinfo show information detected about current filesystem
1077 debuggetbundle
1098 debuggetbundle
1078 retrieves a bundle from a repo
1099 retrieves a bundle from a repo
1079 debugignore display the combined ignore pattern and information about
1100 debugignore display the combined ignore pattern and information about
1080 ignored files
1101 ignored files
1081 debugindex dump index data for a storage primitive
1102 debugindex dump index data for a storage primitive
1082 debugindexdot
1103 debugindexdot
1083 dump an index DAG as a graphviz dot file
1104 dump an index DAG as a graphviz dot file
1084 debugindexstats
1105 debugindexstats
1085 show stats related to the changelog index
1106 show stats related to the changelog index
1086 debuginstall test Mercurial installation
1107 debuginstall test Mercurial installation
1087 debugknown test whether node ids are known to a repo
1108 debugknown test whether node ids are known to a repo
1088 debuglocks show or modify state of locks
1109 debuglocks show or modify state of locks
1089 debugmanifestfulltextcache
1110 debugmanifestfulltextcache
1090 show, clear or amend the contents of the manifest fulltext
1111 show, clear or amend the contents of the manifest fulltext
1091 cache
1112 cache
1092 debugmergestate
1113 debugmergestate
1093 print merge state
1114 print merge state
1094 debugnamecomplete
1115 debugnamecomplete
1095 complete "names" - tags, open branch names, bookmark names
1116 complete "names" - tags, open branch names, bookmark names
1096 debugobsolete
1117 debugobsolete
1097 create arbitrary obsolete marker
1118 create arbitrary obsolete marker
1098 debugoptADV (no help text available)
1119 debugoptADV (no help text available)
1099 debugoptDEP (no help text available)
1120 debugoptDEP (no help text available)
1100 debugoptEXP (no help text available)
1121 debugoptEXP (no help text available)
1101 debugpathcomplete
1122 debugpathcomplete
1102 complete part or all of a tracked path
1123 complete part or all of a tracked path
1103 debugpeer establish a connection to a peer repository
1124 debugpeer establish a connection to a peer repository
1104 debugpickmergetool
1125 debugpickmergetool
1105 examine which merge tool is chosen for specified file
1126 examine which merge tool is chosen for specified file
1106 debugpushkey access the pushkey key/value protocol
1127 debugpushkey access the pushkey key/value protocol
1107 debugpvec (no help text available)
1128 debugpvec (no help text available)
1108 debugrebuilddirstate
1129 debugrebuilddirstate
1109 rebuild the dirstate as it would look like for the given
1130 rebuild the dirstate as it would look like for the given
1110 revision
1131 revision
1111 debugrebuildfncache
1132 debugrebuildfncache
1112 rebuild the fncache file
1133 rebuild the fncache file
1113 debugrename dump rename information
1134 debugrename dump rename information
1114 debugrevlog show data and statistics about a revlog
1135 debugrevlog show data and statistics about a revlog
1115 debugrevlogindex
1136 debugrevlogindex
1116 dump the contents of a revlog index
1137 dump the contents of a revlog index
1117 debugrevspec parse and apply a revision specification
1138 debugrevspec parse and apply a revision specification
1118 debugserve run a server with advanced settings
1139 debugserve run a server with advanced settings
1119 debugsetparents
1140 debugsetparents
1120 manually set the parents of the current working directory
1141 manually set the parents of the current working directory
1121 debugssl test a secure connection to a server
1142 debugssl test a secure connection to a server
1122 debugsub (no help text available)
1143 debugsub (no help text available)
1123 debugsuccessorssets
1144 debugsuccessorssets
1124 show set of successors for revision
1145 show set of successors for revision
1125 debugtemplate
1146 debugtemplate
1126 parse and apply a template
1147 parse and apply a template
1127 debuguigetpass
1148 debuguigetpass
1128 show prompt to type password
1149 show prompt to type password
1129 debuguiprompt
1150 debuguiprompt
1130 show plain prompt
1151 show plain prompt
1131 debugupdatecaches
1152 debugupdatecaches
1132 warm all known caches in the repository
1153 warm all known caches in the repository
1133 debugupgraderepo
1154 debugupgraderepo
1134 upgrade a repository to use different features
1155 upgrade a repository to use different features
1135 debugwalk show how files match on given patterns
1156 debugwalk show how files match on given patterns
1136 debugwhyunstable
1157 debugwhyunstable
1137 explain instabilities of a changeset
1158 explain instabilities of a changeset
1138 debugwireargs
1159 debugwireargs
1139 (no help text available)
1160 (no help text available)
1140 debugwireproto
1161 debugwireproto
1141 send wire protocol commands to a server
1162 send wire protocol commands to a server
1142
1163
1143 (use 'hg help -v debug' to show built-in aliases and global options)
1164 (use 'hg help -v debug' to show built-in aliases and global options)
1144
1165
1145 internals topic renders index of available sub-topics
1166 internals topic renders index of available sub-topics
1146
1167
1147 $ hg help internals
1168 $ hg help internals
1148 Technical implementation topics
1169 Technical implementation topics
1149 """""""""""""""""""""""""""""""
1170 """""""""""""""""""""""""""""""
1150
1171
1151 To access a subtopic, use "hg help internals.{subtopic-name}"
1172 To access a subtopic, use "hg help internals.{subtopic-name}"
1152
1173
1153 bundle2 Bundle2
1174 bundle2 Bundle2
1154 bundles Bundles
1175 bundles Bundles
1155 cbor CBOR
1176 cbor CBOR
1156 censor Censor
1177 censor Censor
1157 changegroups Changegroups
1178 changegroups Changegroups
1158 config Config Registrar
1179 config Config Registrar
1159 requirements Repository Requirements
1180 requirements Repository Requirements
1160 revlogs Revision Logs
1181 revlogs Revision Logs
1161 wireprotocol Wire Protocol
1182 wireprotocol Wire Protocol
1162 wireprotocolrpc
1183 wireprotocolrpc
1163 Wire Protocol RPC
1184 Wire Protocol RPC
1164 wireprotocolv2
1185 wireprotocolv2
1165 Wire Protocol Version 2
1186 Wire Protocol Version 2
1166
1187
1167 sub-topics can be accessed
1188 sub-topics can be accessed
1168
1189
1169 $ hg help internals.changegroups
1190 $ hg help internals.changegroups
1170 Changegroups
1191 Changegroups
1171 """"""""""""
1192 """"""""""""
1172
1193
1173 Changegroups are representations of repository revlog data, specifically
1194 Changegroups are representations of repository revlog data, specifically
1174 the changelog data, root/flat manifest data, treemanifest data, and
1195 the changelog data, root/flat manifest data, treemanifest data, and
1175 filelogs.
1196 filelogs.
1176
1197
1177 There are 3 versions of changegroups: "1", "2", and "3". From a high-
1198 There are 3 versions of changegroups: "1", "2", and "3". From a high-
1178 level, versions "1" and "2" are almost exactly the same, with the only
1199 level, versions "1" and "2" are almost exactly the same, with the only
1179 difference being an additional item in the *delta header*. Version "3"
1200 difference being an additional item in the *delta header*. Version "3"
1180 adds support for storage flags in the *delta header* and optionally
1201 adds support for storage flags in the *delta header* and optionally
1181 exchanging treemanifests (enabled by setting an option on the
1202 exchanging treemanifests (enabled by setting an option on the
1182 "changegroup" part in the bundle2).
1203 "changegroup" part in the bundle2).
1183
1204
1184 Changegroups when not exchanging treemanifests consist of 3 logical
1205 Changegroups when not exchanging treemanifests consist of 3 logical
1185 segments:
1206 segments:
1186
1207
1187 +---------------------------------+
1208 +---------------------------------+
1188 | | | |
1209 | | | |
1189 | changeset | manifest | filelogs |
1210 | changeset | manifest | filelogs |
1190 | | | |
1211 | | | |
1191 | | | |
1212 | | | |
1192 +---------------------------------+
1213 +---------------------------------+
1193
1214
1194 When exchanging treemanifests, there are 4 logical segments:
1215 When exchanging treemanifests, there are 4 logical segments:
1195
1216
1196 +-------------------------------------------------+
1217 +-------------------------------------------------+
1197 | | | | |
1218 | | | | |
1198 | changeset | root | treemanifests | filelogs |
1219 | changeset | root | treemanifests | filelogs |
1199 | | manifest | | |
1220 | | manifest | | |
1200 | | | | |
1221 | | | | |
1201 +-------------------------------------------------+
1222 +-------------------------------------------------+
1202
1223
1203 The principle building block of each segment is a *chunk*. A *chunk* is a
1224 The principle building block of each segment is a *chunk*. A *chunk* is a
1204 framed piece of data:
1225 framed piece of data:
1205
1226
1206 +---------------------------------------+
1227 +---------------------------------------+
1207 | | |
1228 | | |
1208 | length | data |
1229 | length | data |
1209 | (4 bytes) | (<length - 4> bytes) |
1230 | (4 bytes) | (<length - 4> bytes) |
1210 | | |
1231 | | |
1211 +---------------------------------------+
1232 +---------------------------------------+
1212
1233
1213 All integers are big-endian signed integers. Each chunk starts with a
1234 All integers are big-endian signed integers. Each chunk starts with a
1214 32-bit integer indicating the length of the entire chunk (including the
1235 32-bit integer indicating the length of the entire chunk (including the
1215 length field itself).
1236 length field itself).
1216
1237
1217 There is a special case chunk that has a value of 0 for the length
1238 There is a special case chunk that has a value of 0 for the length
1218 ("0x00000000"). We call this an *empty chunk*.
1239 ("0x00000000"). We call this an *empty chunk*.
1219
1240
1220 Delta Groups
1241 Delta Groups
1221 ============
1242 ============
1222
1243
1223 A *delta group* expresses the content of a revlog as a series of deltas,
1244 A *delta group* expresses the content of a revlog as a series of deltas,
1224 or patches against previous revisions.
1245 or patches against previous revisions.
1225
1246
1226 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
1247 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
1227 to signal the end of the delta group:
1248 to signal the end of the delta group:
1228
1249
1229 +------------------------------------------------------------------------+
1250 +------------------------------------------------------------------------+
1230 | | | | | |
1251 | | | | | |
1231 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
1252 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
1232 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
1253 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
1233 | | | | | |
1254 | | | | | |
1234 +------------------------------------------------------------------------+
1255 +------------------------------------------------------------------------+
1235
1256
1236 Each *chunk*'s data consists of the following:
1257 Each *chunk*'s data consists of the following:
1237
1258
1238 +---------------------------------------+
1259 +---------------------------------------+
1239 | | |
1260 | | |
1240 | delta header | delta data |
1261 | delta header | delta data |
1241 | (various by version) | (various) |
1262 | (various by version) | (various) |
1242 | | |
1263 | | |
1243 +---------------------------------------+
1264 +---------------------------------------+
1244
1265
1245 The *delta data* is a series of *delta*s that describe a diff from an
1266 The *delta data* is a series of *delta*s that describe a diff from an
1246 existing entry (either that the recipient already has, or previously
1267 existing entry (either that the recipient already has, or previously
1247 specified in the bundle/changegroup).
1268 specified in the bundle/changegroup).
1248
1269
1249 The *delta header* is different between versions "1", "2", and "3" of the
1270 The *delta header* is different between versions "1", "2", and "3" of the
1250 changegroup format.
1271 changegroup format.
1251
1272
1252 Version 1 (headerlen=80):
1273 Version 1 (headerlen=80):
1253
1274
1254 +------------------------------------------------------+
1275 +------------------------------------------------------+
1255 | | | | |
1276 | | | | |
1256 | node | p1 node | p2 node | link node |
1277 | node | p1 node | p2 node | link node |
1257 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1278 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1258 | | | | |
1279 | | | | |
1259 +------------------------------------------------------+
1280 +------------------------------------------------------+
1260
1281
1261 Version 2 (headerlen=100):
1282 Version 2 (headerlen=100):
1262
1283
1263 +------------------------------------------------------------------+
1284 +------------------------------------------------------------------+
1264 | | | | | |
1285 | | | | | |
1265 | node | p1 node | p2 node | base node | link node |
1286 | node | p1 node | p2 node | base node | link node |
1266 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1287 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1267 | | | | | |
1288 | | | | | |
1268 +------------------------------------------------------------------+
1289 +------------------------------------------------------------------+
1269
1290
1270 Version 3 (headerlen=102):
1291 Version 3 (headerlen=102):
1271
1292
1272 +------------------------------------------------------------------------------+
1293 +------------------------------------------------------------------------------+
1273 | | | | | | |
1294 | | | | | | |
1274 | node | p1 node | p2 node | base node | link node | flags |
1295 | node | p1 node | p2 node | base node | link node | flags |
1275 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1296 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1276 | | | | | | |
1297 | | | | | | |
1277 +------------------------------------------------------------------------------+
1298 +------------------------------------------------------------------------------+
1278
1299
1279 The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
1300 The *delta data* consists of "chunklen - 4 - headerlen" bytes, which
1280 contain a series of *delta*s, densely packed (no separators). These deltas
1301 contain a series of *delta*s, densely packed (no separators). These deltas
1281 describe a diff from an existing entry (either that the recipient already
1302 describe a diff from an existing entry (either that the recipient already
1282 has, or previously specified in the bundle/changegroup). The format is
1303 has, or previously specified in the bundle/changegroup). The format is
1283 described more fully in "hg help internals.bdiff", but briefly:
1304 described more fully in "hg help internals.bdiff", but briefly:
1284
1305
1285 +---------------------------------------------------------------+
1306 +---------------------------------------------------------------+
1286 | | | | |
1307 | | | | |
1287 | start offset | end offset | new length | content |
1308 | start offset | end offset | new length | content |
1288 | (4 bytes) | (4 bytes) | (4 bytes) | (<new length> bytes) |
1309 | (4 bytes) | (4 bytes) | (4 bytes) | (<new length> bytes) |
1289 | | | | |
1310 | | | | |
1290 +---------------------------------------------------------------+
1311 +---------------------------------------------------------------+
1291
1312
1292 Please note that the length field in the delta data does *not* include
1313 Please note that the length field in the delta data does *not* include
1293 itself.
1314 itself.
1294
1315
1295 In version 1, the delta is always applied against the previous node from
1316 In version 1, the delta is always applied against the previous node from
1296 the changegroup or the first parent if this is the first entry in the
1317 the changegroup or the first parent if this is the first entry in the
1297 changegroup.
1318 changegroup.
1298
1319
1299 In version 2 and up, the delta base node is encoded in the entry in the
1320 In version 2 and up, the delta base node is encoded in the entry in the
1300 changegroup. This allows the delta to be expressed against any parent,
1321 changegroup. This allows the delta to be expressed against any parent,
1301 which can result in smaller deltas and more efficient encoding of data.
1322 which can result in smaller deltas and more efficient encoding of data.
1302
1323
1303 The *flags* field holds bitwise flags affecting the processing of revision
1324 The *flags* field holds bitwise flags affecting the processing of revision
1304 data. The following flags are defined:
1325 data. The following flags are defined:
1305
1326
1306 32768
1327 32768
1307 Censored revision. The revision's fulltext has been replaced by censor
1328 Censored revision. The revision's fulltext has been replaced by censor
1308 metadata. May only occur on file revisions.
1329 metadata. May only occur on file revisions.
1309
1330
1310 16384
1331 16384
1311 Ellipsis revision. Revision hash does not match data (likely due to
1332 Ellipsis revision. Revision hash does not match data (likely due to
1312 rewritten parents).
1333 rewritten parents).
1313
1334
1314 8192
1335 8192
1315 Externally stored. The revision fulltext contains "key:value" "\n"
1336 Externally stored. The revision fulltext contains "key:value" "\n"
1316 delimited metadata defining an object stored elsewhere. Used by the LFS
1337 delimited metadata defining an object stored elsewhere. Used by the LFS
1317 extension.
1338 extension.
1318
1339
1319 For historical reasons, the integer values are identical to revlog version
1340 For historical reasons, the integer values are identical to revlog version
1320 1 per-revision storage flags and correspond to bits being set in this
1341 1 per-revision storage flags and correspond to bits being set in this
1321 2-byte field. Bits were allocated starting from the most-significant bit,
1342 2-byte field. Bits were allocated starting from the most-significant bit,
1322 hence the reverse ordering and allocation of these flags.
1343 hence the reverse ordering and allocation of these flags.
1323
1344
1324 Changeset Segment
1345 Changeset Segment
1325 =================
1346 =================
1326
1347
1327 The *changeset segment* consists of a single *delta group* holding
1348 The *changeset segment* consists of a single *delta group* holding
1328 changelog data. The *empty chunk* at the end of the *delta group* denotes
1349 changelog data. The *empty chunk* at the end of the *delta group* denotes
1329 the boundary to the *manifest segment*.
1350 the boundary to the *manifest segment*.
1330
1351
1331 Manifest Segment
1352 Manifest Segment
1332 ================
1353 ================
1333
1354
1334 The *manifest segment* consists of a single *delta group* holding manifest
1355 The *manifest segment* consists of a single *delta group* holding manifest
1335 data. If treemanifests are in use, it contains only the manifest for the
1356 data. If treemanifests are in use, it contains only the manifest for the
1336 root directory of the repository. Otherwise, it contains the entire
1357 root directory of the repository. Otherwise, it contains the entire
1337 manifest data. The *empty chunk* at the end of the *delta group* denotes
1358 manifest data. The *empty chunk* at the end of the *delta group* denotes
1338 the boundary to the next segment (either the *treemanifests segment* or
1359 the boundary to the next segment (either the *treemanifests segment* or
1339 the *filelogs segment*, depending on version and the request options).
1360 the *filelogs segment*, depending on version and the request options).
1340
1361
1341 Treemanifests Segment
1362 Treemanifests Segment
1342 ---------------------
1363 ---------------------
1343
1364
1344 The *treemanifests segment* only exists in changegroup version "3", and
1365 The *treemanifests segment* only exists in changegroup version "3", and
1345 only if the 'treemanifest' param is part of the bundle2 changegroup part
1366 only if the 'treemanifest' param is part of the bundle2 changegroup part
1346 (it is not possible to use changegroup version 3 outside of bundle2).
1367 (it is not possible to use changegroup version 3 outside of bundle2).
1347 Aside from the filenames in the *treemanifests segment* containing a
1368 Aside from the filenames in the *treemanifests segment* containing a
1348 trailing "/" character, it behaves identically to the *filelogs segment*
1369 trailing "/" character, it behaves identically to the *filelogs segment*
1349 (see below). The final sub-segment is followed by an *empty chunk*
1370 (see below). The final sub-segment is followed by an *empty chunk*
1350 (logically, a sub-segment with filename size 0). This denotes the boundary
1371 (logically, a sub-segment with filename size 0). This denotes the boundary
1351 to the *filelogs segment*.
1372 to the *filelogs segment*.
1352
1373
1353 Filelogs Segment
1374 Filelogs Segment
1354 ================
1375 ================
1355
1376
1356 The *filelogs segment* consists of multiple sub-segments, each
1377 The *filelogs segment* consists of multiple sub-segments, each
1357 corresponding to an individual file whose data is being described:
1378 corresponding to an individual file whose data is being described:
1358
1379
1359 +--------------------------------------------------+
1380 +--------------------------------------------------+
1360 | | | | | |
1381 | | | | | |
1361 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
1382 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
1362 | | | | | (4 bytes) |
1383 | | | | | (4 bytes) |
1363 | | | | | |
1384 | | | | | |
1364 +--------------------------------------------------+
1385 +--------------------------------------------------+
1365
1386
1366 The final filelog sub-segment is followed by an *empty chunk* (logically,
1387 The final filelog sub-segment is followed by an *empty chunk* (logically,
1367 a sub-segment with filename size 0). This denotes the end of the segment
1388 a sub-segment with filename size 0). This denotes the end of the segment
1368 and of the overall changegroup.
1389 and of the overall changegroup.
1369
1390
1370 Each filelog sub-segment consists of the following:
1391 Each filelog sub-segment consists of the following:
1371
1392
1372 +------------------------------------------------------+
1393 +------------------------------------------------------+
1373 | | | |
1394 | | | |
1374 | filename length | filename | delta group |
1395 | filename length | filename | delta group |
1375 | (4 bytes) | (<length - 4> bytes) | (various) |
1396 | (4 bytes) | (<length - 4> bytes) | (various) |
1376 | | | |
1397 | | | |
1377 +------------------------------------------------------+
1398 +------------------------------------------------------+
1378
1399
1379 That is, a *chunk* consisting of the filename (not terminated or padded)
1400 That is, a *chunk* consisting of the filename (not terminated or padded)
1380 followed by N chunks constituting the *delta group* for this file. The
1401 followed by N chunks constituting the *delta group* for this file. The
1381 *empty chunk* at the end of each *delta group* denotes the boundary to the
1402 *empty chunk* at the end of each *delta group* denotes the boundary to the
1382 next filelog sub-segment.
1403 next filelog sub-segment.
1383
1404
1384 Test list of commands with command with no help text
1405 Test list of commands with command with no help text
1385
1406
1386 $ hg help helpext
1407 $ hg help helpext
1387 helpext extension - no help text available
1408 helpext extension - no help text available
1388
1409
1389 list of commands:
1410 list of commands:
1390
1411
1391 nohelp (no help text available)
1412 nohelp (no help text available)
1392
1413
1393 (use 'hg help -v helpext' to show built-in aliases and global options)
1414 (use 'hg help -v helpext' to show built-in aliases and global options)
1394
1415
1395
1416
1396 test advanced, deprecated and experimental options are hidden in command help
1417 test advanced, deprecated and experimental options are hidden in command help
1397 $ hg help debugoptADV
1418 $ hg help debugoptADV
1398 hg debugoptADV
1419 hg debugoptADV
1399
1420
1400 (no help text available)
1421 (no help text available)
1401
1422
1402 options:
1423 options:
1403
1424
1404 (some details hidden, use --verbose to show complete help)
1425 (some details hidden, use --verbose to show complete help)
1405 $ hg help debugoptDEP
1426 $ hg help debugoptDEP
1406 hg debugoptDEP
1427 hg debugoptDEP
1407
1428
1408 (no help text available)
1429 (no help text available)
1409
1430
1410 options:
1431 options:
1411
1432
1412 (some details hidden, use --verbose to show complete help)
1433 (some details hidden, use --verbose to show complete help)
1413
1434
1414 $ hg help debugoptEXP
1435 $ hg help debugoptEXP
1415 hg debugoptEXP
1436 hg debugoptEXP
1416
1437
1417 (no help text available)
1438 (no help text available)
1418
1439
1419 options:
1440 options:
1420
1441
1421 (some details hidden, use --verbose to show complete help)
1442 (some details hidden, use --verbose to show complete help)
1422
1443
1423 test advanced, deprecated and experimental options are shown with -v
1444 test advanced, deprecated and experimental options are shown with -v
1424 $ hg help -v debugoptADV | grep aopt
1445 $ hg help -v debugoptADV | grep aopt
1425 --aopt option is (ADVANCED)
1446 --aopt option is (ADVANCED)
1426 $ hg help -v debugoptDEP | grep dopt
1447 $ hg help -v debugoptDEP | grep dopt
1427 --dopt option is (DEPRECATED)
1448 --dopt option is (DEPRECATED)
1428 $ hg help -v debugoptEXP | grep eopt
1449 $ hg help -v debugoptEXP | grep eopt
1429 --eopt option is (EXPERIMENTAL)
1450 --eopt option is (EXPERIMENTAL)
1430
1451
1431 #if gettext
1452 #if gettext
1432 test deprecated option is hidden with translation with untranslated description
1453 test deprecated option is hidden with translation with untranslated description
1433 (use many globy for not failing on changed transaction)
1454 (use many globy for not failing on changed transaction)
1434 $ LANGUAGE=sv hg help debugoptDEP
1455 $ LANGUAGE=sv hg help debugoptDEP
1435 hg debugoptDEP
1456 hg debugoptDEP
1436
1457
1437 (*) (glob)
1458 (*) (glob)
1438
1459
1439 options:
1460 options:
1440
1461
1441 (some details hidden, use --verbose to show complete help)
1462 (some details hidden, use --verbose to show complete help)
1442 #endif
1463 #endif
1443
1464
1444 Test commands that collide with topics (issue4240)
1465 Test commands that collide with topics (issue4240)
1445
1466
1446 $ hg config -hq
1467 $ hg config -hq
1447 hg config [-u] [NAME]...
1468 hg config [-u] [NAME]...
1448
1469
1449 show combined config settings from all hgrc files
1470 show combined config settings from all hgrc files
1450 $ hg showconfig -hq
1471 $ hg showconfig -hq
1451 hg config [-u] [NAME]...
1472 hg config [-u] [NAME]...
1452
1473
1453 show combined config settings from all hgrc files
1474 show combined config settings from all hgrc files
1454
1475
1455 Test a help topic
1476 Test a help topic
1456
1477
1457 $ hg help dates
1478 $ hg help dates
1458 Date Formats
1479 Date Formats
1459 """"""""""""
1480 """"""""""""
1460
1481
1461 Some commands allow the user to specify a date, e.g.:
1482 Some commands allow the user to specify a date, e.g.:
1462
1483
1463 - backout, commit, import, tag: Specify the commit date.
1484 - backout, commit, import, tag: Specify the commit date.
1464 - log, revert, update: Select revision(s) by date.
1485 - log, revert, update: Select revision(s) by date.
1465
1486
1466 Many date formats are valid. Here are some examples:
1487 Many date formats are valid. Here are some examples:
1467
1488
1468 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1489 - "Wed Dec 6 13:18:29 2006" (local timezone assumed)
1469 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1490 - "Dec 6 13:18 -0600" (year assumed, time offset provided)
1470 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1491 - "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
1471 - "Dec 6" (midnight)
1492 - "Dec 6" (midnight)
1472 - "13:18" (today assumed)
1493 - "13:18" (today assumed)
1473 - "3:39" (3:39AM assumed)
1494 - "3:39" (3:39AM assumed)
1474 - "3:39pm" (15:39)
1495 - "3:39pm" (15:39)
1475 - "2006-12-06 13:18:29" (ISO 8601 format)
1496 - "2006-12-06 13:18:29" (ISO 8601 format)
1476 - "2006-12-6 13:18"
1497 - "2006-12-6 13:18"
1477 - "2006-12-6"
1498 - "2006-12-6"
1478 - "12-6"
1499 - "12-6"
1479 - "12/6"
1500 - "12/6"
1480 - "12/6/6" (Dec 6 2006)
1501 - "12/6/6" (Dec 6 2006)
1481 - "today" (midnight)
1502 - "today" (midnight)
1482 - "yesterday" (midnight)
1503 - "yesterday" (midnight)
1483 - "now" - right now
1504 - "now" - right now
1484
1505
1485 Lastly, there is Mercurial's internal format:
1506 Lastly, there is Mercurial's internal format:
1486
1507
1487 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1508 - "1165411109 0" (Wed Dec 6 13:18:29 2006 UTC)
1488
1509
1489 This is the internal representation format for dates. The first number is
1510 This is the internal representation format for dates. The first number is
1490 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1511 the number of seconds since the epoch (1970-01-01 00:00 UTC). The second
1491 is the offset of the local timezone, in seconds west of UTC (negative if
1512 is the offset of the local timezone, in seconds west of UTC (negative if
1492 the timezone is east of UTC).
1513 the timezone is east of UTC).
1493
1514
1494 The log command also accepts date ranges:
1515 The log command also accepts date ranges:
1495
1516
1496 - "<DATE" - at or before a given date/time
1517 - "<DATE" - at or before a given date/time
1497 - ">DATE" - on or after a given date/time
1518 - ">DATE" - on or after a given date/time
1498 - "DATE to DATE" - a date range, inclusive
1519 - "DATE to DATE" - a date range, inclusive
1499 - "-DAYS" - within a given number of days of today
1520 - "-DAYS" - within a given number of days of today
1500
1521
1501 Test repeated config section name
1522 Test repeated config section name
1502
1523
1503 $ hg help config.host
1524 $ hg help config.host
1504 "http_proxy.host"
1525 "http_proxy.host"
1505 Host name and (optional) port of the proxy server, for example
1526 Host name and (optional) port of the proxy server, for example
1506 "myproxy:8000".
1527 "myproxy:8000".
1507
1528
1508 "smtp.host"
1529 "smtp.host"
1509 Host name of mail server, e.g. "mail.example.com".
1530 Host name of mail server, e.g. "mail.example.com".
1510
1531
1511
1532
1512 Test section name with dot
1533 Test section name with dot
1513
1534
1514 $ hg help config.ui.username
1535 $ hg help config.ui.username
1515 "ui.username"
1536 "ui.username"
1516 The committer of a changeset created when running "commit". Typically
1537 The committer of a changeset created when running "commit". Typically
1517 a person's name and email address, e.g. "Fred Widget
1538 a person's name and email address, e.g. "Fred Widget
1518 <fred@example.com>". Environment variables in the username are
1539 <fred@example.com>". Environment variables in the username are
1519 expanded.
1540 expanded.
1520
1541
1521 (default: "$EMAIL" or "username@hostname". If the username in hgrc is
1542 (default: "$EMAIL" or "username@hostname". If the username in hgrc is
1522 empty, e.g. if the system admin set "username =" in the system hgrc,
1543 empty, e.g. if the system admin set "username =" in the system hgrc,
1523 it has to be specified manually or in a different hgrc file)
1544 it has to be specified manually or in a different hgrc file)
1524
1545
1525
1546
1526 $ hg help config.annotate.git
1547 $ hg help config.annotate.git
1527 abort: help section not found: config.annotate.git
1548 abort: help section not found: config.annotate.git
1528 [255]
1549 [255]
1529
1550
1530 $ hg help config.update.check
1551 $ hg help config.update.check
1531 "commands.update.check"
1552 "commands.update.check"
1532 Determines what level of checking 'hg update' will perform before
1553 Determines what level of checking 'hg update' will perform before
1533 moving to a destination revision. Valid values are "abort", "none",
1554 moving to a destination revision. Valid values are "abort", "none",
1534 "linear", and "noconflict". "abort" always fails if the working
1555 "linear", and "noconflict". "abort" always fails if the working
1535 directory has uncommitted changes. "none" performs no checking, and
1556 directory has uncommitted changes. "none" performs no checking, and
1536 may result in a merge with uncommitted changes. "linear" allows any
1557 may result in a merge with uncommitted changes. "linear" allows any
1537 update as long as it follows a straight line in the revision history,
1558 update as long as it follows a straight line in the revision history,
1538 and may trigger a merge with uncommitted changes. "noconflict" will
1559 and may trigger a merge with uncommitted changes. "noconflict" will
1539 allow any update which would not trigger a merge with uncommitted
1560 allow any update which would not trigger a merge with uncommitted
1540 changes, if any are present. (default: "linear")
1561 changes, if any are present. (default: "linear")
1541
1562
1542
1563
1543 $ hg help config.commands.update.check
1564 $ hg help config.commands.update.check
1544 "commands.update.check"
1565 "commands.update.check"
1545 Determines what level of checking 'hg update' will perform before
1566 Determines what level of checking 'hg update' will perform before
1546 moving to a destination revision. Valid values are "abort", "none",
1567 moving to a destination revision. Valid values are "abort", "none",
1547 "linear", and "noconflict". "abort" always fails if the working
1568 "linear", and "noconflict". "abort" always fails if the working
1548 directory has uncommitted changes. "none" performs no checking, and
1569 directory has uncommitted changes. "none" performs no checking, and
1549 may result in a merge with uncommitted changes. "linear" allows any
1570 may result in a merge with uncommitted changes. "linear" allows any
1550 update as long as it follows a straight line in the revision history,
1571 update as long as it follows a straight line in the revision history,
1551 and may trigger a merge with uncommitted changes. "noconflict" will
1572 and may trigger a merge with uncommitted changes. "noconflict" will
1552 allow any update which would not trigger a merge with uncommitted
1573 allow any update which would not trigger a merge with uncommitted
1553 changes, if any are present. (default: "linear")
1574 changes, if any are present. (default: "linear")
1554
1575
1555
1576
1556 $ hg help config.ommands.update.check
1577 $ hg help config.ommands.update.check
1557 abort: help section not found: config.ommands.update.check
1578 abort: help section not found: config.ommands.update.check
1558 [255]
1579 [255]
1559
1580
1560 Unrelated trailing paragraphs shouldn't be included
1581 Unrelated trailing paragraphs shouldn't be included
1561
1582
1562 $ hg help config.extramsg | grep '^$'
1583 $ hg help config.extramsg | grep '^$'
1563
1584
1564
1585
1565 Test capitalized section name
1586 Test capitalized section name
1566
1587
1567 $ hg help scripting.HGPLAIN > /dev/null
1588 $ hg help scripting.HGPLAIN > /dev/null
1568
1589
1569 Help subsection:
1590 Help subsection:
1570
1591
1571 $ hg help config.charsets |grep "Email example:" > /dev/null
1592 $ hg help config.charsets |grep "Email example:" > /dev/null
1572 [1]
1593 [1]
1573
1594
1574 Show nested definitions
1595 Show nested definitions
1575 ("profiling.type"[break]"ls"[break]"stat"[break])
1596 ("profiling.type"[break]"ls"[break]"stat"[break])
1576
1597
1577 $ hg help config.type | egrep '^$'|wc -l
1598 $ hg help config.type | egrep '^$'|wc -l
1578 \s*3 (re)
1599 \s*3 (re)
1579
1600
1580 $ hg help config.profiling.type.ls
1601 $ hg help config.profiling.type.ls
1581 "profiling.type.ls"
1602 "profiling.type.ls"
1582 Use Python's built-in instrumenting profiler. This profiler works on
1603 Use Python's built-in instrumenting profiler. This profiler works on
1583 all platforms, but each line number it reports is the first line of
1604 all platforms, but each line number it reports is the first line of
1584 a function. This restriction makes it difficult to identify the
1605 a function. This restriction makes it difficult to identify the
1585 expensive parts of a non-trivial function.
1606 expensive parts of a non-trivial function.
1586
1607
1587
1608
1588 Separate sections from subsections
1609 Separate sections from subsections
1589
1610
1590 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1611 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1591 "format"
1612 "format"
1592 --------
1613 --------
1593
1614
1594 "usegeneraldelta"
1615 "usegeneraldelta"
1595
1616
1596 "dotencode"
1617 "dotencode"
1597
1618
1598 "usefncache"
1619 "usefncache"
1599
1620
1600 "usestore"
1621 "usestore"
1601
1622
1602 "profiling"
1623 "profiling"
1603 -----------
1624 -----------
1604
1625
1605 "format"
1626 "format"
1606
1627
1607 "progress"
1628 "progress"
1608 ----------
1629 ----------
1609
1630
1610 "format"
1631 "format"
1611
1632
1612
1633
1613 Last item in help config.*:
1634 Last item in help config.*:
1614
1635
1615 $ hg help config.`hg help config|grep '^ "'| \
1636 $ hg help config.`hg help config|grep '^ "'| \
1616 > tail -1|sed 's![ "]*!!g'`| \
1637 > tail -1|sed 's![ "]*!!g'`| \
1617 > grep 'hg help -c config' > /dev/null
1638 > grep 'hg help -c config' > /dev/null
1618 [1]
1639 [1]
1619
1640
1620 note to use help -c for general hg help config:
1641 note to use help -c for general hg help config:
1621
1642
1622 $ hg help config |grep 'hg help -c config' > /dev/null
1643 $ hg help config |grep 'hg help -c config' > /dev/null
1623
1644
1624 Test templating help
1645 Test templating help
1625
1646
1626 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1647 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1627 desc String. The text of the changeset description.
1648 desc String. The text of the changeset description.
1628 diffstat String. Statistics of changes with the following format:
1649 diffstat String. Statistics of changes with the following format:
1629 firstline Any text. Returns the first line of text.
1650 firstline Any text. Returns the first line of text.
1630 nonempty Any text. Returns '(none)' if the string is empty.
1651 nonempty Any text. Returns '(none)' if the string is empty.
1631
1652
1632 Test deprecated items
1653 Test deprecated items
1633
1654
1634 $ hg help -v templating | grep currentbookmark
1655 $ hg help -v templating | grep currentbookmark
1635 currentbookmark
1656 currentbookmark
1636 $ hg help templating | (grep currentbookmark || true)
1657 $ hg help templating | (grep currentbookmark || true)
1637
1658
1638 Test help hooks
1659 Test help hooks
1639
1660
1640 $ cat > helphook1.py <<EOF
1661 $ cat > helphook1.py <<EOF
1641 > from mercurial import help
1662 > from mercurial import help
1642 >
1663 >
1643 > def rewrite(ui, topic, doc):
1664 > def rewrite(ui, topic, doc):
1644 > return doc + b'\nhelphook1\n'
1665 > return doc + b'\nhelphook1\n'
1645 >
1666 >
1646 > def extsetup(ui):
1667 > def extsetup(ui):
1647 > help.addtopichook(b'revisions', rewrite)
1668 > help.addtopichook(b'revisions', rewrite)
1648 > EOF
1669 > EOF
1649 $ cat > helphook2.py <<EOF
1670 $ cat > helphook2.py <<EOF
1650 > from mercurial import help
1671 > from mercurial import help
1651 >
1672 >
1652 > def rewrite(ui, topic, doc):
1673 > def rewrite(ui, topic, doc):
1653 > return doc + b'\nhelphook2\n'
1674 > return doc + b'\nhelphook2\n'
1654 >
1675 >
1655 > def extsetup(ui):
1676 > def extsetup(ui):
1656 > help.addtopichook(b'revisions', rewrite)
1677 > help.addtopichook(b'revisions', rewrite)
1657 > EOF
1678 > EOF
1658 $ echo '[extensions]' >> $HGRCPATH
1679 $ echo '[extensions]' >> $HGRCPATH
1659 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1680 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1660 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1681 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1661 $ hg help revsets | grep helphook
1682 $ hg help revsets | grep helphook
1662 helphook1
1683 helphook1
1663 helphook2
1684 helphook2
1664
1685
1665 help -c should only show debug --debug
1686 help -c should only show debug --debug
1666
1687
1667 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1688 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1668 [1]
1689 [1]
1669
1690
1670 help -c should only show deprecated for -v
1691 help -c should only show deprecated for -v
1671
1692
1672 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1693 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1673 [1]
1694 [1]
1674
1695
1675 Test -s / --system
1696 Test -s / --system
1676
1697
1677 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1698 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1678 > wc -l | sed -e 's/ //g'
1699 > wc -l | sed -e 's/ //g'
1679 0
1700 0
1680 $ hg help config.files --system unix | grep 'USER' | \
1701 $ hg help config.files --system unix | grep 'USER' | \
1681 > wc -l | sed -e 's/ //g'
1702 > wc -l | sed -e 's/ //g'
1682 0
1703 0
1683
1704
1684 Test -e / -c / -k combinations
1705 Test -e / -c / -k combinations
1685
1706
1686 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1707 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1687 Commands:
1708 Commands:
1688 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1709 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1689 Extensions:
1710 Extensions:
1690 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1711 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1691 Topics:
1712 Topics:
1692 Commands:
1713 Commands:
1693 Extensions:
1714 Extensions:
1694 Extension Commands:
1715 Extension Commands:
1695 $ hg help -c schemes
1716 $ hg help -c schemes
1696 abort: no such help topic: schemes
1717 abort: no such help topic: schemes
1697 (try 'hg help --keyword schemes')
1718 (try 'hg help --keyword schemes')
1698 [255]
1719 [255]
1699 $ hg help -e schemes |head -1
1720 $ hg help -e schemes |head -1
1700 schemes extension - extend schemes with shortcuts to repository swarms
1721 schemes extension - extend schemes with shortcuts to repository swarms
1701 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1722 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1702 Commands:
1723 Commands:
1703 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1724 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1704 Extensions:
1725 Extensions:
1705 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1726 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1706 Extensions:
1727 Extensions:
1707 Commands:
1728 Commands:
1708 $ hg help -c commit > /dev/null
1729 $ hg help -c commit > /dev/null
1709 $ hg help -e -c commit > /dev/null
1730 $ hg help -e -c commit > /dev/null
1710 $ hg help -e commit
1731 $ hg help -e commit
1711 abort: no such help topic: commit
1732 abort: no such help topic: commit
1712 (try 'hg help --keyword commit')
1733 (try 'hg help --keyword commit')
1713 [255]
1734 [255]
1714
1735
1715 Test keyword search help
1736 Test keyword search help
1716
1737
1717 $ cat > prefixedname.py <<EOF
1738 $ cat > prefixedname.py <<EOF
1718 > '''matched against word "clone"
1739 > '''matched against word "clone"
1719 > '''
1740 > '''
1720 > EOF
1741 > EOF
1721 $ echo '[extensions]' >> $HGRCPATH
1742 $ echo '[extensions]' >> $HGRCPATH
1722 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1743 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1723 $ hg help -k clone
1744 $ hg help -k clone
1724 Topics:
1745 Topics:
1725
1746
1726 config Configuration Files
1747 config Configuration Files
1727 extensions Using Additional Features
1748 extensions Using Additional Features
1728 glossary Glossary
1749 glossary Glossary
1729 phases Working with Phases
1750 phases Working with Phases
1730 subrepos Subrepositories
1751 subrepos Subrepositories
1731 urls URL Paths
1752 urls URL Paths
1732
1753
1733 Commands:
1754 Commands:
1734
1755
1735 bookmarks create a new bookmark or list existing bookmarks
1756 bookmarks create a new bookmark or list existing bookmarks
1736 clone make a copy of an existing repository
1757 clone make a copy of an existing repository
1737 paths show aliases for remote repositories
1758 paths show aliases for remote repositories
1738 pull pull changes from the specified source
1759 pull pull changes from the specified source
1739 update update working directory (or switch revisions)
1760 update update working directory (or switch revisions)
1740
1761
1741 Extensions:
1762 Extensions:
1742
1763
1743 clonebundles advertise pre-generated bundles to seed clones
1764 clonebundles advertise pre-generated bundles to seed clones
1744 narrow create clones which fetch history data for subset of files
1765 narrow create clones which fetch history data for subset of files
1745 (EXPERIMENTAL)
1766 (EXPERIMENTAL)
1746 prefixedname matched against word "clone"
1767 prefixedname matched against word "clone"
1747 relink recreates hardlinks between repository clones
1768 relink recreates hardlinks between repository clones
1748
1769
1749 Extension Commands:
1770 Extension Commands:
1750
1771
1751 qclone clone main and patch repository at same time
1772 qclone clone main and patch repository at same time
1752
1773
1753 Test unfound topic
1774 Test unfound topic
1754
1775
1755 $ hg help nonexistingtopicthatwillneverexisteverever
1776 $ hg help nonexistingtopicthatwillneverexisteverever
1756 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1777 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1757 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1778 (try 'hg help --keyword nonexistingtopicthatwillneverexisteverever')
1758 [255]
1779 [255]
1759
1780
1760 Test unfound keyword
1781 Test unfound keyword
1761
1782
1762 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1783 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1763 abort: no matches
1784 abort: no matches
1764 (try 'hg help' for a list of topics)
1785 (try 'hg help' for a list of topics)
1765 [255]
1786 [255]
1766
1787
1767 Test omit indicating for help
1788 Test omit indicating for help
1768
1789
1769 $ cat > addverboseitems.py <<EOF
1790 $ cat > addverboseitems.py <<EOF
1770 > '''extension to test omit indicating.
1791 > '''extension to test omit indicating.
1771 >
1792 >
1772 > This paragraph is never omitted (for extension)
1793 > This paragraph is never omitted (for extension)
1773 >
1794 >
1774 > .. container:: verbose
1795 > .. container:: verbose
1775 >
1796 >
1776 > This paragraph is omitted,
1797 > This paragraph is omitted,
1777 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1798 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1778 >
1799 >
1779 > This paragraph is never omitted, too (for extension)
1800 > This paragraph is never omitted, too (for extension)
1780 > '''
1801 > '''
1781 > from __future__ import absolute_import
1802 > from __future__ import absolute_import
1782 > from mercurial import commands, help
1803 > from mercurial import commands, help
1783 > testtopic = b"""This paragraph is never omitted (for topic).
1804 > testtopic = b"""This paragraph is never omitted (for topic).
1784 >
1805 >
1785 > .. container:: verbose
1806 > .. container:: verbose
1786 >
1807 >
1787 > This paragraph is omitted,
1808 > This paragraph is omitted,
1788 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1809 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1789 >
1810 >
1790 > This paragraph is never omitted, too (for topic)
1811 > This paragraph is never omitted, too (for topic)
1791 > """
1812 > """
1792 > def extsetup(ui):
1813 > def extsetup(ui):
1793 > help.helptable.append(([b"topic-containing-verbose"],
1814 > help.helptable.append(([b"topic-containing-verbose"],
1794 > b"This is the topic to test omit indicating.",
1815 > b"This is the topic to test omit indicating.",
1795 > lambda ui: testtopic))
1816 > lambda ui: testtopic))
1796 > EOF
1817 > EOF
1797 $ echo '[extensions]' >> $HGRCPATH
1818 $ echo '[extensions]' >> $HGRCPATH
1798 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1819 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1799 $ hg help addverboseitems
1820 $ hg help addverboseitems
1800 addverboseitems extension - extension to test omit indicating.
1821 addverboseitems extension - extension to test omit indicating.
1801
1822
1802 This paragraph is never omitted (for extension)
1823 This paragraph is never omitted (for extension)
1803
1824
1804 This paragraph is never omitted, too (for extension)
1825 This paragraph is never omitted, too (for extension)
1805
1826
1806 (some details hidden, use --verbose to show complete help)
1827 (some details hidden, use --verbose to show complete help)
1807
1828
1808 no commands defined
1829 no commands defined
1809 $ hg help -v addverboseitems
1830 $ hg help -v addverboseitems
1810 addverboseitems extension - extension to test omit indicating.
1831 addverboseitems extension - extension to test omit indicating.
1811
1832
1812 This paragraph is never omitted (for extension)
1833 This paragraph is never omitted (for extension)
1813
1834
1814 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1835 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1815 extension)
1836 extension)
1816
1837
1817 This paragraph is never omitted, too (for extension)
1838 This paragraph is never omitted, too (for extension)
1818
1839
1819 no commands defined
1840 no commands defined
1820 $ hg help topic-containing-verbose
1841 $ hg help topic-containing-verbose
1821 This is the topic to test omit indicating.
1842 This is the topic to test omit indicating.
1822 """"""""""""""""""""""""""""""""""""""""""
1843 """"""""""""""""""""""""""""""""""""""""""
1823
1844
1824 This paragraph is never omitted (for topic).
1845 This paragraph is never omitted (for topic).
1825
1846
1826 This paragraph is never omitted, too (for topic)
1847 This paragraph is never omitted, too (for topic)
1827
1848
1828 (some details hidden, use --verbose to show complete help)
1849 (some details hidden, use --verbose to show complete help)
1829 $ hg help -v topic-containing-verbose
1850 $ hg help -v topic-containing-verbose
1830 This is the topic to test omit indicating.
1851 This is the topic to test omit indicating.
1831 """"""""""""""""""""""""""""""""""""""""""
1852 """"""""""""""""""""""""""""""""""""""""""
1832
1853
1833 This paragraph is never omitted (for topic).
1854 This paragraph is never omitted (for topic).
1834
1855
1835 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1856 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1836 topic)
1857 topic)
1837
1858
1838 This paragraph is never omitted, too (for topic)
1859 This paragraph is never omitted, too (for topic)
1839
1860
1840 Test section lookup
1861 Test section lookup
1841
1862
1842 $ hg help revset.merge
1863 $ hg help revset.merge
1843 "merge()"
1864 "merge()"
1844 Changeset is a merge changeset.
1865 Changeset is a merge changeset.
1845
1866
1846 $ hg help glossary.dag
1867 $ hg help glossary.dag
1847 DAG
1868 DAG
1848 The repository of changesets of a distributed version control system
1869 The repository of changesets of a distributed version control system
1849 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1870 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1850 of nodes and edges, where nodes correspond to changesets and edges
1871 of nodes and edges, where nodes correspond to changesets and edges
1851 imply a parent -> child relation. This graph can be visualized by
1872 imply a parent -> child relation. This graph can be visualized by
1852 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1873 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1853 limited by the requirement for children to have at most two parents.
1874 limited by the requirement for children to have at most two parents.
1854
1875
1855
1876
1856 $ hg help hgrc.paths
1877 $ hg help hgrc.paths
1857 "paths"
1878 "paths"
1858 -------
1879 -------
1859
1880
1860 Assigns symbolic names and behavior to repositories.
1881 Assigns symbolic names and behavior to repositories.
1861
1882
1862 Options are symbolic names defining the URL or directory that is the
1883 Options are symbolic names defining the URL or directory that is the
1863 location of the repository. Example:
1884 location of the repository. Example:
1864
1885
1865 [paths]
1886 [paths]
1866 my_server = https://example.com/my_repo
1887 my_server = https://example.com/my_repo
1867 local_path = /home/me/repo
1888 local_path = /home/me/repo
1868
1889
1869 These symbolic names can be used from the command line. To pull from
1890 These symbolic names can be used from the command line. To pull from
1870 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1891 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1871 local_path'.
1892 local_path'.
1872
1893
1873 Options containing colons (":") denote sub-options that can influence
1894 Options containing colons (":") denote sub-options that can influence
1874 behavior for that specific path. Example:
1895 behavior for that specific path. Example:
1875
1896
1876 [paths]
1897 [paths]
1877 my_server = https://example.com/my_path
1898 my_server = https://example.com/my_path
1878 my_server:pushurl = ssh://example.com/my_path
1899 my_server:pushurl = ssh://example.com/my_path
1879
1900
1880 The following sub-options can be defined:
1901 The following sub-options can be defined:
1881
1902
1882 "pushurl"
1903 "pushurl"
1883 The URL to use for push operations. If not defined, the location
1904 The URL to use for push operations. If not defined, the location
1884 defined by the path's main entry is used.
1905 defined by the path's main entry is used.
1885
1906
1886 "pushrev"
1907 "pushrev"
1887 A revset defining which revisions to push by default.
1908 A revset defining which revisions to push by default.
1888
1909
1889 When 'hg push' is executed without a "-r" argument, the revset defined
1910 When 'hg push' is executed without a "-r" argument, the revset defined
1890 by this sub-option is evaluated to determine what to push.
1911 by this sub-option is evaluated to determine what to push.
1891
1912
1892 For example, a value of "." will push the working directory's revision
1913 For example, a value of "." will push the working directory's revision
1893 by default.
1914 by default.
1894
1915
1895 Revsets specifying bookmarks will not result in the bookmark being
1916 Revsets specifying bookmarks will not result in the bookmark being
1896 pushed.
1917 pushed.
1897
1918
1898 The following special named paths exist:
1919 The following special named paths exist:
1899
1920
1900 "default"
1921 "default"
1901 The URL or directory to use when no source or remote is specified.
1922 The URL or directory to use when no source or remote is specified.
1902
1923
1903 'hg clone' will automatically define this path to the location the
1924 'hg clone' will automatically define this path to the location the
1904 repository was cloned from.
1925 repository was cloned from.
1905
1926
1906 "default-push"
1927 "default-push"
1907 (deprecated) The URL or directory for the default 'hg push' location.
1928 (deprecated) The URL or directory for the default 'hg push' location.
1908 "default:pushurl" should be used instead.
1929 "default:pushurl" should be used instead.
1909
1930
1910 $ hg help glossary.mcguffin
1931 $ hg help glossary.mcguffin
1911 abort: help section not found: glossary.mcguffin
1932 abort: help section not found: glossary.mcguffin
1912 [255]
1933 [255]
1913
1934
1914 $ hg help glossary.mc.guffin
1935 $ hg help glossary.mc.guffin
1915 abort: help section not found: glossary.mc.guffin
1936 abort: help section not found: glossary.mc.guffin
1916 [255]
1937 [255]
1917
1938
1918 $ hg help template.files
1939 $ hg help template.files
1919 files List of strings. All files modified, added, or removed by
1940 files List of strings. All files modified, added, or removed by
1920 this changeset.
1941 this changeset.
1921 files(pattern)
1942 files(pattern)
1922 All files of the current changeset matching the pattern. See
1943 All files of the current changeset matching the pattern. See
1923 'hg help patterns'.
1944 'hg help patterns'.
1924
1945
1925 Test section lookup by translated message
1946 Test section lookup by translated message
1926
1947
1927 str.lower() instead of encoding.lower(str) on translated message might
1948 str.lower() instead of encoding.lower(str) on translated message might
1928 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1949 make message meaningless, because some encoding uses 0x41(A) - 0x5a(Z)
1929 as the second or later byte of multi-byte character.
1950 as the second or later byte of multi-byte character.
1930
1951
1931 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1952 For example, "\x8bL\x98^" (translation of "record" in ja_JP.cp932)
1932 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1953 contains 0x4c (L). str.lower() replaces 0x4c(L) by 0x6c(l) and this
1933 replacement makes message meaningless.
1954 replacement makes message meaningless.
1934
1955
1935 This tests that section lookup by translated string isn't broken by
1956 This tests that section lookup by translated string isn't broken by
1936 such str.lower().
1957 such str.lower().
1937
1958
1938 $ "$PYTHON" <<EOF
1959 $ "$PYTHON" <<EOF
1939 > def escape(s):
1960 > def escape(s):
1940 > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
1961 > return b''.join(b'\\u%x' % ord(uc) for uc in s.decode('cp932'))
1941 > # translation of "record" in ja_JP.cp932
1962 > # translation of "record" in ja_JP.cp932
1942 > upper = b"\x8bL\x98^"
1963 > upper = b"\x8bL\x98^"
1943 > # str.lower()-ed section name should be treated as different one
1964 > # str.lower()-ed section name should be treated as different one
1944 > lower = b"\x8bl\x98^"
1965 > lower = b"\x8bl\x98^"
1945 > with open('ambiguous.py', 'wb') as fp:
1966 > with open('ambiguous.py', 'wb') as fp:
1946 > fp.write(b"""# ambiguous section names in ja_JP.cp932
1967 > fp.write(b"""# ambiguous section names in ja_JP.cp932
1947 > u'''summary of extension
1968 > u'''summary of extension
1948 >
1969 >
1949 > %s
1970 > %s
1950 > ----
1971 > ----
1951 >
1972 >
1952 > Upper name should show only this message
1973 > Upper name should show only this message
1953 >
1974 >
1954 > %s
1975 > %s
1955 > ----
1976 > ----
1956 >
1977 >
1957 > Lower name should show only this message
1978 > Lower name should show only this message
1958 >
1979 >
1959 > subsequent section
1980 > subsequent section
1960 > ------------------
1981 > ------------------
1961 >
1982 >
1962 > This should be hidden at 'hg help ambiguous' with section name.
1983 > This should be hidden at 'hg help ambiguous' with section name.
1963 > '''
1984 > '''
1964 > """ % (escape(upper), escape(lower)))
1985 > """ % (escape(upper), escape(lower)))
1965 > EOF
1986 > EOF
1966
1987
1967 $ cat >> $HGRCPATH <<EOF
1988 $ cat >> $HGRCPATH <<EOF
1968 > [extensions]
1989 > [extensions]
1969 > ambiguous = ./ambiguous.py
1990 > ambiguous = ./ambiguous.py
1970 > EOF
1991 > EOF
1971
1992
1972 $ "$PYTHON" <<EOF | sh
1993 $ "$PYTHON" <<EOF | sh
1973 > from mercurial import pycompat
1994 > from mercurial import pycompat
1974 > upper = b"\x8bL\x98^"
1995 > upper = b"\x8bL\x98^"
1975 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
1996 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % upper)
1976 > EOF
1997 > EOF
1977 \x8bL\x98^ (esc)
1998 \x8bL\x98^ (esc)
1978 ----
1999 ----
1979
2000
1980 Upper name should show only this message
2001 Upper name should show only this message
1981
2002
1982
2003
1983 $ "$PYTHON" <<EOF | sh
2004 $ "$PYTHON" <<EOF | sh
1984 > from mercurial import pycompat
2005 > from mercurial import pycompat
1985 > lower = b"\x8bl\x98^"
2006 > lower = b"\x8bl\x98^"
1986 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
2007 > pycompat.stdout.write(b"hg --encoding cp932 help -e ambiguous.%s\n" % lower)
1987 > EOF
2008 > EOF
1988 \x8bl\x98^ (esc)
2009 \x8bl\x98^ (esc)
1989 ----
2010 ----
1990
2011
1991 Lower name should show only this message
2012 Lower name should show only this message
1992
2013
1993
2014
1994 $ cat >> $HGRCPATH <<EOF
2015 $ cat >> $HGRCPATH <<EOF
1995 > [extensions]
2016 > [extensions]
1996 > ambiguous = !
2017 > ambiguous = !
1997 > EOF
2018 > EOF
1998
2019
1999 Show help content of disabled extensions
2020 Show help content of disabled extensions
2000
2021
2001 $ cat >> $HGRCPATH <<EOF
2022 $ cat >> $HGRCPATH <<EOF
2002 > [extensions]
2023 > [extensions]
2003 > ambiguous = !./ambiguous.py
2024 > ambiguous = !./ambiguous.py
2004 > EOF
2025 > EOF
2005 $ hg help -e ambiguous
2026 $ hg help -e ambiguous
2006 ambiguous extension - (no help text available)
2027 ambiguous extension - (no help text available)
2007
2028
2008 (use 'hg help extensions' for information on enabling extensions)
2029 (use 'hg help extensions' for information on enabling extensions)
2009
2030
2010 Test dynamic list of merge tools only shows up once
2031 Test dynamic list of merge tools only shows up once
2011 $ hg help merge-tools
2032 $ hg help merge-tools
2012 Merge Tools
2033 Merge Tools
2013 """""""""""
2034 """""""""""
2014
2035
2015 To merge files Mercurial uses merge tools.
2036 To merge files Mercurial uses merge tools.
2016
2037
2017 A merge tool combines two different versions of a file into a merged file.
2038 A merge tool combines two different versions of a file into a merged file.
2018 Merge tools are given the two files and the greatest common ancestor of
2039 Merge tools are given the two files and the greatest common ancestor of
2019 the two file versions, so they can determine the changes made on both
2040 the two file versions, so they can determine the changes made on both
2020 branches.
2041 branches.
2021
2042
2022 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
2043 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
2023 backout' and in several extensions.
2044 backout' and in several extensions.
2024
2045
2025 Usually, the merge tool tries to automatically reconcile the files by
2046 Usually, the merge tool tries to automatically reconcile the files by
2026 combining all non-overlapping changes that occurred separately in the two
2047 combining all non-overlapping changes that occurred separately in the two
2027 different evolutions of the same initial base file. Furthermore, some
2048 different evolutions of the same initial base file. Furthermore, some
2028 interactive merge programs make it easier to manually resolve conflicting
2049 interactive merge programs make it easier to manually resolve conflicting
2029 merges, either in a graphical way, or by inserting some conflict markers.
2050 merges, either in a graphical way, or by inserting some conflict markers.
2030 Mercurial does not include any interactive merge programs but relies on
2051 Mercurial does not include any interactive merge programs but relies on
2031 external tools for that.
2052 external tools for that.
2032
2053
2033 Available merge tools
2054 Available merge tools
2034 =====================
2055 =====================
2035
2056
2036 External merge tools and their properties are configured in the merge-
2057 External merge tools and their properties are configured in the merge-
2037 tools configuration section - see hgrc(5) - but they can often just be
2058 tools configuration section - see hgrc(5) - but they can often just be
2038 named by their executable.
2059 named by their executable.
2039
2060
2040 A merge tool is generally usable if its executable can be found on the
2061 A merge tool is generally usable if its executable can be found on the
2041 system and if it can handle the merge. The executable is found if it is an
2062 system and if it can handle the merge. The executable is found if it is an
2042 absolute or relative executable path or the name of an application in the
2063 absolute or relative executable path or the name of an application in the
2043 executable search path. The tool is assumed to be able to handle the merge
2064 executable search path. The tool is assumed to be able to handle the merge
2044 if it can handle symlinks if the file is a symlink, if it can handle
2065 if it can handle symlinks if the file is a symlink, if it can handle
2045 binary files if the file is binary, and if a GUI is available if the tool
2066 binary files if the file is binary, and if a GUI is available if the tool
2046 requires a GUI.
2067 requires a GUI.
2047
2068
2048 There are some internal merge tools which can be used. The internal merge
2069 There are some internal merge tools which can be used. The internal merge
2049 tools are:
2070 tools are:
2050
2071
2051 ":dump"
2072 ":dump"
2052 Creates three versions of the files to merge, containing the contents of
2073 Creates three versions of the files to merge, containing the contents of
2053 local, other and base. These files can then be used to perform a merge
2074 local, other and base. These files can then be used to perform a merge
2054 manually. If the file to be merged is named "a.txt", these files will
2075 manually. If the file to be merged is named "a.txt", these files will
2055 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
2076 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
2056 they will be placed in the same directory as "a.txt".
2077 they will be placed in the same directory as "a.txt".
2057
2078
2058 This implies premerge. Therefore, files aren't dumped, if premerge runs
2079 This implies premerge. Therefore, files aren't dumped, if premerge runs
2059 successfully. Use :forcedump to forcibly write files out.
2080 successfully. Use :forcedump to forcibly write files out.
2060
2081
2061 (actual capabilities: binary, symlink)
2082 (actual capabilities: binary, symlink)
2062
2083
2063 ":fail"
2084 ":fail"
2064 Rather than attempting to merge files that were modified on both
2085 Rather than attempting to merge files that were modified on both
2065 branches, it marks them as unresolved. The resolve command must be used
2086 branches, it marks them as unresolved. The resolve command must be used
2066 to resolve these conflicts.
2087 to resolve these conflicts.
2067
2088
2068 (actual capabilities: binary, symlink)
2089 (actual capabilities: binary, symlink)
2069
2090
2070 ":forcedump"
2091 ":forcedump"
2071 Creates three versions of the files as same as :dump, but omits
2092 Creates three versions of the files as same as :dump, but omits
2072 premerge.
2093 premerge.
2073
2094
2074 (actual capabilities: binary, symlink)
2095 (actual capabilities: binary, symlink)
2075
2096
2076 ":local"
2097 ":local"
2077 Uses the local 'p1()' version of files as the merged version.
2098 Uses the local 'p1()' version of files as the merged version.
2078
2099
2079 (actual capabilities: binary, symlink)
2100 (actual capabilities: binary, symlink)
2080
2101
2081 ":merge"
2102 ":merge"
2082 Uses the internal non-interactive simple merge algorithm for merging
2103 Uses the internal non-interactive simple merge algorithm for merging
2083 files. It will fail if there are any conflicts and leave markers in the
2104 files. It will fail if there are any conflicts and leave markers in the
2084 partially merged file. Markers will have two sections, one for each side
2105 partially merged file. Markers will have two sections, one for each side
2085 of merge.
2106 of merge.
2086
2107
2087 ":merge-local"
2108 ":merge-local"
2088 Like :merge, but resolve all conflicts non-interactively in favor of the
2109 Like :merge, but resolve all conflicts non-interactively in favor of the
2089 local 'p1()' changes.
2110 local 'p1()' changes.
2090
2111
2091 ":merge-other"
2112 ":merge-other"
2092 Like :merge, but resolve all conflicts non-interactively in favor of the
2113 Like :merge, but resolve all conflicts non-interactively in favor of the
2093 other 'p2()' changes.
2114 other 'p2()' changes.
2094
2115
2095 ":merge3"
2116 ":merge3"
2096 Uses the internal non-interactive simple merge algorithm for merging
2117 Uses the internal non-interactive simple merge algorithm for merging
2097 files. It will fail if there are any conflicts and leave markers in the
2118 files. It will fail if there are any conflicts and leave markers in the
2098 partially merged file. Marker will have three sections, one from each
2119 partially merged file. Marker will have three sections, one from each
2099 side of the merge and one for the base content.
2120 side of the merge and one for the base content.
2100
2121
2101 ":other"
2122 ":other"
2102 Uses the other 'p2()' version of files as the merged version.
2123 Uses the other 'p2()' version of files as the merged version.
2103
2124
2104 (actual capabilities: binary, symlink)
2125 (actual capabilities: binary, symlink)
2105
2126
2106 ":prompt"
2127 ":prompt"
2107 Asks the user which of the local 'p1()' or the other 'p2()' version to
2128 Asks the user which of the local 'p1()' or the other 'p2()' version to
2108 keep as the merged version.
2129 keep as the merged version.
2109
2130
2110 (actual capabilities: binary, symlink)
2131 (actual capabilities: binary, symlink)
2111
2132
2112 ":tagmerge"
2133 ":tagmerge"
2113 Uses the internal tag merge algorithm (experimental).
2134 Uses the internal tag merge algorithm (experimental).
2114
2135
2115 ":union"
2136 ":union"
2116 Uses the internal non-interactive simple merge algorithm for merging
2137 Uses the internal non-interactive simple merge algorithm for merging
2117 files. It will use both left and right sides for conflict regions. No
2138 files. It will use both left and right sides for conflict regions. No
2118 markers are inserted.
2139 markers are inserted.
2119
2140
2120 Internal tools are always available and do not require a GUI but will by
2141 Internal tools are always available and do not require a GUI but will by
2121 default not handle symlinks or binary files. See next section for detail
2142 default not handle symlinks or binary files. See next section for detail
2122 about "actual capabilities" described above.
2143 about "actual capabilities" described above.
2123
2144
2124 Choosing a merge tool
2145 Choosing a merge tool
2125 =====================
2146 =====================
2126
2147
2127 Mercurial uses these rules when deciding which merge tool to use:
2148 Mercurial uses these rules when deciding which merge tool to use:
2128
2149
2129 1. If a tool has been specified with the --tool option to merge or
2150 1. If a tool has been specified with the --tool option to merge or
2130 resolve, it is used. If it is the name of a tool in the merge-tools
2151 resolve, it is used. If it is the name of a tool in the merge-tools
2131 configuration, its configuration is used. Otherwise the specified tool
2152 configuration, its configuration is used. Otherwise the specified tool
2132 must be executable by the shell.
2153 must be executable by the shell.
2133 2. If the "HGMERGE" environment variable is present, its value is used and
2154 2. If the "HGMERGE" environment variable is present, its value is used and
2134 must be executable by the shell.
2155 must be executable by the shell.
2135 3. If the filename of the file to be merged matches any of the patterns in
2156 3. If the filename of the file to be merged matches any of the patterns in
2136 the merge-patterns configuration section, the first usable merge tool
2157 the merge-patterns configuration section, the first usable merge tool
2137 corresponding to a matching pattern is used.
2158 corresponding to a matching pattern is used.
2138 4. If ui.merge is set it will be considered next. If the value is not the
2159 4. If ui.merge is set it will be considered next. If the value is not the
2139 name of a configured tool, the specified value is used and must be
2160 name of a configured tool, the specified value is used and must be
2140 executable by the shell. Otherwise the named tool is used if it is
2161 executable by the shell. Otherwise the named tool is used if it is
2141 usable.
2162 usable.
2142 5. If any usable merge tools are present in the merge-tools configuration
2163 5. If any usable merge tools are present in the merge-tools configuration
2143 section, the one with the highest priority is used.
2164 section, the one with the highest priority is used.
2144 6. If a program named "hgmerge" can be found on the system, it is used -
2165 6. If a program named "hgmerge" can be found on the system, it is used -
2145 but it will by default not be used for symlinks and binary files.
2166 but it will by default not be used for symlinks and binary files.
2146 7. If the file to be merged is not binary and is not a symlink, then
2167 7. If the file to be merged is not binary and is not a symlink, then
2147 internal ":merge" is used.
2168 internal ":merge" is used.
2148 8. Otherwise, ":prompt" is used.
2169 8. Otherwise, ":prompt" is used.
2149
2170
2150 For historical reason, Mercurial treats merge tools as below while
2171 For historical reason, Mercurial treats merge tools as below while
2151 examining rules above.
2172 examining rules above.
2152
2173
2153 step specified via binary symlink
2174 step specified via binary symlink
2154 ----------------------------------
2175 ----------------------------------
2155 1. --tool o/o o/o
2176 1. --tool o/o o/o
2156 2. HGMERGE o/o o/o
2177 2. HGMERGE o/o o/o
2157 3. merge-patterns o/o(*) x/?(*)
2178 3. merge-patterns o/o(*) x/?(*)
2158 4. ui.merge x/?(*) x/?(*)
2179 4. ui.merge x/?(*) x/?(*)
2159
2180
2160 Each capability column indicates Mercurial behavior for internal/external
2181 Each capability column indicates Mercurial behavior for internal/external
2161 merge tools at examining each rule.
2182 merge tools at examining each rule.
2162
2183
2163 - "o": "assume that a tool has capability"
2184 - "o": "assume that a tool has capability"
2164 - "x": "assume that a tool does not have capability"
2185 - "x": "assume that a tool does not have capability"
2165 - "?": "check actual capability of a tool"
2186 - "?": "check actual capability of a tool"
2166
2187
2167 If "merge.strict-capability-check" configuration is true, Mercurial checks
2188 If "merge.strict-capability-check" configuration is true, Mercurial checks
2168 capabilities of merge tools strictly in (*) cases above (= each capability
2189 capabilities of merge tools strictly in (*) cases above (= each capability
2169 column becomes "?/?"). It is false by default for backward compatibility.
2190 column becomes "?/?"). It is false by default for backward compatibility.
2170
2191
2171 Note:
2192 Note:
2172 After selecting a merge program, Mercurial will by default attempt to
2193 After selecting a merge program, Mercurial will by default attempt to
2173 merge the files using a simple merge algorithm first. Only if it
2194 merge the files using a simple merge algorithm first. Only if it
2174 doesn't succeed because of conflicting changes will Mercurial actually
2195 doesn't succeed because of conflicting changes will Mercurial actually
2175 execute the merge program. Whether to use the simple merge algorithm
2196 execute the merge program. Whether to use the simple merge algorithm
2176 first can be controlled by the premerge setting of the merge tool.
2197 first can be controlled by the premerge setting of the merge tool.
2177 Premerge is enabled by default unless the file is binary or a symlink.
2198 Premerge is enabled by default unless the file is binary or a symlink.
2178
2199
2179 See the merge-tools and ui sections of hgrc(5) for details on the
2200 See the merge-tools and ui sections of hgrc(5) for details on the
2180 configuration of merge tools.
2201 configuration of merge tools.
2181
2202
2182 Compression engines listed in `hg help bundlespec`
2203 Compression engines listed in `hg help bundlespec`
2183
2204
2184 $ hg help bundlespec | grep gzip
2205 $ hg help bundlespec | grep gzip
2185 "v1" bundles can only use the "gzip", "bzip2", and "none" compression
2206 "v1" bundles can only use the "gzip", "bzip2", and "none" compression
2186 An algorithm that produces smaller bundles than "gzip".
2207 An algorithm that produces smaller bundles than "gzip".
2187 This engine will likely produce smaller bundles than "gzip" but will be
2208 This engine will likely produce smaller bundles than "gzip" but will be
2188 "gzip"
2209 "gzip"
2189 better compression than "gzip". It also frequently yields better (?)
2210 better compression than "gzip". It also frequently yields better (?)
2190
2211
2191 Test usage of section marks in help documents
2212 Test usage of section marks in help documents
2192
2213
2193 $ cd "$TESTDIR"/../doc
2214 $ cd "$TESTDIR"/../doc
2194 $ "$PYTHON" check-seclevel.py
2215 $ "$PYTHON" check-seclevel.py
2195 $ cd $TESTTMP
2216 $ cd $TESTTMP
2196
2217
2197 #if serve
2218 #if serve
2198
2219
2199 Test the help pages in hgweb.
2220 Test the help pages in hgweb.
2200
2221
2201 Dish up an empty repo; serve it cold.
2222 Dish up an empty repo; serve it cold.
2202
2223
2203 $ hg init "$TESTTMP/test"
2224 $ hg init "$TESTTMP/test"
2204 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
2225 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
2205 $ cat hg.pid >> $DAEMON_PIDS
2226 $ cat hg.pid >> $DAEMON_PIDS
2206
2227
2207 $ get-with-headers.py $LOCALIP:$HGPORT "help"
2228 $ get-with-headers.py $LOCALIP:$HGPORT "help"
2208 200 Script output follows
2229 200 Script output follows
2209
2230
2210 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2231 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2211 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2232 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2212 <head>
2233 <head>
2213 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2234 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2214 <meta name="robots" content="index, nofollow" />
2235 <meta name="robots" content="index, nofollow" />
2215 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2236 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2216 <script type="text/javascript" src="/static/mercurial.js"></script>
2237 <script type="text/javascript" src="/static/mercurial.js"></script>
2217
2238
2218 <title>Help: Index</title>
2239 <title>Help: Index</title>
2219 </head>
2240 </head>
2220 <body>
2241 <body>
2221
2242
2222 <div class="container">
2243 <div class="container">
2223 <div class="menu">
2244 <div class="menu">
2224 <div class="logo">
2245 <div class="logo">
2225 <a href="https://mercurial-scm.org/">
2246 <a href="https://mercurial-scm.org/">
2226 <img src="/static/hglogo.png" alt="mercurial" /></a>
2247 <img src="/static/hglogo.png" alt="mercurial" /></a>
2227 </div>
2248 </div>
2228 <ul>
2249 <ul>
2229 <li><a href="/shortlog">log</a></li>
2250 <li><a href="/shortlog">log</a></li>
2230 <li><a href="/graph">graph</a></li>
2251 <li><a href="/graph">graph</a></li>
2231 <li><a href="/tags">tags</a></li>
2252 <li><a href="/tags">tags</a></li>
2232 <li><a href="/bookmarks">bookmarks</a></li>
2253 <li><a href="/bookmarks">bookmarks</a></li>
2233 <li><a href="/branches">branches</a></li>
2254 <li><a href="/branches">branches</a></li>
2234 </ul>
2255 </ul>
2235 <ul>
2256 <ul>
2236 <li class="active">help</li>
2257 <li class="active">help</li>
2237 </ul>
2258 </ul>
2238 </div>
2259 </div>
2239
2260
2240 <div class="main">
2261 <div class="main">
2241 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2262 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2242
2263
2243 <form class="search" action="/log">
2264 <form class="search" action="/log">
2244
2265
2245 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2266 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2246 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2267 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2247 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2268 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2248 </form>
2269 </form>
2249 <table class="bigtable">
2270 <table class="bigtable">
2250 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2271 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
2251
2272
2252 <tr><td>
2273 <tr><td>
2253 <a href="/help/bundlespec">
2274 <a href="/help/bundlespec">
2254 bundlespec
2275 bundlespec
2255 </a>
2276 </a>
2256 </td><td>
2277 </td><td>
2257 Bundle File Formats
2278 Bundle File Formats
2258 </td></tr>
2279 </td></tr>
2259 <tr><td>
2280 <tr><td>
2260 <a href="/help/color">
2281 <a href="/help/color">
2261 color
2282 color
2262 </a>
2283 </a>
2263 </td><td>
2284 </td><td>
2264 Colorizing Outputs
2285 Colorizing Outputs
2265 </td></tr>
2286 </td></tr>
2266 <tr><td>
2287 <tr><td>
2267 <a href="/help/config">
2288 <a href="/help/config">
2268 config
2289 config
2269 </a>
2290 </a>
2270 </td><td>
2291 </td><td>
2271 Configuration Files
2292 Configuration Files
2272 </td></tr>
2293 </td></tr>
2273 <tr><td>
2294 <tr><td>
2274 <a href="/help/dates">
2295 <a href="/help/dates">
2275 dates
2296 dates
2276 </a>
2297 </a>
2277 </td><td>
2298 </td><td>
2278 Date Formats
2299 Date Formats
2279 </td></tr>
2300 </td></tr>
2280 <tr><td>
2301 <tr><td>
2281 <a href="/help/deprecated">
2302 <a href="/help/deprecated">
2282 deprecated
2303 deprecated
2283 </a>
2304 </a>
2284 </td><td>
2305 </td><td>
2285 Deprecated Features
2306 Deprecated Features
2286 </td></tr>
2307 </td></tr>
2287 <tr><td>
2308 <tr><td>
2288 <a href="/help/diffs">
2309 <a href="/help/diffs">
2289 diffs
2310 diffs
2290 </a>
2311 </a>
2291 </td><td>
2312 </td><td>
2292 Diff Formats
2313 Diff Formats
2293 </td></tr>
2314 </td></tr>
2294 <tr><td>
2315 <tr><td>
2295 <a href="/help/environment">
2316 <a href="/help/environment">
2296 environment
2317 environment
2297 </a>
2318 </a>
2298 </td><td>
2319 </td><td>
2299 Environment Variables
2320 Environment Variables
2300 </td></tr>
2321 </td></tr>
2301 <tr><td>
2322 <tr><td>
2302 <a href="/help/extensions">
2323 <a href="/help/extensions">
2303 extensions
2324 extensions
2304 </a>
2325 </a>
2305 </td><td>
2326 </td><td>
2306 Using Additional Features
2327 Using Additional Features
2307 </td></tr>
2328 </td></tr>
2308 <tr><td>
2329 <tr><td>
2309 <a href="/help/filesets">
2330 <a href="/help/filesets">
2310 filesets
2331 filesets
2311 </a>
2332 </a>
2312 </td><td>
2333 </td><td>
2313 Specifying File Sets
2334 Specifying File Sets
2314 </td></tr>
2335 </td></tr>
2315 <tr><td>
2336 <tr><td>
2316 <a href="/help/flags">
2337 <a href="/help/flags">
2317 flags
2338 flags
2318 </a>
2339 </a>
2319 </td><td>
2340 </td><td>
2320 Command-line flags
2341 Command-line flags
2321 </td></tr>
2342 </td></tr>
2322 <tr><td>
2343 <tr><td>
2323 <a href="/help/glossary">
2344 <a href="/help/glossary">
2324 glossary
2345 glossary
2325 </a>
2346 </a>
2326 </td><td>
2347 </td><td>
2327 Glossary
2348 Glossary
2328 </td></tr>
2349 </td></tr>
2329 <tr><td>
2350 <tr><td>
2330 <a href="/help/hgignore">
2351 <a href="/help/hgignore">
2331 hgignore
2352 hgignore
2332 </a>
2353 </a>
2333 </td><td>
2354 </td><td>
2334 Syntax for Mercurial Ignore Files
2355 Syntax for Mercurial Ignore Files
2335 </td></tr>
2356 </td></tr>
2336 <tr><td>
2357 <tr><td>
2337 <a href="/help/hgweb">
2358 <a href="/help/hgweb">
2338 hgweb
2359 hgweb
2339 </a>
2360 </a>
2340 </td><td>
2361 </td><td>
2341 Configuring hgweb
2362 Configuring hgweb
2342 </td></tr>
2363 </td></tr>
2343 <tr><td>
2364 <tr><td>
2344 <a href="/help/internals">
2365 <a href="/help/internals">
2345 internals
2366 internals
2346 </a>
2367 </a>
2347 </td><td>
2368 </td><td>
2348 Technical implementation topics
2369 Technical implementation topics
2349 </td></tr>
2370 </td></tr>
2350 <tr><td>
2371 <tr><td>
2351 <a href="/help/merge-tools">
2372 <a href="/help/merge-tools">
2352 merge-tools
2373 merge-tools
2353 </a>
2374 </a>
2354 </td><td>
2375 </td><td>
2355 Merge Tools
2376 Merge Tools
2356 </td></tr>
2377 </td></tr>
2357 <tr><td>
2378 <tr><td>
2358 <a href="/help/pager">
2379 <a href="/help/pager">
2359 pager
2380 pager
2360 </a>
2381 </a>
2361 </td><td>
2382 </td><td>
2362 Pager Support
2383 Pager Support
2363 </td></tr>
2384 </td></tr>
2364 <tr><td>
2385 <tr><td>
2365 <a href="/help/patterns">
2386 <a href="/help/patterns">
2366 patterns
2387 patterns
2367 </a>
2388 </a>
2368 </td><td>
2389 </td><td>
2369 File Name Patterns
2390 File Name Patterns
2370 </td></tr>
2391 </td></tr>
2371 <tr><td>
2392 <tr><td>
2372 <a href="/help/phases">
2393 <a href="/help/phases">
2373 phases
2394 phases
2374 </a>
2395 </a>
2375 </td><td>
2396 </td><td>
2376 Working with Phases
2397 Working with Phases
2377 </td></tr>
2398 </td></tr>
2378 <tr><td>
2399 <tr><td>
2379 <a href="/help/revisions">
2400 <a href="/help/revisions">
2380 revisions
2401 revisions
2381 </a>
2402 </a>
2382 </td><td>
2403 </td><td>
2383 Specifying Revisions
2404 Specifying Revisions
2384 </td></tr>
2405 </td></tr>
2385 <tr><td>
2406 <tr><td>
2386 <a href="/help/scripting">
2407 <a href="/help/scripting">
2387 scripting
2408 scripting
2388 </a>
2409 </a>
2389 </td><td>
2410 </td><td>
2390 Using Mercurial from scripts and automation
2411 Using Mercurial from scripts and automation
2391 </td></tr>
2412 </td></tr>
2392 <tr><td>
2413 <tr><td>
2393 <a href="/help/subrepos">
2414 <a href="/help/subrepos">
2394 subrepos
2415 subrepos
2395 </a>
2416 </a>
2396 </td><td>
2417 </td><td>
2397 Subrepositories
2418 Subrepositories
2398 </td></tr>
2419 </td></tr>
2399 <tr><td>
2420 <tr><td>
2400 <a href="/help/templating">
2421 <a href="/help/templating">
2401 templating
2422 templating
2402 </a>
2423 </a>
2403 </td><td>
2424 </td><td>
2404 Template Usage
2425 Template Usage
2405 </td></tr>
2426 </td></tr>
2406 <tr><td>
2427 <tr><td>
2407 <a href="/help/urls">
2428 <a href="/help/urls">
2408 urls
2429 urls
2409 </a>
2430 </a>
2410 </td><td>
2431 </td><td>
2411 URL Paths
2432 URL Paths
2412 </td></tr>
2433 </td></tr>
2413 <tr><td>
2434 <tr><td>
2414 <a href="/help/topic-containing-verbose">
2435 <a href="/help/topic-containing-verbose">
2415 topic-containing-verbose
2436 topic-containing-verbose
2416 </a>
2437 </a>
2417 </td><td>
2438 </td><td>
2418 This is the topic to test omit indicating.
2439 This is the topic to test omit indicating.
2419 </td></tr>
2440 </td></tr>
2420
2441
2421
2442
2422 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2443 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
2423
2444
2424 <tr><td>
2445 <tr><td>
2425 <a href="/help/add">
2446 <a href="/help/add">
2426 add
2447 add
2427 </a>
2448 </a>
2428 </td><td>
2449 </td><td>
2429 add the specified files on the next commit
2450 add the specified files on the next commit
2430 </td></tr>
2451 </td></tr>
2431 <tr><td>
2452 <tr><td>
2432 <a href="/help/annotate">
2453 <a href="/help/annotate">
2433 annotate
2454 annotate
2434 </a>
2455 </a>
2435 </td><td>
2456 </td><td>
2436 show changeset information by line for each file
2457 show changeset information by line for each file
2437 </td></tr>
2458 </td></tr>
2438 <tr><td>
2459 <tr><td>
2439 <a href="/help/clone">
2460 <a href="/help/clone">
2440 clone
2461 clone
2441 </a>
2462 </a>
2442 </td><td>
2463 </td><td>
2443 make a copy of an existing repository
2464 make a copy of an existing repository
2444 </td></tr>
2465 </td></tr>
2445 <tr><td>
2466 <tr><td>
2446 <a href="/help/commit">
2467 <a href="/help/commit">
2447 commit
2468 commit
2448 </a>
2469 </a>
2449 </td><td>
2470 </td><td>
2450 commit the specified files or all outstanding changes
2471 commit the specified files or all outstanding changes
2451 </td></tr>
2472 </td></tr>
2452 <tr><td>
2473 <tr><td>
2453 <a href="/help/diff">
2474 <a href="/help/diff">
2454 diff
2475 diff
2455 </a>
2476 </a>
2456 </td><td>
2477 </td><td>
2457 diff repository (or selected files)
2478 diff repository (or selected files)
2458 </td></tr>
2479 </td></tr>
2459 <tr><td>
2480 <tr><td>
2460 <a href="/help/export">
2481 <a href="/help/export">
2461 export
2482 export
2462 </a>
2483 </a>
2463 </td><td>
2484 </td><td>
2464 dump the header and diffs for one or more changesets
2485 dump the header and diffs for one or more changesets
2465 </td></tr>
2486 </td></tr>
2466 <tr><td>
2487 <tr><td>
2467 <a href="/help/forget">
2488 <a href="/help/forget">
2468 forget
2489 forget
2469 </a>
2490 </a>
2470 </td><td>
2491 </td><td>
2471 forget the specified files on the next commit
2492 forget the specified files on the next commit
2472 </td></tr>
2493 </td></tr>
2473 <tr><td>
2494 <tr><td>
2474 <a href="/help/init">
2495 <a href="/help/init">
2475 init
2496 init
2476 </a>
2497 </a>
2477 </td><td>
2498 </td><td>
2478 create a new repository in the given directory
2499 create a new repository in the given directory
2479 </td></tr>
2500 </td></tr>
2480 <tr><td>
2501 <tr><td>
2481 <a href="/help/log">
2502 <a href="/help/log">
2482 log
2503 log
2483 </a>
2504 </a>
2484 </td><td>
2505 </td><td>
2485 show revision history of entire repository or files
2506 show revision history of entire repository or files
2486 </td></tr>
2507 </td></tr>
2487 <tr><td>
2508 <tr><td>
2488 <a href="/help/merge">
2509 <a href="/help/merge">
2489 merge
2510 merge
2490 </a>
2511 </a>
2491 </td><td>
2512 </td><td>
2492 merge another revision into working directory
2513 merge another revision into working directory
2493 </td></tr>
2514 </td></tr>
2494 <tr><td>
2515 <tr><td>
2495 <a href="/help/pull">
2516 <a href="/help/pull">
2496 pull
2517 pull
2497 </a>
2518 </a>
2498 </td><td>
2519 </td><td>
2499 pull changes from the specified source
2520 pull changes from the specified source
2500 </td></tr>
2521 </td></tr>
2501 <tr><td>
2522 <tr><td>
2502 <a href="/help/push">
2523 <a href="/help/push">
2503 push
2524 push
2504 </a>
2525 </a>
2505 </td><td>
2526 </td><td>
2506 push changes to the specified destination
2527 push changes to the specified destination
2507 </td></tr>
2528 </td></tr>
2508 <tr><td>
2529 <tr><td>
2509 <a href="/help/remove">
2530 <a href="/help/remove">
2510 remove
2531 remove
2511 </a>
2532 </a>
2512 </td><td>
2533 </td><td>
2513 remove the specified files on the next commit
2534 remove the specified files on the next commit
2514 </td></tr>
2535 </td></tr>
2515 <tr><td>
2536 <tr><td>
2516 <a href="/help/serve">
2537 <a href="/help/serve">
2517 serve
2538 serve
2518 </a>
2539 </a>
2519 </td><td>
2540 </td><td>
2520 start stand-alone webserver
2541 start stand-alone webserver
2521 </td></tr>
2542 </td></tr>
2522 <tr><td>
2543 <tr><td>
2523 <a href="/help/status">
2544 <a href="/help/status">
2524 status
2545 status
2525 </a>
2546 </a>
2526 </td><td>
2547 </td><td>
2527 show changed files in the working directory
2548 show changed files in the working directory
2528 </td></tr>
2549 </td></tr>
2529 <tr><td>
2550 <tr><td>
2530 <a href="/help/summary">
2551 <a href="/help/summary">
2531 summary
2552 summary
2532 </a>
2553 </a>
2533 </td><td>
2554 </td><td>
2534 summarize working directory state
2555 summarize working directory state
2535 </td></tr>
2556 </td></tr>
2536 <tr><td>
2557 <tr><td>
2537 <a href="/help/update">
2558 <a href="/help/update">
2538 update
2559 update
2539 </a>
2560 </a>
2540 </td><td>
2561 </td><td>
2541 update working directory (or switch revisions)
2562 update working directory (or switch revisions)
2542 </td></tr>
2563 </td></tr>
2543
2564
2544
2565
2545
2566
2546 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2567 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
2547
2568
2548 <tr><td>
2569 <tr><td>
2549 <a href="/help/addremove">
2570 <a href="/help/addremove">
2550 addremove
2571 addremove
2551 </a>
2572 </a>
2552 </td><td>
2573 </td><td>
2553 add all new files, delete all missing files
2574 add all new files, delete all missing files
2554 </td></tr>
2575 </td></tr>
2555 <tr><td>
2576 <tr><td>
2556 <a href="/help/archive">
2577 <a href="/help/archive">
2557 archive
2578 archive
2558 </a>
2579 </a>
2559 </td><td>
2580 </td><td>
2560 create an unversioned archive of a repository revision
2581 create an unversioned archive of a repository revision
2561 </td></tr>
2582 </td></tr>
2562 <tr><td>
2583 <tr><td>
2563 <a href="/help/backout">
2584 <a href="/help/backout">
2564 backout
2585 backout
2565 </a>
2586 </a>
2566 </td><td>
2587 </td><td>
2567 reverse effect of earlier changeset
2588 reverse effect of earlier changeset
2568 </td></tr>
2589 </td></tr>
2569 <tr><td>
2590 <tr><td>
2570 <a href="/help/bisect">
2591 <a href="/help/bisect">
2571 bisect
2592 bisect
2572 </a>
2593 </a>
2573 </td><td>
2594 </td><td>
2574 subdivision search of changesets
2595 subdivision search of changesets
2575 </td></tr>
2596 </td></tr>
2576 <tr><td>
2597 <tr><td>
2577 <a href="/help/bookmarks">
2598 <a href="/help/bookmarks">
2578 bookmarks
2599 bookmarks
2579 </a>
2600 </a>
2580 </td><td>
2601 </td><td>
2581 create a new bookmark or list existing bookmarks
2602 create a new bookmark or list existing bookmarks
2582 </td></tr>
2603 </td></tr>
2583 <tr><td>
2604 <tr><td>
2584 <a href="/help/branch">
2605 <a href="/help/branch">
2585 branch
2606 branch
2586 </a>
2607 </a>
2587 </td><td>
2608 </td><td>
2588 set or show the current branch name
2609 set or show the current branch name
2589 </td></tr>
2610 </td></tr>
2590 <tr><td>
2611 <tr><td>
2591 <a href="/help/branches">
2612 <a href="/help/branches">
2592 branches
2613 branches
2593 </a>
2614 </a>
2594 </td><td>
2615 </td><td>
2595 list repository named branches
2616 list repository named branches
2596 </td></tr>
2617 </td></tr>
2597 <tr><td>
2618 <tr><td>
2598 <a href="/help/bundle">
2619 <a href="/help/bundle">
2599 bundle
2620 bundle
2600 </a>
2621 </a>
2601 </td><td>
2622 </td><td>
2602 create a bundle file
2623 create a bundle file
2603 </td></tr>
2624 </td></tr>
2604 <tr><td>
2625 <tr><td>
2605 <a href="/help/cat">
2626 <a href="/help/cat">
2606 cat
2627 cat
2607 </a>
2628 </a>
2608 </td><td>
2629 </td><td>
2609 output the current or given revision of files
2630 output the current or given revision of files
2610 </td></tr>
2631 </td></tr>
2611 <tr><td>
2632 <tr><td>
2612 <a href="/help/config">
2633 <a href="/help/config">
2613 config
2634 config
2614 </a>
2635 </a>
2615 </td><td>
2636 </td><td>
2616 show combined config settings from all hgrc files
2637 show combined config settings from all hgrc files
2617 </td></tr>
2638 </td></tr>
2618 <tr><td>
2639 <tr><td>
2619 <a href="/help/copy">
2640 <a href="/help/copy">
2620 copy
2641 copy
2621 </a>
2642 </a>
2622 </td><td>
2643 </td><td>
2623 mark files as copied for the next commit
2644 mark files as copied for the next commit
2624 </td></tr>
2645 </td></tr>
2625 <tr><td>
2646 <tr><td>
2626 <a href="/help/files">
2647 <a href="/help/files">
2627 files
2648 files
2628 </a>
2649 </a>
2629 </td><td>
2650 </td><td>
2630 list tracked files
2651 list tracked files
2631 </td></tr>
2652 </td></tr>
2632 <tr><td>
2653 <tr><td>
2633 <a href="/help/graft">
2654 <a href="/help/graft">
2634 graft
2655 graft
2635 </a>
2656 </a>
2636 </td><td>
2657 </td><td>
2637 copy changes from other branches onto the current branch
2658 copy changes from other branches onto the current branch
2638 </td></tr>
2659 </td></tr>
2639 <tr><td>
2660 <tr><td>
2640 <a href="/help/grep">
2661 <a href="/help/grep">
2641 grep
2662 grep
2642 </a>
2663 </a>
2643 </td><td>
2664 </td><td>
2644 search revision history for a pattern in specified files
2665 search revision history for a pattern in specified files
2645 </td></tr>
2666 </td></tr>
2646 <tr><td>
2667 <tr><td>
2647 <a href="/help/heads">
2668 <a href="/help/heads">
2648 heads
2669 heads
2649 </a>
2670 </a>
2650 </td><td>
2671 </td><td>
2651 show branch heads
2672 show branch heads
2652 </td></tr>
2673 </td></tr>
2653 <tr><td>
2674 <tr><td>
2654 <a href="/help/help">
2675 <a href="/help/help">
2655 help
2676 help
2656 </a>
2677 </a>
2657 </td><td>
2678 </td><td>
2658 show help for a given topic or a help overview
2679 show help for a given topic or a help overview
2659 </td></tr>
2680 </td></tr>
2660 <tr><td>
2681 <tr><td>
2661 <a href="/help/hgalias">
2682 <a href="/help/hgalias">
2662 hgalias
2683 hgalias
2663 </a>
2684 </a>
2664 </td><td>
2685 </td><td>
2686 My doc
2687 </td></tr>
2688 <tr><td>
2689 <a href="/help/hgaliasnodoc">
2690 hgaliasnodoc
2691 </a>
2692 </td><td>
2665 summarize working directory state
2693 summarize working directory state
2666 </td></tr>
2694 </td></tr>
2667 <tr><td>
2695 <tr><td>
2668 <a href="/help/identify">
2696 <a href="/help/identify">
2669 identify
2697 identify
2670 </a>
2698 </a>
2671 </td><td>
2699 </td><td>
2672 identify the working directory or specified revision
2700 identify the working directory or specified revision
2673 </td></tr>
2701 </td></tr>
2674 <tr><td>
2702 <tr><td>
2675 <a href="/help/import">
2703 <a href="/help/import">
2676 import
2704 import
2677 </a>
2705 </a>
2678 </td><td>
2706 </td><td>
2679 import an ordered set of patches
2707 import an ordered set of patches
2680 </td></tr>
2708 </td></tr>
2681 <tr><td>
2709 <tr><td>
2682 <a href="/help/incoming">
2710 <a href="/help/incoming">
2683 incoming
2711 incoming
2684 </a>
2712 </a>
2685 </td><td>
2713 </td><td>
2686 show new changesets found in source
2714 show new changesets found in source
2687 </td></tr>
2715 </td></tr>
2688 <tr><td>
2716 <tr><td>
2689 <a href="/help/manifest">
2717 <a href="/help/manifest">
2690 manifest
2718 manifest
2691 </a>
2719 </a>
2692 </td><td>
2720 </td><td>
2693 output the current or given revision of the project manifest
2721 output the current or given revision of the project manifest
2694 </td></tr>
2722 </td></tr>
2695 <tr><td>
2723 <tr><td>
2696 <a href="/help/nohelp">
2724 <a href="/help/nohelp">
2697 nohelp
2725 nohelp
2698 </a>
2726 </a>
2699 </td><td>
2727 </td><td>
2700 (no help text available)
2728 (no help text available)
2701 </td></tr>
2729 </td></tr>
2702 <tr><td>
2730 <tr><td>
2703 <a href="/help/outgoing">
2731 <a href="/help/outgoing">
2704 outgoing
2732 outgoing
2705 </a>
2733 </a>
2706 </td><td>
2734 </td><td>
2707 show changesets not found in the destination
2735 show changesets not found in the destination
2708 </td></tr>
2736 </td></tr>
2709 <tr><td>
2737 <tr><td>
2710 <a href="/help/paths">
2738 <a href="/help/paths">
2711 paths
2739 paths
2712 </a>
2740 </a>
2713 </td><td>
2741 </td><td>
2714 show aliases for remote repositories
2742 show aliases for remote repositories
2715 </td></tr>
2743 </td></tr>
2716 <tr><td>
2744 <tr><td>
2717 <a href="/help/phase">
2745 <a href="/help/phase">
2718 phase
2746 phase
2719 </a>
2747 </a>
2720 </td><td>
2748 </td><td>
2721 set or show the current phase name
2749 set or show the current phase name
2722 </td></tr>
2750 </td></tr>
2723 <tr><td>
2751 <tr><td>
2724 <a href="/help/recover">
2752 <a href="/help/recover">
2725 recover
2753 recover
2726 </a>
2754 </a>
2727 </td><td>
2755 </td><td>
2728 roll back an interrupted transaction
2756 roll back an interrupted transaction
2729 </td></tr>
2757 </td></tr>
2730 <tr><td>
2758 <tr><td>
2731 <a href="/help/rename">
2759 <a href="/help/rename">
2732 rename
2760 rename
2733 </a>
2761 </a>
2734 </td><td>
2762 </td><td>
2735 rename files; equivalent of copy + remove
2763 rename files; equivalent of copy + remove
2736 </td></tr>
2764 </td></tr>
2737 <tr><td>
2765 <tr><td>
2738 <a href="/help/resolve">
2766 <a href="/help/resolve">
2739 resolve
2767 resolve
2740 </a>
2768 </a>
2741 </td><td>
2769 </td><td>
2742 redo merges or set/view the merge status of files
2770 redo merges or set/view the merge status of files
2743 </td></tr>
2771 </td></tr>
2744 <tr><td>
2772 <tr><td>
2745 <a href="/help/revert">
2773 <a href="/help/revert">
2746 revert
2774 revert
2747 </a>
2775 </a>
2748 </td><td>
2776 </td><td>
2749 restore files to their checkout state
2777 restore files to their checkout state
2750 </td></tr>
2778 </td></tr>
2751 <tr><td>
2779 <tr><td>
2752 <a href="/help/root">
2780 <a href="/help/root">
2753 root
2781 root
2754 </a>
2782 </a>
2755 </td><td>
2783 </td><td>
2756 print the root (top) of the current working directory
2784 print the root (top) of the current working directory
2757 </td></tr>
2785 </td></tr>
2758 <tr><td>
2786 <tr><td>
2759 <a href="/help/shellalias">
2787 <a href="/help/shellalias">
2760 shellalias
2788 shellalias
2761 </a>
2789 </a>
2762 </td><td>
2790 </td><td>
2763 (no help text available)
2791 (no help text available)
2764 </td></tr>
2792 </td></tr>
2765 <tr><td>
2793 <tr><td>
2766 <a href="/help/tag">
2794 <a href="/help/tag">
2767 tag
2795 tag
2768 </a>
2796 </a>
2769 </td><td>
2797 </td><td>
2770 add one or more tags for the current or given revision
2798 add one or more tags for the current or given revision
2771 </td></tr>
2799 </td></tr>
2772 <tr><td>
2800 <tr><td>
2773 <a href="/help/tags">
2801 <a href="/help/tags">
2774 tags
2802 tags
2775 </a>
2803 </a>
2776 </td><td>
2804 </td><td>
2777 list repository tags
2805 list repository tags
2778 </td></tr>
2806 </td></tr>
2779 <tr><td>
2807 <tr><td>
2780 <a href="/help/unbundle">
2808 <a href="/help/unbundle">
2781 unbundle
2809 unbundle
2782 </a>
2810 </a>
2783 </td><td>
2811 </td><td>
2784 apply one or more bundle files
2812 apply one or more bundle files
2785 </td></tr>
2813 </td></tr>
2786 <tr><td>
2814 <tr><td>
2787 <a href="/help/verify">
2815 <a href="/help/verify">
2788 verify
2816 verify
2789 </a>
2817 </a>
2790 </td><td>
2818 </td><td>
2791 verify the integrity of the repository
2819 verify the integrity of the repository
2792 </td></tr>
2820 </td></tr>
2793 <tr><td>
2821 <tr><td>
2794 <a href="/help/version">
2822 <a href="/help/version">
2795 version
2823 version
2796 </a>
2824 </a>
2797 </td><td>
2825 </td><td>
2798 output version and copyright information
2826 output version and copyright information
2799 </td></tr>
2827 </td></tr>
2800
2828
2801
2829
2802 </table>
2830 </table>
2803 </div>
2831 </div>
2804 </div>
2832 </div>
2805
2833
2806
2834
2807
2835
2808 </body>
2836 </body>
2809 </html>
2837 </html>
2810
2838
2811
2839
2812 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2840 $ get-with-headers.py $LOCALIP:$HGPORT "help/add"
2813 200 Script output follows
2841 200 Script output follows
2814
2842
2815 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2843 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2816 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2844 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2817 <head>
2845 <head>
2818 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2846 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2819 <meta name="robots" content="index, nofollow" />
2847 <meta name="robots" content="index, nofollow" />
2820 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2848 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2821 <script type="text/javascript" src="/static/mercurial.js"></script>
2849 <script type="text/javascript" src="/static/mercurial.js"></script>
2822
2850
2823 <title>Help: add</title>
2851 <title>Help: add</title>
2824 </head>
2852 </head>
2825 <body>
2853 <body>
2826
2854
2827 <div class="container">
2855 <div class="container">
2828 <div class="menu">
2856 <div class="menu">
2829 <div class="logo">
2857 <div class="logo">
2830 <a href="https://mercurial-scm.org/">
2858 <a href="https://mercurial-scm.org/">
2831 <img src="/static/hglogo.png" alt="mercurial" /></a>
2859 <img src="/static/hglogo.png" alt="mercurial" /></a>
2832 </div>
2860 </div>
2833 <ul>
2861 <ul>
2834 <li><a href="/shortlog">log</a></li>
2862 <li><a href="/shortlog">log</a></li>
2835 <li><a href="/graph">graph</a></li>
2863 <li><a href="/graph">graph</a></li>
2836 <li><a href="/tags">tags</a></li>
2864 <li><a href="/tags">tags</a></li>
2837 <li><a href="/bookmarks">bookmarks</a></li>
2865 <li><a href="/bookmarks">bookmarks</a></li>
2838 <li><a href="/branches">branches</a></li>
2866 <li><a href="/branches">branches</a></li>
2839 </ul>
2867 </ul>
2840 <ul>
2868 <ul>
2841 <li class="active"><a href="/help">help</a></li>
2869 <li class="active"><a href="/help">help</a></li>
2842 </ul>
2870 </ul>
2843 </div>
2871 </div>
2844
2872
2845 <div class="main">
2873 <div class="main">
2846 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2874 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2847 <h3>Help: add</h3>
2875 <h3>Help: add</h3>
2848
2876
2849 <form class="search" action="/log">
2877 <form class="search" action="/log">
2850
2878
2851 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2879 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
2852 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2880 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2853 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2881 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2854 </form>
2882 </form>
2855 <div id="doc">
2883 <div id="doc">
2856 <p>
2884 <p>
2857 hg add [OPTION]... [FILE]...
2885 hg add [OPTION]... [FILE]...
2858 </p>
2886 </p>
2859 <p>
2887 <p>
2860 add the specified files on the next commit
2888 add the specified files on the next commit
2861 </p>
2889 </p>
2862 <p>
2890 <p>
2863 Schedule files to be version controlled and added to the
2891 Schedule files to be version controlled and added to the
2864 repository.
2892 repository.
2865 </p>
2893 </p>
2866 <p>
2894 <p>
2867 The files will be added to the repository at the next commit. To
2895 The files will be added to the repository at the next commit. To
2868 undo an add before that, see 'hg forget'.
2896 undo an add before that, see 'hg forget'.
2869 </p>
2897 </p>
2870 <p>
2898 <p>
2871 If no names are given, add all files to the repository (except
2899 If no names are given, add all files to the repository (except
2872 files matching &quot;.hgignore&quot;).
2900 files matching &quot;.hgignore&quot;).
2873 </p>
2901 </p>
2874 <p>
2902 <p>
2875 Examples:
2903 Examples:
2876 </p>
2904 </p>
2877 <ul>
2905 <ul>
2878 <li> New (unknown) files are added automatically by 'hg add':
2906 <li> New (unknown) files are added automatically by 'hg add':
2879 <pre>
2907 <pre>
2880 \$ ls (re)
2908 \$ ls (re)
2881 foo.c
2909 foo.c
2882 \$ hg status (re)
2910 \$ hg status (re)
2883 ? foo.c
2911 ? foo.c
2884 \$ hg add (re)
2912 \$ hg add (re)
2885 adding foo.c
2913 adding foo.c
2886 \$ hg status (re)
2914 \$ hg status (re)
2887 A foo.c
2915 A foo.c
2888 </pre>
2916 </pre>
2889 <li> Specific files to be added can be specified:
2917 <li> Specific files to be added can be specified:
2890 <pre>
2918 <pre>
2891 \$ ls (re)
2919 \$ ls (re)
2892 bar.c foo.c
2920 bar.c foo.c
2893 \$ hg status (re)
2921 \$ hg status (re)
2894 ? bar.c
2922 ? bar.c
2895 ? foo.c
2923 ? foo.c
2896 \$ hg add bar.c (re)
2924 \$ hg add bar.c (re)
2897 \$ hg status (re)
2925 \$ hg status (re)
2898 A bar.c
2926 A bar.c
2899 ? foo.c
2927 ? foo.c
2900 </pre>
2928 </pre>
2901 </ul>
2929 </ul>
2902 <p>
2930 <p>
2903 Returns 0 if all files are successfully added.
2931 Returns 0 if all files are successfully added.
2904 </p>
2932 </p>
2905 <p>
2933 <p>
2906 options ([+] can be repeated):
2934 options ([+] can be repeated):
2907 </p>
2935 </p>
2908 <table>
2936 <table>
2909 <tr><td>-I</td>
2937 <tr><td>-I</td>
2910 <td>--include PATTERN [+]</td>
2938 <td>--include PATTERN [+]</td>
2911 <td>include names matching the given patterns</td></tr>
2939 <td>include names matching the given patterns</td></tr>
2912 <tr><td>-X</td>
2940 <tr><td>-X</td>
2913 <td>--exclude PATTERN [+]</td>
2941 <td>--exclude PATTERN [+]</td>
2914 <td>exclude names matching the given patterns</td></tr>
2942 <td>exclude names matching the given patterns</td></tr>
2915 <tr><td>-S</td>
2943 <tr><td>-S</td>
2916 <td>--subrepos</td>
2944 <td>--subrepos</td>
2917 <td>recurse into subrepositories</td></tr>
2945 <td>recurse into subrepositories</td></tr>
2918 <tr><td>-n</td>
2946 <tr><td>-n</td>
2919 <td>--dry-run</td>
2947 <td>--dry-run</td>
2920 <td>do not perform actions, just print output</td></tr>
2948 <td>do not perform actions, just print output</td></tr>
2921 </table>
2949 </table>
2922 <p>
2950 <p>
2923 global options ([+] can be repeated):
2951 global options ([+] can be repeated):
2924 </p>
2952 </p>
2925 <table>
2953 <table>
2926 <tr><td>-R</td>
2954 <tr><td>-R</td>
2927 <td>--repository REPO</td>
2955 <td>--repository REPO</td>
2928 <td>repository root directory or name of overlay bundle file</td></tr>
2956 <td>repository root directory or name of overlay bundle file</td></tr>
2929 <tr><td></td>
2957 <tr><td></td>
2930 <td>--cwd DIR</td>
2958 <td>--cwd DIR</td>
2931 <td>change working directory</td></tr>
2959 <td>change working directory</td></tr>
2932 <tr><td>-y</td>
2960 <tr><td>-y</td>
2933 <td>--noninteractive</td>
2961 <td>--noninteractive</td>
2934 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2962 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2935 <tr><td>-q</td>
2963 <tr><td>-q</td>
2936 <td>--quiet</td>
2964 <td>--quiet</td>
2937 <td>suppress output</td></tr>
2965 <td>suppress output</td></tr>
2938 <tr><td>-v</td>
2966 <tr><td>-v</td>
2939 <td>--verbose</td>
2967 <td>--verbose</td>
2940 <td>enable additional output</td></tr>
2968 <td>enable additional output</td></tr>
2941 <tr><td></td>
2969 <tr><td></td>
2942 <td>--color TYPE</td>
2970 <td>--color TYPE</td>
2943 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2971 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
2944 <tr><td></td>
2972 <tr><td></td>
2945 <td>--config CONFIG [+]</td>
2973 <td>--config CONFIG [+]</td>
2946 <td>set/override config option (use 'section.name=value')</td></tr>
2974 <td>set/override config option (use 'section.name=value')</td></tr>
2947 <tr><td></td>
2975 <tr><td></td>
2948 <td>--debug</td>
2976 <td>--debug</td>
2949 <td>enable debugging output</td></tr>
2977 <td>enable debugging output</td></tr>
2950 <tr><td></td>
2978 <tr><td></td>
2951 <td>--debugger</td>
2979 <td>--debugger</td>
2952 <td>start debugger</td></tr>
2980 <td>start debugger</td></tr>
2953 <tr><td></td>
2981 <tr><td></td>
2954 <td>--encoding ENCODE</td>
2982 <td>--encoding ENCODE</td>
2955 <td>set the charset encoding (default: ascii)</td></tr>
2983 <td>set the charset encoding (default: ascii)</td></tr>
2956 <tr><td></td>
2984 <tr><td></td>
2957 <td>--encodingmode MODE</td>
2985 <td>--encodingmode MODE</td>
2958 <td>set the charset encoding mode (default: strict)</td></tr>
2986 <td>set the charset encoding mode (default: strict)</td></tr>
2959 <tr><td></td>
2987 <tr><td></td>
2960 <td>--traceback</td>
2988 <td>--traceback</td>
2961 <td>always print a traceback on exception</td></tr>
2989 <td>always print a traceback on exception</td></tr>
2962 <tr><td></td>
2990 <tr><td></td>
2963 <td>--time</td>
2991 <td>--time</td>
2964 <td>time how long the command takes</td></tr>
2992 <td>time how long the command takes</td></tr>
2965 <tr><td></td>
2993 <tr><td></td>
2966 <td>--profile</td>
2994 <td>--profile</td>
2967 <td>print command execution profile</td></tr>
2995 <td>print command execution profile</td></tr>
2968 <tr><td></td>
2996 <tr><td></td>
2969 <td>--version</td>
2997 <td>--version</td>
2970 <td>output version information and exit</td></tr>
2998 <td>output version information and exit</td></tr>
2971 <tr><td>-h</td>
2999 <tr><td>-h</td>
2972 <td>--help</td>
3000 <td>--help</td>
2973 <td>display help and exit</td></tr>
3001 <td>display help and exit</td></tr>
2974 <tr><td></td>
3002 <tr><td></td>
2975 <td>--hidden</td>
3003 <td>--hidden</td>
2976 <td>consider hidden changesets</td></tr>
3004 <td>consider hidden changesets</td></tr>
2977 <tr><td></td>
3005 <tr><td></td>
2978 <td>--pager TYPE</td>
3006 <td>--pager TYPE</td>
2979 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3007 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
2980 </table>
3008 </table>
2981
3009
2982 </div>
3010 </div>
2983 </div>
3011 </div>
2984 </div>
3012 </div>
2985
3013
2986
3014
2987
3015
2988 </body>
3016 </body>
2989 </html>
3017 </html>
2990
3018
2991
3019
2992 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
3020 $ get-with-headers.py $LOCALIP:$HGPORT "help/remove"
2993 200 Script output follows
3021 200 Script output follows
2994
3022
2995 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3023 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2996 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3024 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2997 <head>
3025 <head>
2998 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3026 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2999 <meta name="robots" content="index, nofollow" />
3027 <meta name="robots" content="index, nofollow" />
3000 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3028 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3001 <script type="text/javascript" src="/static/mercurial.js"></script>
3029 <script type="text/javascript" src="/static/mercurial.js"></script>
3002
3030
3003 <title>Help: remove</title>
3031 <title>Help: remove</title>
3004 </head>
3032 </head>
3005 <body>
3033 <body>
3006
3034
3007 <div class="container">
3035 <div class="container">
3008 <div class="menu">
3036 <div class="menu">
3009 <div class="logo">
3037 <div class="logo">
3010 <a href="https://mercurial-scm.org/">
3038 <a href="https://mercurial-scm.org/">
3011 <img src="/static/hglogo.png" alt="mercurial" /></a>
3039 <img src="/static/hglogo.png" alt="mercurial" /></a>
3012 </div>
3040 </div>
3013 <ul>
3041 <ul>
3014 <li><a href="/shortlog">log</a></li>
3042 <li><a href="/shortlog">log</a></li>
3015 <li><a href="/graph">graph</a></li>
3043 <li><a href="/graph">graph</a></li>
3016 <li><a href="/tags">tags</a></li>
3044 <li><a href="/tags">tags</a></li>
3017 <li><a href="/bookmarks">bookmarks</a></li>
3045 <li><a href="/bookmarks">bookmarks</a></li>
3018 <li><a href="/branches">branches</a></li>
3046 <li><a href="/branches">branches</a></li>
3019 </ul>
3047 </ul>
3020 <ul>
3048 <ul>
3021 <li class="active"><a href="/help">help</a></li>
3049 <li class="active"><a href="/help">help</a></li>
3022 </ul>
3050 </ul>
3023 </div>
3051 </div>
3024
3052
3025 <div class="main">
3053 <div class="main">
3026 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3054 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3027 <h3>Help: remove</h3>
3055 <h3>Help: remove</h3>
3028
3056
3029 <form class="search" action="/log">
3057 <form class="search" action="/log">
3030
3058
3031 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3059 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3032 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3060 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3033 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3061 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3034 </form>
3062 </form>
3035 <div id="doc">
3063 <div id="doc">
3036 <p>
3064 <p>
3037 hg remove [OPTION]... FILE...
3065 hg remove [OPTION]... FILE...
3038 </p>
3066 </p>
3039 <p>
3067 <p>
3040 aliases: rm
3068 aliases: rm
3041 </p>
3069 </p>
3042 <p>
3070 <p>
3043 remove the specified files on the next commit
3071 remove the specified files on the next commit
3044 </p>
3072 </p>
3045 <p>
3073 <p>
3046 Schedule the indicated files for removal from the current branch.
3074 Schedule the indicated files for removal from the current branch.
3047 </p>
3075 </p>
3048 <p>
3076 <p>
3049 This command schedules the files to be removed at the next commit.
3077 This command schedules the files to be removed at the next commit.
3050 To undo a remove before that, see 'hg revert'. To undo added
3078 To undo a remove before that, see 'hg revert'. To undo added
3051 files, see 'hg forget'.
3079 files, see 'hg forget'.
3052 </p>
3080 </p>
3053 <p>
3081 <p>
3054 -A/--after can be used to remove only files that have already
3082 -A/--after can be used to remove only files that have already
3055 been deleted, -f/--force can be used to force deletion, and -Af
3083 been deleted, -f/--force can be used to force deletion, and -Af
3056 can be used to remove files from the next revision without
3084 can be used to remove files from the next revision without
3057 deleting them from the working directory.
3085 deleting them from the working directory.
3058 </p>
3086 </p>
3059 <p>
3087 <p>
3060 The following table details the behavior of remove for different
3088 The following table details the behavior of remove for different
3061 file states (columns) and option combinations (rows). The file
3089 file states (columns) and option combinations (rows). The file
3062 states are Added [A], Clean [C], Modified [M] and Missing [!]
3090 states are Added [A], Clean [C], Modified [M] and Missing [!]
3063 (as reported by 'hg status'). The actions are Warn, Remove
3091 (as reported by 'hg status'). The actions are Warn, Remove
3064 (from branch) and Delete (from disk):
3092 (from branch) and Delete (from disk):
3065 </p>
3093 </p>
3066 <table>
3094 <table>
3067 <tr><td>opt/state</td>
3095 <tr><td>opt/state</td>
3068 <td>A</td>
3096 <td>A</td>
3069 <td>C</td>
3097 <td>C</td>
3070 <td>M</td>
3098 <td>M</td>
3071 <td>!</td></tr>
3099 <td>!</td></tr>
3072 <tr><td>none</td>
3100 <tr><td>none</td>
3073 <td>W</td>
3101 <td>W</td>
3074 <td>RD</td>
3102 <td>RD</td>
3075 <td>W</td>
3103 <td>W</td>
3076 <td>R</td></tr>
3104 <td>R</td></tr>
3077 <tr><td>-f</td>
3105 <tr><td>-f</td>
3078 <td>R</td>
3106 <td>R</td>
3079 <td>RD</td>
3107 <td>RD</td>
3080 <td>RD</td>
3108 <td>RD</td>
3081 <td>R</td></tr>
3109 <td>R</td></tr>
3082 <tr><td>-A</td>
3110 <tr><td>-A</td>
3083 <td>W</td>
3111 <td>W</td>
3084 <td>W</td>
3112 <td>W</td>
3085 <td>W</td>
3113 <td>W</td>
3086 <td>R</td></tr>
3114 <td>R</td></tr>
3087 <tr><td>-Af</td>
3115 <tr><td>-Af</td>
3088 <td>R</td>
3116 <td>R</td>
3089 <td>R</td>
3117 <td>R</td>
3090 <td>R</td>
3118 <td>R</td>
3091 <td>R</td></tr>
3119 <td>R</td></tr>
3092 </table>
3120 </table>
3093 <p>
3121 <p>
3094 <b>Note:</b>
3122 <b>Note:</b>
3095 </p>
3123 </p>
3096 <p>
3124 <p>
3097 'hg remove' never deletes files in Added [A] state from the
3125 'hg remove' never deletes files in Added [A] state from the
3098 working directory, not even if &quot;--force&quot; is specified.
3126 working directory, not even if &quot;--force&quot; is specified.
3099 </p>
3127 </p>
3100 <p>
3128 <p>
3101 Returns 0 on success, 1 if any warnings encountered.
3129 Returns 0 on success, 1 if any warnings encountered.
3102 </p>
3130 </p>
3103 <p>
3131 <p>
3104 options ([+] can be repeated):
3132 options ([+] can be repeated):
3105 </p>
3133 </p>
3106 <table>
3134 <table>
3107 <tr><td>-A</td>
3135 <tr><td>-A</td>
3108 <td>--after</td>
3136 <td>--after</td>
3109 <td>record delete for missing files</td></tr>
3137 <td>record delete for missing files</td></tr>
3110 <tr><td>-f</td>
3138 <tr><td>-f</td>
3111 <td>--force</td>
3139 <td>--force</td>
3112 <td>forget added files, delete modified files</td></tr>
3140 <td>forget added files, delete modified files</td></tr>
3113 <tr><td>-S</td>
3141 <tr><td>-S</td>
3114 <td>--subrepos</td>
3142 <td>--subrepos</td>
3115 <td>recurse into subrepositories</td></tr>
3143 <td>recurse into subrepositories</td></tr>
3116 <tr><td>-I</td>
3144 <tr><td>-I</td>
3117 <td>--include PATTERN [+]</td>
3145 <td>--include PATTERN [+]</td>
3118 <td>include names matching the given patterns</td></tr>
3146 <td>include names matching the given patterns</td></tr>
3119 <tr><td>-X</td>
3147 <tr><td>-X</td>
3120 <td>--exclude PATTERN [+]</td>
3148 <td>--exclude PATTERN [+]</td>
3121 <td>exclude names matching the given patterns</td></tr>
3149 <td>exclude names matching the given patterns</td></tr>
3122 <tr><td>-n</td>
3150 <tr><td>-n</td>
3123 <td>--dry-run</td>
3151 <td>--dry-run</td>
3124 <td>do not perform actions, just print output</td></tr>
3152 <td>do not perform actions, just print output</td></tr>
3125 </table>
3153 </table>
3126 <p>
3154 <p>
3127 global options ([+] can be repeated):
3155 global options ([+] can be repeated):
3128 </p>
3156 </p>
3129 <table>
3157 <table>
3130 <tr><td>-R</td>
3158 <tr><td>-R</td>
3131 <td>--repository REPO</td>
3159 <td>--repository REPO</td>
3132 <td>repository root directory or name of overlay bundle file</td></tr>
3160 <td>repository root directory or name of overlay bundle file</td></tr>
3133 <tr><td></td>
3161 <tr><td></td>
3134 <td>--cwd DIR</td>
3162 <td>--cwd DIR</td>
3135 <td>change working directory</td></tr>
3163 <td>change working directory</td></tr>
3136 <tr><td>-y</td>
3164 <tr><td>-y</td>
3137 <td>--noninteractive</td>
3165 <td>--noninteractive</td>
3138 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3166 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
3139 <tr><td>-q</td>
3167 <tr><td>-q</td>
3140 <td>--quiet</td>
3168 <td>--quiet</td>
3141 <td>suppress output</td></tr>
3169 <td>suppress output</td></tr>
3142 <tr><td>-v</td>
3170 <tr><td>-v</td>
3143 <td>--verbose</td>
3171 <td>--verbose</td>
3144 <td>enable additional output</td></tr>
3172 <td>enable additional output</td></tr>
3145 <tr><td></td>
3173 <tr><td></td>
3146 <td>--color TYPE</td>
3174 <td>--color TYPE</td>
3147 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3175 <td>when to colorize (boolean, always, auto, never, or debug)</td></tr>
3148 <tr><td></td>
3176 <tr><td></td>
3149 <td>--config CONFIG [+]</td>
3177 <td>--config CONFIG [+]</td>
3150 <td>set/override config option (use 'section.name=value')</td></tr>
3178 <td>set/override config option (use 'section.name=value')</td></tr>
3151 <tr><td></td>
3179 <tr><td></td>
3152 <td>--debug</td>
3180 <td>--debug</td>
3153 <td>enable debugging output</td></tr>
3181 <td>enable debugging output</td></tr>
3154 <tr><td></td>
3182 <tr><td></td>
3155 <td>--debugger</td>
3183 <td>--debugger</td>
3156 <td>start debugger</td></tr>
3184 <td>start debugger</td></tr>
3157 <tr><td></td>
3185 <tr><td></td>
3158 <td>--encoding ENCODE</td>
3186 <td>--encoding ENCODE</td>
3159 <td>set the charset encoding (default: ascii)</td></tr>
3187 <td>set the charset encoding (default: ascii)</td></tr>
3160 <tr><td></td>
3188 <tr><td></td>
3161 <td>--encodingmode MODE</td>
3189 <td>--encodingmode MODE</td>
3162 <td>set the charset encoding mode (default: strict)</td></tr>
3190 <td>set the charset encoding mode (default: strict)</td></tr>
3163 <tr><td></td>
3191 <tr><td></td>
3164 <td>--traceback</td>
3192 <td>--traceback</td>
3165 <td>always print a traceback on exception</td></tr>
3193 <td>always print a traceback on exception</td></tr>
3166 <tr><td></td>
3194 <tr><td></td>
3167 <td>--time</td>
3195 <td>--time</td>
3168 <td>time how long the command takes</td></tr>
3196 <td>time how long the command takes</td></tr>
3169 <tr><td></td>
3197 <tr><td></td>
3170 <td>--profile</td>
3198 <td>--profile</td>
3171 <td>print command execution profile</td></tr>
3199 <td>print command execution profile</td></tr>
3172 <tr><td></td>
3200 <tr><td></td>
3173 <td>--version</td>
3201 <td>--version</td>
3174 <td>output version information and exit</td></tr>
3202 <td>output version information and exit</td></tr>
3175 <tr><td>-h</td>
3203 <tr><td>-h</td>
3176 <td>--help</td>
3204 <td>--help</td>
3177 <td>display help and exit</td></tr>
3205 <td>display help and exit</td></tr>
3178 <tr><td></td>
3206 <tr><td></td>
3179 <td>--hidden</td>
3207 <td>--hidden</td>
3180 <td>consider hidden changesets</td></tr>
3208 <td>consider hidden changesets</td></tr>
3181 <tr><td></td>
3209 <tr><td></td>
3182 <td>--pager TYPE</td>
3210 <td>--pager TYPE</td>
3183 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3211 <td>when to paginate (boolean, always, auto, or never) (default: auto)</td></tr>
3184 </table>
3212 </table>
3185
3213
3186 </div>
3214 </div>
3187 </div>
3215 </div>
3188 </div>
3216 </div>
3189
3217
3190
3218
3191
3219
3192 </body>
3220 </body>
3193 </html>
3221 </html>
3194
3222
3195
3223
3196 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
3224 $ get-with-headers.py $LOCALIP:$HGPORT "help/dates"
3197 200 Script output follows
3225 200 Script output follows
3198
3226
3199 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3227 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3200 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3228 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3201 <head>
3229 <head>
3202 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3230 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3203 <meta name="robots" content="index, nofollow" />
3231 <meta name="robots" content="index, nofollow" />
3204 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3232 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3205 <script type="text/javascript" src="/static/mercurial.js"></script>
3233 <script type="text/javascript" src="/static/mercurial.js"></script>
3206
3234
3207 <title>Help: dates</title>
3235 <title>Help: dates</title>
3208 </head>
3236 </head>
3209 <body>
3237 <body>
3210
3238
3211 <div class="container">
3239 <div class="container">
3212 <div class="menu">
3240 <div class="menu">
3213 <div class="logo">
3241 <div class="logo">
3214 <a href="https://mercurial-scm.org/">
3242 <a href="https://mercurial-scm.org/">
3215 <img src="/static/hglogo.png" alt="mercurial" /></a>
3243 <img src="/static/hglogo.png" alt="mercurial" /></a>
3216 </div>
3244 </div>
3217 <ul>
3245 <ul>
3218 <li><a href="/shortlog">log</a></li>
3246 <li><a href="/shortlog">log</a></li>
3219 <li><a href="/graph">graph</a></li>
3247 <li><a href="/graph">graph</a></li>
3220 <li><a href="/tags">tags</a></li>
3248 <li><a href="/tags">tags</a></li>
3221 <li><a href="/bookmarks">bookmarks</a></li>
3249 <li><a href="/bookmarks">bookmarks</a></li>
3222 <li><a href="/branches">branches</a></li>
3250 <li><a href="/branches">branches</a></li>
3223 </ul>
3251 </ul>
3224 <ul>
3252 <ul>
3225 <li class="active"><a href="/help">help</a></li>
3253 <li class="active"><a href="/help">help</a></li>
3226 </ul>
3254 </ul>
3227 </div>
3255 </div>
3228
3256
3229 <div class="main">
3257 <div class="main">
3230 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3258 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3231 <h3>Help: dates</h3>
3259 <h3>Help: dates</h3>
3232
3260
3233 <form class="search" action="/log">
3261 <form class="search" action="/log">
3234
3262
3235 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3263 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3236 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3264 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3237 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3265 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3238 </form>
3266 </form>
3239 <div id="doc">
3267 <div id="doc">
3240 <h1>Date Formats</h1>
3268 <h1>Date Formats</h1>
3241 <p>
3269 <p>
3242 Some commands allow the user to specify a date, e.g.:
3270 Some commands allow the user to specify a date, e.g.:
3243 </p>
3271 </p>
3244 <ul>
3272 <ul>
3245 <li> backout, commit, import, tag: Specify the commit date.
3273 <li> backout, commit, import, tag: Specify the commit date.
3246 <li> log, revert, update: Select revision(s) by date.
3274 <li> log, revert, update: Select revision(s) by date.
3247 </ul>
3275 </ul>
3248 <p>
3276 <p>
3249 Many date formats are valid. Here are some examples:
3277 Many date formats are valid. Here are some examples:
3250 </p>
3278 </p>
3251 <ul>
3279 <ul>
3252 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
3280 <li> &quot;Wed Dec 6 13:18:29 2006&quot; (local timezone assumed)
3253 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
3281 <li> &quot;Dec 6 13:18 -0600&quot; (year assumed, time offset provided)
3254 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
3282 <li> &quot;Dec 6 13:18 UTC&quot; (UTC and GMT are aliases for +0000)
3255 <li> &quot;Dec 6&quot; (midnight)
3283 <li> &quot;Dec 6&quot; (midnight)
3256 <li> &quot;13:18&quot; (today assumed)
3284 <li> &quot;13:18&quot; (today assumed)
3257 <li> &quot;3:39&quot; (3:39AM assumed)
3285 <li> &quot;3:39&quot; (3:39AM assumed)
3258 <li> &quot;3:39pm&quot; (15:39)
3286 <li> &quot;3:39pm&quot; (15:39)
3259 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
3287 <li> &quot;2006-12-06 13:18:29&quot; (ISO 8601 format)
3260 <li> &quot;2006-12-6 13:18&quot;
3288 <li> &quot;2006-12-6 13:18&quot;
3261 <li> &quot;2006-12-6&quot;
3289 <li> &quot;2006-12-6&quot;
3262 <li> &quot;12-6&quot;
3290 <li> &quot;12-6&quot;
3263 <li> &quot;12/6&quot;
3291 <li> &quot;12/6&quot;
3264 <li> &quot;12/6/6&quot; (Dec 6 2006)
3292 <li> &quot;12/6/6&quot; (Dec 6 2006)
3265 <li> &quot;today&quot; (midnight)
3293 <li> &quot;today&quot; (midnight)
3266 <li> &quot;yesterday&quot; (midnight)
3294 <li> &quot;yesterday&quot; (midnight)
3267 <li> &quot;now&quot; - right now
3295 <li> &quot;now&quot; - right now
3268 </ul>
3296 </ul>
3269 <p>
3297 <p>
3270 Lastly, there is Mercurial's internal format:
3298 Lastly, there is Mercurial's internal format:
3271 </p>
3299 </p>
3272 <ul>
3300 <ul>
3273 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
3301 <li> &quot;1165411109 0&quot; (Wed Dec 6 13:18:29 2006 UTC)
3274 </ul>
3302 </ul>
3275 <p>
3303 <p>
3276 This is the internal representation format for dates. The first number
3304 This is the internal representation format for dates. The first number
3277 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
3305 is the number of seconds since the epoch (1970-01-01 00:00 UTC). The
3278 second is the offset of the local timezone, in seconds west of UTC
3306 second is the offset of the local timezone, in seconds west of UTC
3279 (negative if the timezone is east of UTC).
3307 (negative if the timezone is east of UTC).
3280 </p>
3308 </p>
3281 <p>
3309 <p>
3282 The log command also accepts date ranges:
3310 The log command also accepts date ranges:
3283 </p>
3311 </p>
3284 <ul>
3312 <ul>
3285 <li> &quot;&lt;DATE&quot; - at or before a given date/time
3313 <li> &quot;&lt;DATE&quot; - at or before a given date/time
3286 <li> &quot;&gt;DATE&quot; - on or after a given date/time
3314 <li> &quot;&gt;DATE&quot; - on or after a given date/time
3287 <li> &quot;DATE to DATE&quot; - a date range, inclusive
3315 <li> &quot;DATE to DATE&quot; - a date range, inclusive
3288 <li> &quot;-DAYS&quot; - within a given number of days of today
3316 <li> &quot;-DAYS&quot; - within a given number of days of today
3289 </ul>
3317 </ul>
3290
3318
3291 </div>
3319 </div>
3292 </div>
3320 </div>
3293 </div>
3321 </div>
3294
3322
3295
3323
3296
3324
3297 </body>
3325 </body>
3298 </html>
3326 </html>
3299
3327
3300
3328
3301 $ get-with-headers.py $LOCALIP:$HGPORT "help/pager"
3329 $ get-with-headers.py $LOCALIP:$HGPORT "help/pager"
3302 200 Script output follows
3330 200 Script output follows
3303
3331
3304 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3332 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3305 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3333 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3306 <head>
3334 <head>
3307 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3335 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3308 <meta name="robots" content="index, nofollow" />
3336 <meta name="robots" content="index, nofollow" />
3309 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3337 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3310 <script type="text/javascript" src="/static/mercurial.js"></script>
3338 <script type="text/javascript" src="/static/mercurial.js"></script>
3311
3339
3312 <title>Help: pager</title>
3340 <title>Help: pager</title>
3313 </head>
3341 </head>
3314 <body>
3342 <body>
3315
3343
3316 <div class="container">
3344 <div class="container">
3317 <div class="menu">
3345 <div class="menu">
3318 <div class="logo">
3346 <div class="logo">
3319 <a href="https://mercurial-scm.org/">
3347 <a href="https://mercurial-scm.org/">
3320 <img src="/static/hglogo.png" alt="mercurial" /></a>
3348 <img src="/static/hglogo.png" alt="mercurial" /></a>
3321 </div>
3349 </div>
3322 <ul>
3350 <ul>
3323 <li><a href="/shortlog">log</a></li>
3351 <li><a href="/shortlog">log</a></li>
3324 <li><a href="/graph">graph</a></li>
3352 <li><a href="/graph">graph</a></li>
3325 <li><a href="/tags">tags</a></li>
3353 <li><a href="/tags">tags</a></li>
3326 <li><a href="/bookmarks">bookmarks</a></li>
3354 <li><a href="/bookmarks">bookmarks</a></li>
3327 <li><a href="/branches">branches</a></li>
3355 <li><a href="/branches">branches</a></li>
3328 </ul>
3356 </ul>
3329 <ul>
3357 <ul>
3330 <li class="active"><a href="/help">help</a></li>
3358 <li class="active"><a href="/help">help</a></li>
3331 </ul>
3359 </ul>
3332 </div>
3360 </div>
3333
3361
3334 <div class="main">
3362 <div class="main">
3335 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3363 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3336 <h3>Help: pager</h3>
3364 <h3>Help: pager</h3>
3337
3365
3338 <form class="search" action="/log">
3366 <form class="search" action="/log">
3339
3367
3340 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3368 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3341 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3369 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3342 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3370 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3343 </form>
3371 </form>
3344 <div id="doc">
3372 <div id="doc">
3345 <h1>Pager Support</h1>
3373 <h1>Pager Support</h1>
3346 <p>
3374 <p>
3347 Some Mercurial commands can produce a lot of output, and Mercurial will
3375 Some Mercurial commands can produce a lot of output, and Mercurial will
3348 attempt to use a pager to make those commands more pleasant.
3376 attempt to use a pager to make those commands more pleasant.
3349 </p>
3377 </p>
3350 <p>
3378 <p>
3351 To set the pager that should be used, set the application variable:
3379 To set the pager that should be used, set the application variable:
3352 </p>
3380 </p>
3353 <pre>
3381 <pre>
3354 [pager]
3382 [pager]
3355 pager = less -FRX
3383 pager = less -FRX
3356 </pre>
3384 </pre>
3357 <p>
3385 <p>
3358 If no pager is set in the user or repository configuration, Mercurial uses the
3386 If no pager is set in the user or repository configuration, Mercurial uses the
3359 environment variable $PAGER. If $PAGER is not set, pager.pager from the default
3387 environment variable $PAGER. If $PAGER is not set, pager.pager from the default
3360 or system configuration is used. If none of these are set, a default pager will
3388 or system configuration is used. If none of these are set, a default pager will
3361 be used, typically 'less' on Unix and 'more' on Windows.
3389 be used, typically 'less' on Unix and 'more' on Windows.
3362 </p>
3390 </p>
3363 <p>
3391 <p>
3364 You can disable the pager for certain commands by adding them to the
3392 You can disable the pager for certain commands by adding them to the
3365 pager.ignore list:
3393 pager.ignore list:
3366 </p>
3394 </p>
3367 <pre>
3395 <pre>
3368 [pager]
3396 [pager]
3369 ignore = version, help, update
3397 ignore = version, help, update
3370 </pre>
3398 </pre>
3371 <p>
3399 <p>
3372 To ignore global commands like 'hg version' or 'hg help', you have
3400 To ignore global commands like 'hg version' or 'hg help', you have
3373 to specify them in your user configuration file.
3401 to specify them in your user configuration file.
3374 </p>
3402 </p>
3375 <p>
3403 <p>
3376 To control whether the pager is used at all for an individual command,
3404 To control whether the pager is used at all for an individual command,
3377 you can use --pager=&lt;value&gt;:
3405 you can use --pager=&lt;value&gt;:
3378 </p>
3406 </p>
3379 <ul>
3407 <ul>
3380 <li> use as needed: 'auto'.
3408 <li> use as needed: 'auto'.
3381 <li> require the pager: 'yes' or 'on'.
3409 <li> require the pager: 'yes' or 'on'.
3382 <li> suppress the pager: 'no' or 'off' (any unrecognized value will also work).
3410 <li> suppress the pager: 'no' or 'off' (any unrecognized value will also work).
3383 </ul>
3411 </ul>
3384 <p>
3412 <p>
3385 To globally turn off all attempts to use a pager, set:
3413 To globally turn off all attempts to use a pager, set:
3386 </p>
3414 </p>
3387 <pre>
3415 <pre>
3388 [ui]
3416 [ui]
3389 paginate = never
3417 paginate = never
3390 </pre>
3418 </pre>
3391 <p>
3419 <p>
3392 which will prevent the pager from running.
3420 which will prevent the pager from running.
3393 </p>
3421 </p>
3394
3422
3395 </div>
3423 </div>
3396 </div>
3424 </div>
3397 </div>
3425 </div>
3398
3426
3399
3427
3400
3428
3401 </body>
3429 </body>
3402 </html>
3430 </html>
3403
3431
3404
3432
3405 Sub-topic indexes rendered properly
3433 Sub-topic indexes rendered properly
3406
3434
3407 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
3435 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals"
3408 200 Script output follows
3436 200 Script output follows
3409
3437
3410 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3438 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3411 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3439 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3412 <head>
3440 <head>
3413 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3441 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3414 <meta name="robots" content="index, nofollow" />
3442 <meta name="robots" content="index, nofollow" />
3415 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3443 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3416 <script type="text/javascript" src="/static/mercurial.js"></script>
3444 <script type="text/javascript" src="/static/mercurial.js"></script>
3417
3445
3418 <title>Help: internals</title>
3446 <title>Help: internals</title>
3419 </head>
3447 </head>
3420 <body>
3448 <body>
3421
3449
3422 <div class="container">
3450 <div class="container">
3423 <div class="menu">
3451 <div class="menu">
3424 <div class="logo">
3452 <div class="logo">
3425 <a href="https://mercurial-scm.org/">
3453 <a href="https://mercurial-scm.org/">
3426 <img src="/static/hglogo.png" alt="mercurial" /></a>
3454 <img src="/static/hglogo.png" alt="mercurial" /></a>
3427 </div>
3455 </div>
3428 <ul>
3456 <ul>
3429 <li><a href="/shortlog">log</a></li>
3457 <li><a href="/shortlog">log</a></li>
3430 <li><a href="/graph">graph</a></li>
3458 <li><a href="/graph">graph</a></li>
3431 <li><a href="/tags">tags</a></li>
3459 <li><a href="/tags">tags</a></li>
3432 <li><a href="/bookmarks">bookmarks</a></li>
3460 <li><a href="/bookmarks">bookmarks</a></li>
3433 <li><a href="/branches">branches</a></li>
3461 <li><a href="/branches">branches</a></li>
3434 </ul>
3462 </ul>
3435 <ul>
3463 <ul>
3436 <li><a href="/help">help</a></li>
3464 <li><a href="/help">help</a></li>
3437 </ul>
3465 </ul>
3438 </div>
3466 </div>
3439
3467
3440 <div class="main">
3468 <div class="main">
3441 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3469 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3442
3470
3443 <form class="search" action="/log">
3471 <form class="search" action="/log">
3444
3472
3445 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3473 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3446 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3474 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3447 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3475 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3448 </form>
3476 </form>
3449 <table class="bigtable">
3477 <table class="bigtable">
3450 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
3478 <tr><td colspan="2"><h2><a name="topics" href="#topics">Topics</a></h2></td></tr>
3451
3479
3452 <tr><td>
3480 <tr><td>
3453 <a href="/help/internals.bundle2">
3481 <a href="/help/internals.bundle2">
3454 bundle2
3482 bundle2
3455 </a>
3483 </a>
3456 </td><td>
3484 </td><td>
3457 Bundle2
3485 Bundle2
3458 </td></tr>
3486 </td></tr>
3459 <tr><td>
3487 <tr><td>
3460 <a href="/help/internals.bundles">
3488 <a href="/help/internals.bundles">
3461 bundles
3489 bundles
3462 </a>
3490 </a>
3463 </td><td>
3491 </td><td>
3464 Bundles
3492 Bundles
3465 </td></tr>
3493 </td></tr>
3466 <tr><td>
3494 <tr><td>
3467 <a href="/help/internals.cbor">
3495 <a href="/help/internals.cbor">
3468 cbor
3496 cbor
3469 </a>
3497 </a>
3470 </td><td>
3498 </td><td>
3471 CBOR
3499 CBOR
3472 </td></tr>
3500 </td></tr>
3473 <tr><td>
3501 <tr><td>
3474 <a href="/help/internals.censor">
3502 <a href="/help/internals.censor">
3475 censor
3503 censor
3476 </a>
3504 </a>
3477 </td><td>
3505 </td><td>
3478 Censor
3506 Censor
3479 </td></tr>
3507 </td></tr>
3480 <tr><td>
3508 <tr><td>
3481 <a href="/help/internals.changegroups">
3509 <a href="/help/internals.changegroups">
3482 changegroups
3510 changegroups
3483 </a>
3511 </a>
3484 </td><td>
3512 </td><td>
3485 Changegroups
3513 Changegroups
3486 </td></tr>
3514 </td></tr>
3487 <tr><td>
3515 <tr><td>
3488 <a href="/help/internals.config">
3516 <a href="/help/internals.config">
3489 config
3517 config
3490 </a>
3518 </a>
3491 </td><td>
3519 </td><td>
3492 Config Registrar
3520 Config Registrar
3493 </td></tr>
3521 </td></tr>
3494 <tr><td>
3522 <tr><td>
3495 <a href="/help/internals.requirements">
3523 <a href="/help/internals.requirements">
3496 requirements
3524 requirements
3497 </a>
3525 </a>
3498 </td><td>
3526 </td><td>
3499 Repository Requirements
3527 Repository Requirements
3500 </td></tr>
3528 </td></tr>
3501 <tr><td>
3529 <tr><td>
3502 <a href="/help/internals.revlogs">
3530 <a href="/help/internals.revlogs">
3503 revlogs
3531 revlogs
3504 </a>
3532 </a>
3505 </td><td>
3533 </td><td>
3506 Revision Logs
3534 Revision Logs
3507 </td></tr>
3535 </td></tr>
3508 <tr><td>
3536 <tr><td>
3509 <a href="/help/internals.wireprotocol">
3537 <a href="/help/internals.wireprotocol">
3510 wireprotocol
3538 wireprotocol
3511 </a>
3539 </a>
3512 </td><td>
3540 </td><td>
3513 Wire Protocol
3541 Wire Protocol
3514 </td></tr>
3542 </td></tr>
3515 <tr><td>
3543 <tr><td>
3516 <a href="/help/internals.wireprotocolrpc">
3544 <a href="/help/internals.wireprotocolrpc">
3517 wireprotocolrpc
3545 wireprotocolrpc
3518 </a>
3546 </a>
3519 </td><td>
3547 </td><td>
3520 Wire Protocol RPC
3548 Wire Protocol RPC
3521 </td></tr>
3549 </td></tr>
3522 <tr><td>
3550 <tr><td>
3523 <a href="/help/internals.wireprotocolv2">
3551 <a href="/help/internals.wireprotocolv2">
3524 wireprotocolv2
3552 wireprotocolv2
3525 </a>
3553 </a>
3526 </td><td>
3554 </td><td>
3527 Wire Protocol Version 2
3555 Wire Protocol Version 2
3528 </td></tr>
3556 </td></tr>
3529
3557
3530
3558
3531
3559
3532
3560
3533
3561
3534 </table>
3562 </table>
3535 </div>
3563 </div>
3536 </div>
3564 </div>
3537
3565
3538
3566
3539
3567
3540 </body>
3568 </body>
3541 </html>
3569 </html>
3542
3570
3543
3571
3544 Sub-topic topics rendered properly
3572 Sub-topic topics rendered properly
3545
3573
3546 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
3574 $ get-with-headers.py $LOCALIP:$HGPORT "help/internals.changegroups"
3547 200 Script output follows
3575 200 Script output follows
3548
3576
3549 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3577 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3550 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3578 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3551 <head>
3579 <head>
3552 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3580 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3553 <meta name="robots" content="index, nofollow" />
3581 <meta name="robots" content="index, nofollow" />
3554 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3582 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3555 <script type="text/javascript" src="/static/mercurial.js"></script>
3583 <script type="text/javascript" src="/static/mercurial.js"></script>
3556
3584
3557 <title>Help: internals.changegroups</title>
3585 <title>Help: internals.changegroups</title>
3558 </head>
3586 </head>
3559 <body>
3587 <body>
3560
3588
3561 <div class="container">
3589 <div class="container">
3562 <div class="menu">
3590 <div class="menu">
3563 <div class="logo">
3591 <div class="logo">
3564 <a href="https://mercurial-scm.org/">
3592 <a href="https://mercurial-scm.org/">
3565 <img src="/static/hglogo.png" alt="mercurial" /></a>
3593 <img src="/static/hglogo.png" alt="mercurial" /></a>
3566 </div>
3594 </div>
3567 <ul>
3595 <ul>
3568 <li><a href="/shortlog">log</a></li>
3596 <li><a href="/shortlog">log</a></li>
3569 <li><a href="/graph">graph</a></li>
3597 <li><a href="/graph">graph</a></li>
3570 <li><a href="/tags">tags</a></li>
3598 <li><a href="/tags">tags</a></li>
3571 <li><a href="/bookmarks">bookmarks</a></li>
3599 <li><a href="/bookmarks">bookmarks</a></li>
3572 <li><a href="/branches">branches</a></li>
3600 <li><a href="/branches">branches</a></li>
3573 </ul>
3601 </ul>
3574 <ul>
3602 <ul>
3575 <li class="active"><a href="/help">help</a></li>
3603 <li class="active"><a href="/help">help</a></li>
3576 </ul>
3604 </ul>
3577 </div>
3605 </div>
3578
3606
3579 <div class="main">
3607 <div class="main">
3580 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3608 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3581 <h3>Help: internals.changegroups</h3>
3609 <h3>Help: internals.changegroups</h3>
3582
3610
3583 <form class="search" action="/log">
3611 <form class="search" action="/log">
3584
3612
3585 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3613 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3586 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3614 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3587 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3615 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3588 </form>
3616 </form>
3589 <div id="doc">
3617 <div id="doc">
3590 <h1>Changegroups</h1>
3618 <h1>Changegroups</h1>
3591 <p>
3619 <p>
3592 Changegroups are representations of repository revlog data, specifically
3620 Changegroups are representations of repository revlog data, specifically
3593 the changelog data, root/flat manifest data, treemanifest data, and
3621 the changelog data, root/flat manifest data, treemanifest data, and
3594 filelogs.
3622 filelogs.
3595 </p>
3623 </p>
3596 <p>
3624 <p>
3597 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3625 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
3598 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with the
3626 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with the
3599 only difference being an additional item in the *delta header*. Version
3627 only difference being an additional item in the *delta header*. Version
3600 &quot;3&quot; adds support for storage flags in the *delta header* and optionally
3628 &quot;3&quot; adds support for storage flags in the *delta header* and optionally
3601 exchanging treemanifests (enabled by setting an option on the
3629 exchanging treemanifests (enabled by setting an option on the
3602 &quot;changegroup&quot; part in the bundle2).
3630 &quot;changegroup&quot; part in the bundle2).
3603 </p>
3631 </p>
3604 <p>
3632 <p>
3605 Changegroups when not exchanging treemanifests consist of 3 logical
3633 Changegroups when not exchanging treemanifests consist of 3 logical
3606 segments:
3634 segments:
3607 </p>
3635 </p>
3608 <pre>
3636 <pre>
3609 +---------------------------------+
3637 +---------------------------------+
3610 | | | |
3638 | | | |
3611 | changeset | manifest | filelogs |
3639 | changeset | manifest | filelogs |
3612 | | | |
3640 | | | |
3613 | | | |
3641 | | | |
3614 +---------------------------------+
3642 +---------------------------------+
3615 </pre>
3643 </pre>
3616 <p>
3644 <p>
3617 When exchanging treemanifests, there are 4 logical segments:
3645 When exchanging treemanifests, there are 4 logical segments:
3618 </p>
3646 </p>
3619 <pre>
3647 <pre>
3620 +-------------------------------------------------+
3648 +-------------------------------------------------+
3621 | | | | |
3649 | | | | |
3622 | changeset | root | treemanifests | filelogs |
3650 | changeset | root | treemanifests | filelogs |
3623 | | manifest | | |
3651 | | manifest | | |
3624 | | | | |
3652 | | | | |
3625 +-------------------------------------------------+
3653 +-------------------------------------------------+
3626 </pre>
3654 </pre>
3627 <p>
3655 <p>
3628 The principle building block of each segment is a *chunk*. A *chunk*
3656 The principle building block of each segment is a *chunk*. A *chunk*
3629 is a framed piece of data:
3657 is a framed piece of data:
3630 </p>
3658 </p>
3631 <pre>
3659 <pre>
3632 +---------------------------------------+
3660 +---------------------------------------+
3633 | | |
3661 | | |
3634 | length | data |
3662 | length | data |
3635 | (4 bytes) | (&lt;length - 4&gt; bytes) |
3663 | (4 bytes) | (&lt;length - 4&gt; bytes) |
3636 | | |
3664 | | |
3637 +---------------------------------------+
3665 +---------------------------------------+
3638 </pre>
3666 </pre>
3639 <p>
3667 <p>
3640 All integers are big-endian signed integers. Each chunk starts with a 32-bit
3668 All integers are big-endian signed integers. Each chunk starts with a 32-bit
3641 integer indicating the length of the entire chunk (including the length field
3669 integer indicating the length of the entire chunk (including the length field
3642 itself).
3670 itself).
3643 </p>
3671 </p>
3644 <p>
3672 <p>
3645 There is a special case chunk that has a value of 0 for the length
3673 There is a special case chunk that has a value of 0 for the length
3646 (&quot;0x00000000&quot;). We call this an *empty chunk*.
3674 (&quot;0x00000000&quot;). We call this an *empty chunk*.
3647 </p>
3675 </p>
3648 <h2>Delta Groups</h2>
3676 <h2>Delta Groups</h2>
3649 <p>
3677 <p>
3650 A *delta group* expresses the content of a revlog as a series of deltas,
3678 A *delta group* expresses the content of a revlog as a series of deltas,
3651 or patches against previous revisions.
3679 or patches against previous revisions.
3652 </p>
3680 </p>
3653 <p>
3681 <p>
3654 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3682 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
3655 to signal the end of the delta group:
3683 to signal the end of the delta group:
3656 </p>
3684 </p>
3657 <pre>
3685 <pre>
3658 +------------------------------------------------------------------------+
3686 +------------------------------------------------------------------------+
3659 | | | | | |
3687 | | | | | |
3660 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3688 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
3661 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
3689 | (4 bytes) | (various) | (4 bytes) | (various) | (4 bytes) |
3662 | | | | | |
3690 | | | | | |
3663 +------------------------------------------------------------------------+
3691 +------------------------------------------------------------------------+
3664 </pre>
3692 </pre>
3665 <p>
3693 <p>
3666 Each *chunk*'s data consists of the following:
3694 Each *chunk*'s data consists of the following:
3667 </p>
3695 </p>
3668 <pre>
3696 <pre>
3669 +---------------------------------------+
3697 +---------------------------------------+
3670 | | |
3698 | | |
3671 | delta header | delta data |
3699 | delta header | delta data |
3672 | (various by version) | (various) |
3700 | (various by version) | (various) |
3673 | | |
3701 | | |
3674 +---------------------------------------+
3702 +---------------------------------------+
3675 </pre>
3703 </pre>
3676 <p>
3704 <p>
3677 The *delta data* is a series of *delta*s that describe a diff from an existing
3705 The *delta data* is a series of *delta*s that describe a diff from an existing
3678 entry (either that the recipient already has, or previously specified in the
3706 entry (either that the recipient already has, or previously specified in the
3679 bundle/changegroup).
3707 bundle/changegroup).
3680 </p>
3708 </p>
3681 <p>
3709 <p>
3682 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3710 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
3683 &quot;3&quot; of the changegroup format.
3711 &quot;3&quot; of the changegroup format.
3684 </p>
3712 </p>
3685 <p>
3713 <p>
3686 Version 1 (headerlen=80):
3714 Version 1 (headerlen=80):
3687 </p>
3715 </p>
3688 <pre>
3716 <pre>
3689 +------------------------------------------------------+
3717 +------------------------------------------------------+
3690 | | | | |
3718 | | | | |
3691 | node | p1 node | p2 node | link node |
3719 | node | p1 node | p2 node | link node |
3692 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3720 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3693 | | | | |
3721 | | | | |
3694 +------------------------------------------------------+
3722 +------------------------------------------------------+
3695 </pre>
3723 </pre>
3696 <p>
3724 <p>
3697 Version 2 (headerlen=100):
3725 Version 2 (headerlen=100):
3698 </p>
3726 </p>
3699 <pre>
3727 <pre>
3700 +------------------------------------------------------------------+
3728 +------------------------------------------------------------------+
3701 | | | | | |
3729 | | | | | |
3702 | node | p1 node | p2 node | base node | link node |
3730 | node | p1 node | p2 node | base node | link node |
3703 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3731 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
3704 | | | | | |
3732 | | | | | |
3705 +------------------------------------------------------------------+
3733 +------------------------------------------------------------------+
3706 </pre>
3734 </pre>
3707 <p>
3735 <p>
3708 Version 3 (headerlen=102):
3736 Version 3 (headerlen=102):
3709 </p>
3737 </p>
3710 <pre>
3738 <pre>
3711 +------------------------------------------------------------------------------+
3739 +------------------------------------------------------------------------------+
3712 | | | | | | |
3740 | | | | | | |
3713 | node | p1 node | p2 node | base node | link node | flags |
3741 | node | p1 node | p2 node | base node | link node | flags |
3714 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3742 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
3715 | | | | | | |
3743 | | | | | | |
3716 +------------------------------------------------------------------------------+
3744 +------------------------------------------------------------------------------+
3717 </pre>
3745 </pre>
3718 <p>
3746 <p>
3719 The *delta data* consists of &quot;chunklen - 4 - headerlen&quot; bytes, which contain a
3747 The *delta data* consists of &quot;chunklen - 4 - headerlen&quot; bytes, which contain a
3720 series of *delta*s, densely packed (no separators). These deltas describe a diff
3748 series of *delta*s, densely packed (no separators). These deltas describe a diff
3721 from an existing entry (either that the recipient already has, or previously
3749 from an existing entry (either that the recipient already has, or previously
3722 specified in the bundle/changegroup). The format is described more fully in
3750 specified in the bundle/changegroup). The format is described more fully in
3723 &quot;hg help internals.bdiff&quot;, but briefly:
3751 &quot;hg help internals.bdiff&quot;, but briefly:
3724 </p>
3752 </p>
3725 <pre>
3753 <pre>
3726 +---------------------------------------------------------------+
3754 +---------------------------------------------------------------+
3727 | | | | |
3755 | | | | |
3728 | start offset | end offset | new length | content |
3756 | start offset | end offset | new length | content |
3729 | (4 bytes) | (4 bytes) | (4 bytes) | (&lt;new length&gt; bytes) |
3757 | (4 bytes) | (4 bytes) | (4 bytes) | (&lt;new length&gt; bytes) |
3730 | | | | |
3758 | | | | |
3731 +---------------------------------------------------------------+
3759 +---------------------------------------------------------------+
3732 </pre>
3760 </pre>
3733 <p>
3761 <p>
3734 Please note that the length field in the delta data does *not* include itself.
3762 Please note that the length field in the delta data does *not* include itself.
3735 </p>
3763 </p>
3736 <p>
3764 <p>
3737 In version 1, the delta is always applied against the previous node from
3765 In version 1, the delta is always applied against the previous node from
3738 the changegroup or the first parent if this is the first entry in the
3766 the changegroup or the first parent if this is the first entry in the
3739 changegroup.
3767 changegroup.
3740 </p>
3768 </p>
3741 <p>
3769 <p>
3742 In version 2 and up, the delta base node is encoded in the entry in the
3770 In version 2 and up, the delta base node is encoded in the entry in the
3743 changegroup. This allows the delta to be expressed against any parent,
3771 changegroup. This allows the delta to be expressed against any parent,
3744 which can result in smaller deltas and more efficient encoding of data.
3772 which can result in smaller deltas and more efficient encoding of data.
3745 </p>
3773 </p>
3746 <p>
3774 <p>
3747 The *flags* field holds bitwise flags affecting the processing of revision
3775 The *flags* field holds bitwise flags affecting the processing of revision
3748 data. The following flags are defined:
3776 data. The following flags are defined:
3749 </p>
3777 </p>
3750 <dl>
3778 <dl>
3751 <dt>32768
3779 <dt>32768
3752 <dd>Censored revision. The revision's fulltext has been replaced by censor metadata. May only occur on file revisions.
3780 <dd>Censored revision. The revision's fulltext has been replaced by censor metadata. May only occur on file revisions.
3753 <dt>16384
3781 <dt>16384
3754 <dd>Ellipsis revision. Revision hash does not match data (likely due to rewritten parents).
3782 <dd>Ellipsis revision. Revision hash does not match data (likely due to rewritten parents).
3755 <dt>8192
3783 <dt>8192
3756 <dd>Externally stored. The revision fulltext contains &quot;key:value&quot; &quot;\n&quot; delimited metadata defining an object stored elsewhere. Used by the LFS extension.
3784 <dd>Externally stored. The revision fulltext contains &quot;key:value&quot; &quot;\n&quot; delimited metadata defining an object stored elsewhere. Used by the LFS extension.
3757 </dl>
3785 </dl>
3758 <p>
3786 <p>
3759 For historical reasons, the integer values are identical to revlog version 1
3787 For historical reasons, the integer values are identical to revlog version 1
3760 per-revision storage flags and correspond to bits being set in this 2-byte
3788 per-revision storage flags and correspond to bits being set in this 2-byte
3761 field. Bits were allocated starting from the most-significant bit, hence the
3789 field. Bits were allocated starting from the most-significant bit, hence the
3762 reverse ordering and allocation of these flags.
3790 reverse ordering and allocation of these flags.
3763 </p>
3791 </p>
3764 <h2>Changeset Segment</h2>
3792 <h2>Changeset Segment</h2>
3765 <p>
3793 <p>
3766 The *changeset segment* consists of a single *delta group* holding
3794 The *changeset segment* consists of a single *delta group* holding
3767 changelog data. The *empty chunk* at the end of the *delta group* denotes
3795 changelog data. The *empty chunk* at the end of the *delta group* denotes
3768 the boundary to the *manifest segment*.
3796 the boundary to the *manifest segment*.
3769 </p>
3797 </p>
3770 <h2>Manifest Segment</h2>
3798 <h2>Manifest Segment</h2>
3771 <p>
3799 <p>
3772 The *manifest segment* consists of a single *delta group* holding manifest
3800 The *manifest segment* consists of a single *delta group* holding manifest
3773 data. If treemanifests are in use, it contains only the manifest for the
3801 data. If treemanifests are in use, it contains only the manifest for the
3774 root directory of the repository. Otherwise, it contains the entire
3802 root directory of the repository. Otherwise, it contains the entire
3775 manifest data. The *empty chunk* at the end of the *delta group* denotes
3803 manifest data. The *empty chunk* at the end of the *delta group* denotes
3776 the boundary to the next segment (either the *treemanifests segment* or the
3804 the boundary to the next segment (either the *treemanifests segment* or the
3777 *filelogs segment*, depending on version and the request options).
3805 *filelogs segment*, depending on version and the request options).
3778 </p>
3806 </p>
3779 <h3>Treemanifests Segment</h3>
3807 <h3>Treemanifests Segment</h3>
3780 <p>
3808 <p>
3781 The *treemanifests segment* only exists in changegroup version &quot;3&quot;, and
3809 The *treemanifests segment* only exists in changegroup version &quot;3&quot;, and
3782 only if the 'treemanifest' param is part of the bundle2 changegroup part
3810 only if the 'treemanifest' param is part of the bundle2 changegroup part
3783 (it is not possible to use changegroup version 3 outside of bundle2).
3811 (it is not possible to use changegroup version 3 outside of bundle2).
3784 Aside from the filenames in the *treemanifests segment* containing a
3812 Aside from the filenames in the *treemanifests segment* containing a
3785 trailing &quot;/&quot; character, it behaves identically to the *filelogs segment*
3813 trailing &quot;/&quot; character, it behaves identically to the *filelogs segment*
3786 (see below). The final sub-segment is followed by an *empty chunk* (logically,
3814 (see below). The final sub-segment is followed by an *empty chunk* (logically,
3787 a sub-segment with filename size 0). This denotes the boundary to the
3815 a sub-segment with filename size 0). This denotes the boundary to the
3788 *filelogs segment*.
3816 *filelogs segment*.
3789 </p>
3817 </p>
3790 <h2>Filelogs Segment</h2>
3818 <h2>Filelogs Segment</h2>
3791 <p>
3819 <p>
3792 The *filelogs segment* consists of multiple sub-segments, each
3820 The *filelogs segment* consists of multiple sub-segments, each
3793 corresponding to an individual file whose data is being described:
3821 corresponding to an individual file whose data is being described:
3794 </p>
3822 </p>
3795 <pre>
3823 <pre>
3796 +--------------------------------------------------+
3824 +--------------------------------------------------+
3797 | | | | | |
3825 | | | | | |
3798 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
3826 | filelog0 | filelog1 | filelog2 | ... | 0x0 |
3799 | | | | | (4 bytes) |
3827 | | | | | (4 bytes) |
3800 | | | | | |
3828 | | | | | |
3801 +--------------------------------------------------+
3829 +--------------------------------------------------+
3802 </pre>
3830 </pre>
3803 <p>
3831 <p>
3804 The final filelog sub-segment is followed by an *empty chunk* (logically,
3832 The final filelog sub-segment is followed by an *empty chunk* (logically,
3805 a sub-segment with filename size 0). This denotes the end of the segment
3833 a sub-segment with filename size 0). This denotes the end of the segment
3806 and of the overall changegroup.
3834 and of the overall changegroup.
3807 </p>
3835 </p>
3808 <p>
3836 <p>
3809 Each filelog sub-segment consists of the following:
3837 Each filelog sub-segment consists of the following:
3810 </p>
3838 </p>
3811 <pre>
3839 <pre>
3812 +------------------------------------------------------+
3840 +------------------------------------------------------+
3813 | | | |
3841 | | | |
3814 | filename length | filename | delta group |
3842 | filename length | filename | delta group |
3815 | (4 bytes) | (&lt;length - 4&gt; bytes) | (various) |
3843 | (4 bytes) | (&lt;length - 4&gt; bytes) | (various) |
3816 | | | |
3844 | | | |
3817 +------------------------------------------------------+
3845 +------------------------------------------------------+
3818 </pre>
3846 </pre>
3819 <p>
3847 <p>
3820 That is, a *chunk* consisting of the filename (not terminated or padded)
3848 That is, a *chunk* consisting of the filename (not terminated or padded)
3821 followed by N chunks constituting the *delta group* for this file. The
3849 followed by N chunks constituting the *delta group* for this file. The
3822 *empty chunk* at the end of each *delta group* denotes the boundary to the
3850 *empty chunk* at the end of each *delta group* denotes the boundary to the
3823 next filelog sub-segment.
3851 next filelog sub-segment.
3824 </p>
3852 </p>
3825
3853
3826 </div>
3854 </div>
3827 </div>
3855 </div>
3828 </div>
3856 </div>
3829
3857
3830
3858
3831
3859
3832 </body>
3860 </body>
3833 </html>
3861 </html>
3834
3862
3835
3863
3836 $ get-with-headers.py 127.0.0.1:$HGPORT "help/unknowntopic"
3864 $ get-with-headers.py 127.0.0.1:$HGPORT "help/unknowntopic"
3837 404 Not Found
3865 404 Not Found
3838
3866
3839 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3867 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3840 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3868 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
3841 <head>
3869 <head>
3842 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3870 <link rel="icon" href="/static/hgicon.png" type="image/png" />
3843 <meta name="robots" content="index, nofollow" />
3871 <meta name="robots" content="index, nofollow" />
3844 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3872 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
3845 <script type="text/javascript" src="/static/mercurial.js"></script>
3873 <script type="text/javascript" src="/static/mercurial.js"></script>
3846
3874
3847 <title>test: error</title>
3875 <title>test: error</title>
3848 </head>
3876 </head>
3849 <body>
3877 <body>
3850
3878
3851 <div class="container">
3879 <div class="container">
3852 <div class="menu">
3880 <div class="menu">
3853 <div class="logo">
3881 <div class="logo">
3854 <a href="https://mercurial-scm.org/">
3882 <a href="https://mercurial-scm.org/">
3855 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
3883 <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial" /></a>
3856 </div>
3884 </div>
3857 <ul>
3885 <ul>
3858 <li><a href="/shortlog">log</a></li>
3886 <li><a href="/shortlog">log</a></li>
3859 <li><a href="/graph">graph</a></li>
3887 <li><a href="/graph">graph</a></li>
3860 <li><a href="/tags">tags</a></li>
3888 <li><a href="/tags">tags</a></li>
3861 <li><a href="/bookmarks">bookmarks</a></li>
3889 <li><a href="/bookmarks">bookmarks</a></li>
3862 <li><a href="/branches">branches</a></li>
3890 <li><a href="/branches">branches</a></li>
3863 </ul>
3891 </ul>
3864 <ul>
3892 <ul>
3865 <li><a href="/help">help</a></li>
3893 <li><a href="/help">help</a></li>
3866 </ul>
3894 </ul>
3867 </div>
3895 </div>
3868
3896
3869 <div class="main">
3897 <div class="main">
3870
3898
3871 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3899 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
3872 <h3>error</h3>
3900 <h3>error</h3>
3873
3901
3874
3902
3875 <form class="search" action="/log">
3903 <form class="search" action="/log">
3876
3904
3877 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3905 <p><input name="rev" id="search1" type="text" size="30" value="" /></p>
3878 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3906 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
3879 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3907 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
3880 </form>
3908 </form>
3881
3909
3882 <div class="description">
3910 <div class="description">
3883 <p>
3911 <p>
3884 An error occurred while processing your request:
3912 An error occurred while processing your request:
3885 </p>
3913 </p>
3886 <p>
3914 <p>
3887 Not Found
3915 Not Found
3888 </p>
3916 </p>
3889 </div>
3917 </div>
3890 </div>
3918 </div>
3891 </div>
3919 </div>
3892
3920
3893
3921
3894
3922
3895 </body>
3923 </body>
3896 </html>
3924 </html>
3897
3925
3898 [1]
3926 [1]
3899
3927
3900 $ killdaemons.py
3928 $ killdaemons.py
3901
3929
3902 #endif
3930 #endif
General Comments 0
You need to be logged in to leave comments. Login now