##// END OF EJS Templates
help: report source of aliases
timeless -
r28828:3640c170 default
parent child Browse files
Show More
@@ -1,1083 +1,1085 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 atexit
10 import atexit
11 import difflib
11 import difflib
12 import errno
12 import errno
13 import os
13 import os
14 import pdb
14 import pdb
15 import re
15 import re
16 import shlex
16 import shlex
17 import signal
17 import signal
18 import socket
18 import socket
19 import sys
19 import sys
20 import time
20 import time
21 import traceback
21 import traceback
22
22
23
23
24 from .i18n import _
24 from .i18n import _
25
25
26 from . import (
26 from . import (
27 cmdutil,
27 cmdutil,
28 commands,
28 commands,
29 demandimport,
29 demandimport,
30 encoding,
30 encoding,
31 error,
31 error,
32 extensions,
32 extensions,
33 fancyopts,
33 fancyopts,
34 fileset,
34 fileset,
35 hg,
35 hg,
36 hook,
36 hook,
37 revset,
37 revset,
38 templatefilters,
38 templatefilters,
39 templatekw,
39 templatekw,
40 templater,
40 templater,
41 ui as uimod,
41 ui as uimod,
42 util,
42 util,
43 )
43 )
44
44
45 class request(object):
45 class request(object):
46 def __init__(self, args, ui=None, repo=None, fin=None, fout=None,
46 def __init__(self, args, ui=None, repo=None, fin=None, fout=None,
47 ferr=None):
47 ferr=None):
48 self.args = args
48 self.args = args
49 self.ui = ui
49 self.ui = ui
50 self.repo = repo
50 self.repo = repo
51
51
52 # input/output/error streams
52 # input/output/error streams
53 self.fin = fin
53 self.fin = fin
54 self.fout = fout
54 self.fout = fout
55 self.ferr = ferr
55 self.ferr = ferr
56
56
57 def run():
57 def run():
58 "run the command in sys.argv"
58 "run the command in sys.argv"
59 sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
59 sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
60
60
61 def _getsimilar(symbols, value):
61 def _getsimilar(symbols, value):
62 sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio()
62 sim = lambda x: difflib.SequenceMatcher(None, value, x).ratio()
63 # The cutoff for similarity here is pretty arbitrary. It should
63 # The cutoff for similarity here is pretty arbitrary. It should
64 # probably be investigated and tweaked.
64 # probably be investigated and tweaked.
65 return [s for s in symbols if sim(s) > 0.6]
65 return [s for s in symbols if sim(s) > 0.6]
66
66
67 def _reportsimilar(write, similar):
67 def _reportsimilar(write, similar):
68 if len(similar) == 1:
68 if len(similar) == 1:
69 write(_("(did you mean %s?)\n") % similar[0])
69 write(_("(did you mean %s?)\n") % similar[0])
70 elif similar:
70 elif similar:
71 ss = ", ".join(sorted(similar))
71 ss = ", ".join(sorted(similar))
72 write(_("(did you mean one of %s?)\n") % ss)
72 write(_("(did you mean one of %s?)\n") % ss)
73
73
74 def _formatparse(write, inst):
74 def _formatparse(write, inst):
75 similar = []
75 similar = []
76 if isinstance(inst, error.UnknownIdentifier):
76 if isinstance(inst, error.UnknownIdentifier):
77 # make sure to check fileset first, as revset can invoke fileset
77 # make sure to check fileset first, as revset can invoke fileset
78 similar = _getsimilar(inst.symbols, inst.function)
78 similar = _getsimilar(inst.symbols, inst.function)
79 if len(inst.args) > 1:
79 if len(inst.args) > 1:
80 write(_("hg: parse error at %s: %s\n") %
80 write(_("hg: parse error at %s: %s\n") %
81 (inst.args[1], inst.args[0]))
81 (inst.args[1], inst.args[0]))
82 if (inst.args[0][0] == ' '):
82 if (inst.args[0][0] == ' '):
83 write(_("unexpected leading whitespace\n"))
83 write(_("unexpected leading whitespace\n"))
84 else:
84 else:
85 write(_("hg: parse error: %s\n") % inst.args[0])
85 write(_("hg: parse error: %s\n") % inst.args[0])
86 _reportsimilar(write, similar)
86 _reportsimilar(write, similar)
87 if inst.hint:
87 if inst.hint:
88 write(_("(%s)\n") % inst.hint)
88 write(_("(%s)\n") % inst.hint)
89
89
90 def dispatch(req):
90 def dispatch(req):
91 "run the command specified in req.args"
91 "run the command specified in req.args"
92 if req.ferr:
92 if req.ferr:
93 ferr = req.ferr
93 ferr = req.ferr
94 elif req.ui:
94 elif req.ui:
95 ferr = req.ui.ferr
95 ferr = req.ui.ferr
96 else:
96 else:
97 ferr = sys.stderr
97 ferr = sys.stderr
98
98
99 try:
99 try:
100 if not req.ui:
100 if not req.ui:
101 req.ui = uimod.ui()
101 req.ui = uimod.ui()
102 if '--traceback' in req.args:
102 if '--traceback' in req.args:
103 req.ui.setconfig('ui', 'traceback', 'on', '--traceback')
103 req.ui.setconfig('ui', 'traceback', 'on', '--traceback')
104
104
105 # set ui streams from the request
105 # set ui streams from the request
106 if req.fin:
106 if req.fin:
107 req.ui.fin = req.fin
107 req.ui.fin = req.fin
108 if req.fout:
108 if req.fout:
109 req.ui.fout = req.fout
109 req.ui.fout = req.fout
110 if req.ferr:
110 if req.ferr:
111 req.ui.ferr = req.ferr
111 req.ui.ferr = req.ferr
112 except error.Abort as inst:
112 except error.Abort as inst:
113 ferr.write(_("abort: %s\n") % inst)
113 ferr.write(_("abort: %s\n") % inst)
114 if inst.hint:
114 if inst.hint:
115 ferr.write(_("(%s)\n") % inst.hint)
115 ferr.write(_("(%s)\n") % inst.hint)
116 return -1
116 return -1
117 except error.ParseError as inst:
117 except error.ParseError as inst:
118 _formatparse(ferr.write, inst)
118 _formatparse(ferr.write, inst)
119 return -1
119 return -1
120
120
121 msg = ' '.join(' ' in a and repr(a) or a for a in req.args)
121 msg = ' '.join(' ' in a and repr(a) or a for a in req.args)
122 starttime = time.time()
122 starttime = time.time()
123 ret = None
123 ret = None
124 try:
124 try:
125 ret = _runcatch(req)
125 ret = _runcatch(req)
126 except KeyboardInterrupt:
126 except KeyboardInterrupt:
127 try:
127 try:
128 req.ui.warn(_("interrupted!\n"))
128 req.ui.warn(_("interrupted!\n"))
129 except IOError as inst:
129 except IOError as inst:
130 if inst.errno != errno.EPIPE:
130 if inst.errno != errno.EPIPE:
131 raise
131 raise
132 ret = -1
132 ret = -1
133 finally:
133 finally:
134 duration = time.time() - starttime
134 duration = time.time() - starttime
135 req.ui.flush()
135 req.ui.flush()
136 req.ui.log("commandfinish", "%s exited %s after %0.2f seconds\n",
136 req.ui.log("commandfinish", "%s exited %s after %0.2f seconds\n",
137 msg, ret or 0, duration)
137 msg, ret or 0, duration)
138 return ret
138 return ret
139
139
140 def _runcatch(req):
140 def _runcatch(req):
141 def catchterm(*args):
141 def catchterm(*args):
142 raise error.SignalInterrupt
142 raise error.SignalInterrupt
143
143
144 ui = req.ui
144 ui = req.ui
145 try:
145 try:
146 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
146 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
147 num = getattr(signal, name, None)
147 num = getattr(signal, name, None)
148 if num:
148 if num:
149 signal.signal(num, catchterm)
149 signal.signal(num, catchterm)
150 except ValueError:
150 except ValueError:
151 pass # happens if called in a thread
151 pass # happens if called in a thread
152
152
153 try:
153 try:
154 try:
154 try:
155 debugger = 'pdb'
155 debugger = 'pdb'
156 debugtrace = {
156 debugtrace = {
157 'pdb' : pdb.set_trace
157 'pdb' : pdb.set_trace
158 }
158 }
159 debugmortem = {
159 debugmortem = {
160 'pdb' : pdb.post_mortem
160 'pdb' : pdb.post_mortem
161 }
161 }
162
162
163 # read --config before doing anything else
163 # read --config before doing anything else
164 # (e.g. to change trust settings for reading .hg/hgrc)
164 # (e.g. to change trust settings for reading .hg/hgrc)
165 cfgs = _parseconfig(req.ui, _earlygetopt(['--config'], req.args))
165 cfgs = _parseconfig(req.ui, _earlygetopt(['--config'], req.args))
166
166
167 if req.repo:
167 if req.repo:
168 # copy configs that were passed on the cmdline (--config) to
168 # copy configs that were passed on the cmdline (--config) to
169 # the repo ui
169 # the repo ui
170 for sec, name, val in cfgs:
170 for sec, name, val in cfgs:
171 req.repo.ui.setconfig(sec, name, val, source='--config')
171 req.repo.ui.setconfig(sec, name, val, source='--config')
172
172
173 # developer config: ui.debugger
173 # developer config: ui.debugger
174 debugger = ui.config("ui", "debugger")
174 debugger = ui.config("ui", "debugger")
175 debugmod = pdb
175 debugmod = pdb
176 if not debugger or ui.plain():
176 if not debugger or ui.plain():
177 # if we are in HGPLAIN mode, then disable custom debugging
177 # if we are in HGPLAIN mode, then disable custom debugging
178 debugger = 'pdb'
178 debugger = 'pdb'
179 elif '--debugger' in req.args:
179 elif '--debugger' in req.args:
180 # This import can be slow for fancy debuggers, so only
180 # This import can be slow for fancy debuggers, so only
181 # do it when absolutely necessary, i.e. when actual
181 # do it when absolutely necessary, i.e. when actual
182 # debugging has been requested
182 # debugging has been requested
183 with demandimport.deactivated():
183 with demandimport.deactivated():
184 try:
184 try:
185 debugmod = __import__(debugger)
185 debugmod = __import__(debugger)
186 except ImportError:
186 except ImportError:
187 pass # Leave debugmod = pdb
187 pass # Leave debugmod = pdb
188
188
189 debugtrace[debugger] = debugmod.set_trace
189 debugtrace[debugger] = debugmod.set_trace
190 debugmortem[debugger] = debugmod.post_mortem
190 debugmortem[debugger] = debugmod.post_mortem
191
191
192 # enter the debugger before command execution
192 # enter the debugger before command execution
193 if '--debugger' in req.args:
193 if '--debugger' in req.args:
194 ui.warn(_("entering debugger - "
194 ui.warn(_("entering debugger - "
195 "type c to continue starting hg or h for help\n"))
195 "type c to continue starting hg or h for help\n"))
196
196
197 if (debugger != 'pdb' and
197 if (debugger != 'pdb' and
198 debugtrace[debugger] == debugtrace['pdb']):
198 debugtrace[debugger] == debugtrace['pdb']):
199 ui.warn(_("%s debugger specified "
199 ui.warn(_("%s debugger specified "
200 "but its module was not found\n") % debugger)
200 "but its module was not found\n") % debugger)
201 with demandimport.deactivated():
201 with demandimport.deactivated():
202 debugtrace[debugger]()
202 debugtrace[debugger]()
203 try:
203 try:
204 return _dispatch(req)
204 return _dispatch(req)
205 finally:
205 finally:
206 ui.flush()
206 ui.flush()
207 except: # re-raises
207 except: # re-raises
208 # enter the debugger when we hit an exception
208 # enter the debugger when we hit an exception
209 if '--debugger' in req.args:
209 if '--debugger' in req.args:
210 traceback.print_exc()
210 traceback.print_exc()
211 debugmortem[debugger](sys.exc_info()[2])
211 debugmortem[debugger](sys.exc_info()[2])
212 ui.traceback()
212 ui.traceback()
213 raise
213 raise
214
214
215 # Global exception handling, alphabetically
215 # Global exception handling, alphabetically
216 # Mercurial-specific first, followed by built-in and library exceptions
216 # Mercurial-specific first, followed by built-in and library exceptions
217 except error.AmbiguousCommand as inst:
217 except error.AmbiguousCommand as inst:
218 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
218 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
219 (inst.args[0], " ".join(inst.args[1])))
219 (inst.args[0], " ".join(inst.args[1])))
220 except error.ParseError as inst:
220 except error.ParseError as inst:
221 _formatparse(ui.warn, inst)
221 _formatparse(ui.warn, inst)
222 return -1
222 return -1
223 except error.LockHeld as inst:
223 except error.LockHeld as inst:
224 if inst.errno == errno.ETIMEDOUT:
224 if inst.errno == errno.ETIMEDOUT:
225 reason = _('timed out waiting for lock held by %s') % inst.locker
225 reason = _('timed out waiting for lock held by %s') % inst.locker
226 else:
226 else:
227 reason = _('lock held by %s') % inst.locker
227 reason = _('lock held by %s') % inst.locker
228 ui.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason))
228 ui.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason))
229 except error.LockUnavailable as inst:
229 except error.LockUnavailable as inst:
230 ui.warn(_("abort: could not lock %s: %s\n") %
230 ui.warn(_("abort: could not lock %s: %s\n") %
231 (inst.desc or inst.filename, inst.strerror))
231 (inst.desc or inst.filename, inst.strerror))
232 except error.CommandError as inst:
232 except error.CommandError as inst:
233 if inst.args[0]:
233 if inst.args[0]:
234 ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
234 ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
235 commands.help_(ui, inst.args[0], full=False, command=True)
235 commands.help_(ui, inst.args[0], full=False, command=True)
236 else:
236 else:
237 ui.warn(_("hg: %s\n") % inst.args[1])
237 ui.warn(_("hg: %s\n") % inst.args[1])
238 commands.help_(ui, 'shortlist')
238 commands.help_(ui, 'shortlist')
239 except error.OutOfBandError as inst:
239 except error.OutOfBandError as inst:
240 if inst.args:
240 if inst.args:
241 msg = _("abort: remote error:\n")
241 msg = _("abort: remote error:\n")
242 else:
242 else:
243 msg = _("abort: remote error\n")
243 msg = _("abort: remote error\n")
244 ui.warn(msg)
244 ui.warn(msg)
245 if inst.args:
245 if inst.args:
246 ui.warn(''.join(inst.args))
246 ui.warn(''.join(inst.args))
247 if inst.hint:
247 if inst.hint:
248 ui.warn('(%s)\n' % inst.hint)
248 ui.warn('(%s)\n' % inst.hint)
249 except error.RepoError as inst:
249 except error.RepoError as inst:
250 ui.warn(_("abort: %s!\n") % inst)
250 ui.warn(_("abort: %s!\n") % inst)
251 if inst.hint:
251 if inst.hint:
252 ui.warn(_("(%s)\n") % inst.hint)
252 ui.warn(_("(%s)\n") % inst.hint)
253 except error.ResponseError as inst:
253 except error.ResponseError as inst:
254 ui.warn(_("abort: %s") % inst.args[0])
254 ui.warn(_("abort: %s") % inst.args[0])
255 if not isinstance(inst.args[1], basestring):
255 if not isinstance(inst.args[1], basestring):
256 ui.warn(" %r\n" % (inst.args[1],))
256 ui.warn(" %r\n" % (inst.args[1],))
257 elif not inst.args[1]:
257 elif not inst.args[1]:
258 ui.warn(_(" empty string\n"))
258 ui.warn(_(" empty string\n"))
259 else:
259 else:
260 ui.warn("\n%r\n" % util.ellipsis(inst.args[1]))
260 ui.warn("\n%r\n" % util.ellipsis(inst.args[1]))
261 except error.CensoredNodeError as inst:
261 except error.CensoredNodeError as inst:
262 ui.warn(_("abort: file censored %s!\n") % inst)
262 ui.warn(_("abort: file censored %s!\n") % inst)
263 except error.RevlogError as inst:
263 except error.RevlogError as inst:
264 ui.warn(_("abort: %s!\n") % inst)
264 ui.warn(_("abort: %s!\n") % inst)
265 except error.SignalInterrupt:
265 except error.SignalInterrupt:
266 ui.warn(_("killed!\n"))
266 ui.warn(_("killed!\n"))
267 except error.UnknownCommand as inst:
267 except error.UnknownCommand as inst:
268 ui.warn(_("hg: unknown command '%s'\n") % inst.args[0])
268 ui.warn(_("hg: unknown command '%s'\n") % inst.args[0])
269 try:
269 try:
270 # check if the command is in a disabled extension
270 # check if the command is in a disabled extension
271 # (but don't check for extensions themselves)
271 # (but don't check for extensions themselves)
272 commands.help_(ui, inst.args[0], unknowncmd=True)
272 commands.help_(ui, inst.args[0], unknowncmd=True)
273 except (error.UnknownCommand, error.Abort):
273 except (error.UnknownCommand, error.Abort):
274 suggested = False
274 suggested = False
275 if len(inst.args) == 2:
275 if len(inst.args) == 2:
276 sim = _getsimilar(inst.args[1], inst.args[0])
276 sim = _getsimilar(inst.args[1], inst.args[0])
277 if sim:
277 if sim:
278 _reportsimilar(ui.warn, sim)
278 _reportsimilar(ui.warn, sim)
279 suggested = True
279 suggested = True
280 if not suggested:
280 if not suggested:
281 commands.help_(ui, 'shortlist')
281 commands.help_(ui, 'shortlist')
282 except error.InterventionRequired as inst:
282 except error.InterventionRequired as inst:
283 ui.warn("%s\n" % inst)
283 ui.warn("%s\n" % inst)
284 if inst.hint:
284 if inst.hint:
285 ui.warn(_("(%s)\n") % inst.hint)
285 ui.warn(_("(%s)\n") % inst.hint)
286 return 1
286 return 1
287 except error.Abort as inst:
287 except error.Abort as inst:
288 ui.warn(_("abort: %s\n") % inst)
288 ui.warn(_("abort: %s\n") % inst)
289 if inst.hint:
289 if inst.hint:
290 ui.warn(_("(%s)\n") % inst.hint)
290 ui.warn(_("(%s)\n") % inst.hint)
291 except ImportError as inst:
291 except ImportError as inst:
292 ui.warn(_("abort: %s!\n") % inst)
292 ui.warn(_("abort: %s!\n") % inst)
293 m = str(inst).split()[-1]
293 m = str(inst).split()[-1]
294 if m in "mpatch bdiff".split():
294 if m in "mpatch bdiff".split():
295 ui.warn(_("(did you forget to compile extensions?)\n"))
295 ui.warn(_("(did you forget to compile extensions?)\n"))
296 elif m in "zlib".split():
296 elif m in "zlib".split():
297 ui.warn(_("(is your Python install correct?)\n"))
297 ui.warn(_("(is your Python install correct?)\n"))
298 except IOError as inst:
298 except IOError as inst:
299 if util.safehasattr(inst, "code"):
299 if util.safehasattr(inst, "code"):
300 ui.warn(_("abort: %s\n") % inst)
300 ui.warn(_("abort: %s\n") % inst)
301 elif util.safehasattr(inst, "reason"):
301 elif util.safehasattr(inst, "reason"):
302 try: # usually it is in the form (errno, strerror)
302 try: # usually it is in the form (errno, strerror)
303 reason = inst.reason.args[1]
303 reason = inst.reason.args[1]
304 except (AttributeError, IndexError):
304 except (AttributeError, IndexError):
305 # it might be anything, for example a string
305 # it might be anything, for example a string
306 reason = inst.reason
306 reason = inst.reason
307 if isinstance(reason, unicode):
307 if isinstance(reason, unicode):
308 # SSLError of Python 2.7.9 contains a unicode
308 # SSLError of Python 2.7.9 contains a unicode
309 reason = reason.encode(encoding.encoding, 'replace')
309 reason = reason.encode(encoding.encoding, 'replace')
310 ui.warn(_("abort: error: %s\n") % reason)
310 ui.warn(_("abort: error: %s\n") % reason)
311 elif (util.safehasattr(inst, "args")
311 elif (util.safehasattr(inst, "args")
312 and inst.args and inst.args[0] == errno.EPIPE):
312 and inst.args and inst.args[0] == errno.EPIPE):
313 pass
313 pass
314 elif getattr(inst, "strerror", None):
314 elif getattr(inst, "strerror", None):
315 if getattr(inst, "filename", None):
315 if getattr(inst, "filename", None):
316 ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
316 ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
317 else:
317 else:
318 ui.warn(_("abort: %s\n") % inst.strerror)
318 ui.warn(_("abort: %s\n") % inst.strerror)
319 else:
319 else:
320 raise
320 raise
321 except OSError as inst:
321 except OSError as inst:
322 if getattr(inst, "filename", None) is not None:
322 if getattr(inst, "filename", None) is not None:
323 ui.warn(_("abort: %s: '%s'\n") % (inst.strerror, inst.filename))
323 ui.warn(_("abort: %s: '%s'\n") % (inst.strerror, inst.filename))
324 else:
324 else:
325 ui.warn(_("abort: %s\n") % inst.strerror)
325 ui.warn(_("abort: %s\n") % inst.strerror)
326 except KeyboardInterrupt:
326 except KeyboardInterrupt:
327 raise
327 raise
328 except MemoryError:
328 except MemoryError:
329 ui.warn(_("abort: out of memory\n"))
329 ui.warn(_("abort: out of memory\n"))
330 except SystemExit as inst:
330 except SystemExit as inst:
331 # Commands shouldn't sys.exit directly, but give a return code.
331 # Commands shouldn't sys.exit directly, but give a return code.
332 # Just in case catch this and and pass exit code to caller.
332 # Just in case catch this and and pass exit code to caller.
333 return inst.code
333 return inst.code
334 except socket.error as inst:
334 except socket.error as inst:
335 ui.warn(_("abort: %s\n") % inst.args[-1])
335 ui.warn(_("abort: %s\n") % inst.args[-1])
336 except: # perhaps re-raises
336 except: # perhaps re-raises
337 if not handlecommandexception(ui):
337 if not handlecommandexception(ui):
338 raise
338 raise
339
339
340 return -1
340 return -1
341
341
342 def aliasargs(fn, givenargs):
342 def aliasargs(fn, givenargs):
343 args = getattr(fn, 'args', [])
343 args = getattr(fn, 'args', [])
344 if args:
344 if args:
345 cmd = ' '.join(map(util.shellquote, args))
345 cmd = ' '.join(map(util.shellquote, args))
346
346
347 nums = []
347 nums = []
348 def replacer(m):
348 def replacer(m):
349 num = int(m.group(1)) - 1
349 num = int(m.group(1)) - 1
350 nums.append(num)
350 nums.append(num)
351 if num < len(givenargs):
351 if num < len(givenargs):
352 return givenargs[num]
352 return givenargs[num]
353 raise error.Abort(_('too few arguments for command alias'))
353 raise error.Abort(_('too few arguments for command alias'))
354 cmd = re.sub(r'\$(\d+|\$)', replacer, cmd)
354 cmd = re.sub(r'\$(\d+|\$)', replacer, cmd)
355 givenargs = [x for i, x in enumerate(givenargs)
355 givenargs = [x for i, x in enumerate(givenargs)
356 if i not in nums]
356 if i not in nums]
357 args = shlex.split(cmd)
357 args = shlex.split(cmd)
358 return args + givenargs
358 return args + givenargs
359
359
360 def aliasinterpolate(name, args, cmd):
360 def aliasinterpolate(name, args, cmd):
361 '''interpolate args into cmd for shell aliases
361 '''interpolate args into cmd for shell aliases
362
362
363 This also handles $0, $@ and "$@".
363 This also handles $0, $@ and "$@".
364 '''
364 '''
365 # util.interpolate can't deal with "$@" (with quotes) because it's only
365 # util.interpolate can't deal with "$@" (with quotes) because it's only
366 # built to match prefix + patterns.
366 # built to match prefix + patterns.
367 replacemap = dict(('$%d' % (i + 1), arg) for i, arg in enumerate(args))
367 replacemap = dict(('$%d' % (i + 1), arg) for i, arg in enumerate(args))
368 replacemap['$0'] = name
368 replacemap['$0'] = name
369 replacemap['$$'] = '$'
369 replacemap['$$'] = '$'
370 replacemap['$@'] = ' '.join(args)
370 replacemap['$@'] = ' '.join(args)
371 # Typical Unix shells interpolate "$@" (with quotes) as all the positional
371 # Typical Unix shells interpolate "$@" (with quotes) as all the positional
372 # parameters, separated out into words. Emulate the same behavior here by
372 # parameters, separated out into words. Emulate the same behavior here by
373 # quoting the arguments individually. POSIX shells will then typically
373 # quoting the arguments individually. POSIX shells will then typically
374 # tokenize each argument into exactly one word.
374 # tokenize each argument into exactly one word.
375 replacemap['"$@"'] = ' '.join(util.shellquote(arg) for arg in args)
375 replacemap['"$@"'] = ' '.join(util.shellquote(arg) for arg in args)
376 # escape '\$' for regex
376 # escape '\$' for regex
377 regex = '|'.join(replacemap.keys()).replace('$', r'\$')
377 regex = '|'.join(replacemap.keys()).replace('$', r'\$')
378 r = re.compile(regex)
378 r = re.compile(regex)
379 return r.sub(lambda x: replacemap[x.group()], cmd)
379 return r.sub(lambda x: replacemap[x.group()], cmd)
380
380
381 class cmdalias(object):
381 class cmdalias(object):
382 def __init__(self, name, definition, cmdtable):
382 def __init__(self, name, definition, cmdtable, source):
383 self.name = self.cmd = name
383 self.name = self.cmd = name
384 self.cmdname = ''
384 self.cmdname = ''
385 self.definition = definition
385 self.definition = definition
386 self.fn = None
386 self.fn = None
387 self.args = []
387 self.args = []
388 self.opts = []
388 self.opts = []
389 self.help = ''
389 self.help = ''
390 self.badalias = None
390 self.badalias = None
391 self.unknowncmd = False
391 self.unknowncmd = False
392 self.source = source
392
393
393 try:
394 try:
394 aliases, entry = cmdutil.findcmd(self.name, cmdtable)
395 aliases, entry = cmdutil.findcmd(self.name, cmdtable)
395 for alias, e in cmdtable.iteritems():
396 for alias, e in cmdtable.iteritems():
396 if e is entry:
397 if e is entry:
397 self.cmd = alias
398 self.cmd = alias
398 break
399 break
399 self.shadows = True
400 self.shadows = True
400 except error.UnknownCommand:
401 except error.UnknownCommand:
401 self.shadows = False
402 self.shadows = False
402
403
403 if not self.definition:
404 if not self.definition:
404 self.badalias = _("no definition for alias '%s'") % self.name
405 self.badalias = _("no definition for alias '%s'") % self.name
405 return
406 return
406
407
407 if self.definition.startswith('!'):
408 if self.definition.startswith('!'):
408 self.shell = True
409 self.shell = True
409 def fn(ui, *args):
410 def fn(ui, *args):
410 env = {'HG_ARGS': ' '.join((self.name,) + args)}
411 env = {'HG_ARGS': ' '.join((self.name,) + args)}
411 def _checkvar(m):
412 def _checkvar(m):
412 if m.groups()[0] == '$':
413 if m.groups()[0] == '$':
413 return m.group()
414 return m.group()
414 elif int(m.groups()[0]) <= len(args):
415 elif int(m.groups()[0]) <= len(args):
415 return m.group()
416 return m.group()
416 else:
417 else:
417 ui.debug("No argument found for substitution "
418 ui.debug("No argument found for substitution "
418 "of %i variable in alias '%s' definition."
419 "of %i variable in alias '%s' definition."
419 % (int(m.groups()[0]), self.name))
420 % (int(m.groups()[0]), self.name))
420 return ''
421 return ''
421 cmd = re.sub(r'\$(\d+|\$)', _checkvar, self.definition[1:])
422 cmd = re.sub(r'\$(\d+|\$)', _checkvar, self.definition[1:])
422 cmd = aliasinterpolate(self.name, args, cmd)
423 cmd = aliasinterpolate(self.name, args, cmd)
423 return ui.system(cmd, environ=env)
424 return ui.system(cmd, environ=env)
424 self.fn = fn
425 self.fn = fn
425 return
426 return
426
427
427 try:
428 try:
428 args = shlex.split(self.definition)
429 args = shlex.split(self.definition)
429 except ValueError as inst:
430 except ValueError as inst:
430 self.badalias = (_("error in definition for alias '%s': %s")
431 self.badalias = (_("error in definition for alias '%s': %s")
431 % (self.name, inst))
432 % (self.name, inst))
432 return
433 return
433 self.cmdname = cmd = args.pop(0)
434 self.cmdname = cmd = args.pop(0)
434 args = map(util.expandpath, args)
435 args = map(util.expandpath, args)
435
436
436 for invalidarg in ("--cwd", "-R", "--repository", "--repo", "--config"):
437 for invalidarg in ("--cwd", "-R", "--repository", "--repo", "--config"):
437 if _earlygetopt([invalidarg], args):
438 if _earlygetopt([invalidarg], args):
438 self.badalias = (_("error in definition for alias '%s': %s may "
439 self.badalias = (_("error in definition for alias '%s': %s may "
439 "only be given on the command line")
440 "only be given on the command line")
440 % (self.name, invalidarg))
441 % (self.name, invalidarg))
441 return
442 return
442
443
443 try:
444 try:
444 tableentry = cmdutil.findcmd(cmd, cmdtable, False)[1]
445 tableentry = cmdutil.findcmd(cmd, cmdtable, False)[1]
445 if len(tableentry) > 2:
446 if len(tableentry) > 2:
446 self.fn, self.opts, self.help = tableentry
447 self.fn, self.opts, self.help = tableentry
447 else:
448 else:
448 self.fn, self.opts = tableentry
449 self.fn, self.opts = tableentry
449
450
450 self.args = aliasargs(self.fn, args)
451 self.args = aliasargs(self.fn, args)
451 if self.help.startswith("hg " + cmd):
452 if self.help.startswith("hg " + cmd):
452 # drop prefix in old-style help lines so hg shows the alias
453 # drop prefix in old-style help lines so hg shows the alias
453 self.help = self.help[4 + len(cmd):]
454 self.help = self.help[4 + len(cmd):]
454 self.__doc__ = self.fn.__doc__
455 self.__doc__ = self.fn.__doc__
455
456
456 except error.UnknownCommand:
457 except error.UnknownCommand:
457 self.badalias = (_("alias '%s' resolves to unknown command '%s'")
458 self.badalias = (_("alias '%s' resolves to unknown command '%s'")
458 % (self.name, cmd))
459 % (self.name, cmd))
459 self.unknowncmd = True
460 self.unknowncmd = True
460 except error.AmbiguousCommand:
461 except error.AmbiguousCommand:
461 self.badalias = (_("alias '%s' resolves to ambiguous command '%s'")
462 self.badalias = (_("alias '%s' resolves to ambiguous command '%s'")
462 % (self.name, cmd))
463 % (self.name, cmd))
463
464
464 def __getattr__(self, name):
465 def __getattr__(self, name):
465 adefaults = {'norepo': True, 'optionalrepo': False, 'inferrepo': False}
466 adefaults = {'norepo': True, 'optionalrepo': False, 'inferrepo': False}
466 if name not in adefaults:
467 if name not in adefaults:
467 raise AttributeError(name)
468 raise AttributeError(name)
468 if self.badalias or util.safehasattr(self, 'shell'):
469 if self.badalias or util.safehasattr(self, 'shell'):
469 return adefaults[name]
470 return adefaults[name]
470 return getattr(self.fn, name)
471 return getattr(self.fn, name)
471
472
472 def __call__(self, ui, *args, **opts):
473 def __call__(self, ui, *args, **opts):
473 if self.badalias:
474 if self.badalias:
474 hint = None
475 hint = None
475 if self.unknowncmd:
476 if self.unknowncmd:
476 try:
477 try:
477 # check if the command is in a disabled extension
478 # check if the command is in a disabled extension
478 cmd, ext = extensions.disabledcmd(ui, self.cmdname)[:2]
479 cmd, ext = extensions.disabledcmd(ui, self.cmdname)[:2]
479 hint = _("'%s' is provided by '%s' extension") % (cmd, ext)
480 hint = _("'%s' is provided by '%s' extension") % (cmd, ext)
480 except error.UnknownCommand:
481 except error.UnknownCommand:
481 pass
482 pass
482 raise error.Abort(self.badalias, hint=hint)
483 raise error.Abort(self.badalias, hint=hint)
483 if self.shadows:
484 if self.shadows:
484 ui.debug("alias '%s' shadows command '%s'\n" %
485 ui.debug("alias '%s' shadows command '%s'\n" %
485 (self.name, self.cmdname))
486 (self.name, self.cmdname))
486
487
487 if util.safehasattr(self, 'shell'):
488 if util.safehasattr(self, 'shell'):
488 return self.fn(ui, *args, **opts)
489 return self.fn(ui, *args, **opts)
489 else:
490 else:
490 try:
491 try:
491 return util.checksignature(self.fn)(ui, *args, **opts)
492 return util.checksignature(self.fn)(ui, *args, **opts)
492 except error.SignatureError:
493 except error.SignatureError:
493 args = ' '.join([self.cmdname] + self.args)
494 args = ' '.join([self.cmdname] + self.args)
494 ui.debug("alias '%s' expands to '%s'\n" % (self.name, args))
495 ui.debug("alias '%s' expands to '%s'\n" % (self.name, args))
495 raise
496 raise
496
497
497 def addaliases(ui, cmdtable):
498 def addaliases(ui, cmdtable):
498 # aliases are processed after extensions have been loaded, so they
499 # aliases are processed after extensions have been loaded, so they
499 # may use extension commands. Aliases can also use other alias definitions,
500 # may use extension commands. Aliases can also use other alias definitions,
500 # but only if they have been defined prior to the current definition.
501 # but only if they have been defined prior to the current definition.
501 for alias, definition in ui.configitems('alias'):
502 for alias, definition in ui.configitems('alias'):
502 aliasdef = cmdalias(alias, definition, cmdtable)
503 source = ui.configsource('alias', alias)
504 aliasdef = cmdalias(alias, definition, cmdtable, source)
503
505
504 try:
506 try:
505 olddef = cmdtable[aliasdef.cmd][0]
507 olddef = cmdtable[aliasdef.cmd][0]
506 if olddef.definition == aliasdef.definition:
508 if olddef.definition == aliasdef.definition:
507 continue
509 continue
508 except (KeyError, AttributeError):
510 except (KeyError, AttributeError):
509 # definition might not exist or it might not be a cmdalias
511 # definition might not exist or it might not be a cmdalias
510 pass
512 pass
511
513
512 cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help)
514 cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help)
513
515
514 def _parse(ui, args):
516 def _parse(ui, args):
515 options = {}
517 options = {}
516 cmdoptions = {}
518 cmdoptions = {}
517
519
518 try:
520 try:
519 args = fancyopts.fancyopts(args, commands.globalopts, options)
521 args = fancyopts.fancyopts(args, commands.globalopts, options)
520 except fancyopts.getopt.GetoptError as inst:
522 except fancyopts.getopt.GetoptError as inst:
521 raise error.CommandError(None, inst)
523 raise error.CommandError(None, inst)
522
524
523 if args:
525 if args:
524 cmd, args = args[0], args[1:]
526 cmd, args = args[0], args[1:]
525 aliases, entry = cmdutil.findcmd(cmd, commands.table,
527 aliases, entry = cmdutil.findcmd(cmd, commands.table,
526 ui.configbool("ui", "strict"))
528 ui.configbool("ui", "strict"))
527 cmd = aliases[0]
529 cmd = aliases[0]
528 args = aliasargs(entry[0], args)
530 args = aliasargs(entry[0], args)
529 defaults = ui.config("defaults", cmd)
531 defaults = ui.config("defaults", cmd)
530 if defaults:
532 if defaults:
531 args = map(util.expandpath, shlex.split(defaults)) + args
533 args = map(util.expandpath, shlex.split(defaults)) + args
532 c = list(entry[1])
534 c = list(entry[1])
533 else:
535 else:
534 cmd = None
536 cmd = None
535 c = []
537 c = []
536
538
537 # combine global options into local
539 # combine global options into local
538 for o in commands.globalopts:
540 for o in commands.globalopts:
539 c.append((o[0], o[1], options[o[1]], o[3]))
541 c.append((o[0], o[1], options[o[1]], o[3]))
540
542
541 try:
543 try:
542 args = fancyopts.fancyopts(args, c, cmdoptions, True)
544 args = fancyopts.fancyopts(args, c, cmdoptions, True)
543 except fancyopts.getopt.GetoptError as inst:
545 except fancyopts.getopt.GetoptError as inst:
544 raise error.CommandError(cmd, inst)
546 raise error.CommandError(cmd, inst)
545
547
546 # separate global options back out
548 # separate global options back out
547 for o in commands.globalopts:
549 for o in commands.globalopts:
548 n = o[1]
550 n = o[1]
549 options[n] = cmdoptions[n]
551 options[n] = cmdoptions[n]
550 del cmdoptions[n]
552 del cmdoptions[n]
551
553
552 return (cmd, cmd and entry[0] or None, args, options, cmdoptions)
554 return (cmd, cmd and entry[0] or None, args, options, cmdoptions)
553
555
554 def _parseconfig(ui, config):
556 def _parseconfig(ui, config):
555 """parse the --config options from the command line"""
557 """parse the --config options from the command line"""
556 configs = []
558 configs = []
557
559
558 for cfg in config:
560 for cfg in config:
559 try:
561 try:
560 name, value = [cfgelem.strip()
562 name, value = [cfgelem.strip()
561 for cfgelem in cfg.split('=', 1)]
563 for cfgelem in cfg.split('=', 1)]
562 section, name = name.split('.', 1)
564 section, name = name.split('.', 1)
563 if not section or not name:
565 if not section or not name:
564 raise IndexError
566 raise IndexError
565 ui.setconfig(section, name, value, '--config')
567 ui.setconfig(section, name, value, '--config')
566 configs.append((section, name, value))
568 configs.append((section, name, value))
567 except (IndexError, ValueError):
569 except (IndexError, ValueError):
568 raise error.Abort(_('malformed --config option: %r '
570 raise error.Abort(_('malformed --config option: %r '
569 '(use --config section.name=value)') % cfg)
571 '(use --config section.name=value)') % cfg)
570
572
571 return configs
573 return configs
572
574
573 def _earlygetopt(aliases, args):
575 def _earlygetopt(aliases, args):
574 """Return list of values for an option (or aliases).
576 """Return list of values for an option (or aliases).
575
577
576 The values are listed in the order they appear in args.
578 The values are listed in the order they appear in args.
577 The options and values are removed from args.
579 The options and values are removed from args.
578
580
579 >>> args = ['x', '--cwd', 'foo', 'y']
581 >>> args = ['x', '--cwd', 'foo', 'y']
580 >>> _earlygetopt(['--cwd'], args), args
582 >>> _earlygetopt(['--cwd'], args), args
581 (['foo'], ['x', 'y'])
583 (['foo'], ['x', 'y'])
582
584
583 >>> args = ['x', '--cwd=bar', 'y']
585 >>> args = ['x', '--cwd=bar', 'y']
584 >>> _earlygetopt(['--cwd'], args), args
586 >>> _earlygetopt(['--cwd'], args), args
585 (['bar'], ['x', 'y'])
587 (['bar'], ['x', 'y'])
586
588
587 >>> args = ['x', '-R', 'foo', 'y']
589 >>> args = ['x', '-R', 'foo', 'y']
588 >>> _earlygetopt(['-R'], args), args
590 >>> _earlygetopt(['-R'], args), args
589 (['foo'], ['x', 'y'])
591 (['foo'], ['x', 'y'])
590
592
591 >>> args = ['x', '-Rbar', 'y']
593 >>> args = ['x', '-Rbar', 'y']
592 >>> _earlygetopt(['-R'], args), args
594 >>> _earlygetopt(['-R'], args), args
593 (['bar'], ['x', 'y'])
595 (['bar'], ['x', 'y'])
594 """
596 """
595 try:
597 try:
596 argcount = args.index("--")
598 argcount = args.index("--")
597 except ValueError:
599 except ValueError:
598 argcount = len(args)
600 argcount = len(args)
599 shortopts = [opt for opt in aliases if len(opt) == 2]
601 shortopts = [opt for opt in aliases if len(opt) == 2]
600 values = []
602 values = []
601 pos = 0
603 pos = 0
602 while pos < argcount:
604 while pos < argcount:
603 fullarg = arg = args[pos]
605 fullarg = arg = args[pos]
604 equals = arg.find('=')
606 equals = arg.find('=')
605 if equals > -1:
607 if equals > -1:
606 arg = arg[:equals]
608 arg = arg[:equals]
607 if arg in aliases:
609 if arg in aliases:
608 del args[pos]
610 del args[pos]
609 if equals > -1:
611 if equals > -1:
610 values.append(fullarg[equals + 1:])
612 values.append(fullarg[equals + 1:])
611 argcount -= 1
613 argcount -= 1
612 else:
614 else:
613 if pos + 1 >= argcount:
615 if pos + 1 >= argcount:
614 # ignore and let getopt report an error if there is no value
616 # ignore and let getopt report an error if there is no value
615 break
617 break
616 values.append(args.pop(pos))
618 values.append(args.pop(pos))
617 argcount -= 2
619 argcount -= 2
618 elif arg[:2] in shortopts:
620 elif arg[:2] in shortopts:
619 # short option can have no following space, e.g. hg log -Rfoo
621 # short option can have no following space, e.g. hg log -Rfoo
620 values.append(args.pop(pos)[2:])
622 values.append(args.pop(pos)[2:])
621 argcount -= 1
623 argcount -= 1
622 else:
624 else:
623 pos += 1
625 pos += 1
624 return values
626 return values
625
627
626 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
628 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
627 # run pre-hook, and abort if it fails
629 # run pre-hook, and abort if it fails
628 hook.hook(lui, repo, "pre-%s" % cmd, True, args=" ".join(fullargs),
630 hook.hook(lui, repo, "pre-%s" % cmd, True, args=" ".join(fullargs),
629 pats=cmdpats, opts=cmdoptions)
631 pats=cmdpats, opts=cmdoptions)
630 ret = _runcommand(ui, options, cmd, d)
632 ret = _runcommand(ui, options, cmd, d)
631 # run post-hook, passing command result
633 # run post-hook, passing command result
632 hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
634 hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
633 result=ret, pats=cmdpats, opts=cmdoptions)
635 result=ret, pats=cmdpats, opts=cmdoptions)
634 return ret
636 return ret
635
637
636 def _getlocal(ui, rpath, wd=None):
638 def _getlocal(ui, rpath, wd=None):
637 """Return (path, local ui object) for the given target path.
639 """Return (path, local ui object) for the given target path.
638
640
639 Takes paths in [cwd]/.hg/hgrc into account."
641 Takes paths in [cwd]/.hg/hgrc into account."
640 """
642 """
641 if wd is None:
643 if wd is None:
642 try:
644 try:
643 wd = os.getcwd()
645 wd = os.getcwd()
644 except OSError as e:
646 except OSError as e:
645 raise error.Abort(_("error getting current working directory: %s") %
647 raise error.Abort(_("error getting current working directory: %s") %
646 e.strerror)
648 e.strerror)
647 path = cmdutil.findrepo(wd) or ""
649 path = cmdutil.findrepo(wd) or ""
648 if not path:
650 if not path:
649 lui = ui
651 lui = ui
650 else:
652 else:
651 lui = ui.copy()
653 lui = ui.copy()
652 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
654 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
653
655
654 if rpath and rpath[-1]:
656 if rpath and rpath[-1]:
655 path = lui.expandpath(rpath[-1])
657 path = lui.expandpath(rpath[-1])
656 lui = ui.copy()
658 lui = ui.copy()
657 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
659 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
658
660
659 return path, lui
661 return path, lui
660
662
661 def _checkshellalias(lui, ui, args, precheck=True):
663 def _checkshellalias(lui, ui, args, precheck=True):
662 """Return the function to run the shell alias, if it is required
664 """Return the function to run the shell alias, if it is required
663
665
664 'precheck' is whether this function is invoked before adding
666 'precheck' is whether this function is invoked before adding
665 aliases or not.
667 aliases or not.
666 """
668 """
667 options = {}
669 options = {}
668
670
669 try:
671 try:
670 args = fancyopts.fancyopts(args, commands.globalopts, options)
672 args = fancyopts.fancyopts(args, commands.globalopts, options)
671 except fancyopts.getopt.GetoptError:
673 except fancyopts.getopt.GetoptError:
672 return
674 return
673
675
674 if not args:
676 if not args:
675 return
677 return
676
678
677 if precheck:
679 if precheck:
678 strict = True
680 strict = True
679 cmdtable = commands.table.copy()
681 cmdtable = commands.table.copy()
680 addaliases(lui, cmdtable)
682 addaliases(lui, cmdtable)
681 else:
683 else:
682 strict = False
684 strict = False
683 cmdtable = commands.table
685 cmdtable = commands.table
684
686
685 cmd = args[0]
687 cmd = args[0]
686 try:
688 try:
687 aliases, entry = cmdutil.findcmd(cmd, cmdtable, strict)
689 aliases, entry = cmdutil.findcmd(cmd, cmdtable, strict)
688 except (error.AmbiguousCommand, error.UnknownCommand):
690 except (error.AmbiguousCommand, error.UnknownCommand):
689 return
691 return
690
692
691 cmd = aliases[0]
693 cmd = aliases[0]
692 fn = entry[0]
694 fn = entry[0]
693
695
694 if cmd and util.safehasattr(fn, 'shell'):
696 if cmd and util.safehasattr(fn, 'shell'):
695 d = lambda: fn(ui, *args[1:])
697 d = lambda: fn(ui, *args[1:])
696 return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d,
698 return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d,
697 [], {})
699 [], {})
698
700
699 def _cmdattr(ui, cmd, func, attr):
701 def _cmdattr(ui, cmd, func, attr):
700 try:
702 try:
701 return getattr(func, attr)
703 return getattr(func, attr)
702 except AttributeError:
704 except AttributeError:
703 ui.deprecwarn("missing attribute '%s', use @command decorator "
705 ui.deprecwarn("missing attribute '%s', use @command decorator "
704 "to register '%s'" % (attr, cmd), '3.8')
706 "to register '%s'" % (attr, cmd), '3.8')
705 return False
707 return False
706
708
707 _loaded = set()
709 _loaded = set()
708
710
709 # list of (objname, loadermod, loadername) tuple:
711 # list of (objname, loadermod, loadername) tuple:
710 # - objname is the name of an object in extension module, from which
712 # - objname is the name of an object in extension module, from which
711 # extra information is loaded
713 # extra information is loaded
712 # - loadermod is the module where loader is placed
714 # - loadermod is the module where loader is placed
713 # - loadername is the name of the function, which takes (ui, extensionname,
715 # - loadername is the name of the function, which takes (ui, extensionname,
714 # extraobj) arguments
716 # extraobj) arguments
715 extraloaders = [
717 extraloaders = [
716 ('cmdtable', commands, 'loadcmdtable'),
718 ('cmdtable', commands, 'loadcmdtable'),
717 ('filesetpredicate', fileset, 'loadpredicate'),
719 ('filesetpredicate', fileset, 'loadpredicate'),
718 ('revsetpredicate', revset, 'loadpredicate'),
720 ('revsetpredicate', revset, 'loadpredicate'),
719 ('templatefilter', templatefilters, 'loadfilter'),
721 ('templatefilter', templatefilters, 'loadfilter'),
720 ('templatefunc', templater, 'loadfunction'),
722 ('templatefunc', templater, 'loadfunction'),
721 ('templatekeyword', templatekw, 'loadkeyword'),
723 ('templatekeyword', templatekw, 'loadkeyword'),
722 ]
724 ]
723
725
724 def _dispatch(req):
726 def _dispatch(req):
725 args = req.args
727 args = req.args
726 ui = req.ui
728 ui = req.ui
727
729
728 # check for cwd
730 # check for cwd
729 cwd = _earlygetopt(['--cwd'], args)
731 cwd = _earlygetopt(['--cwd'], args)
730 if cwd:
732 if cwd:
731 os.chdir(cwd[-1])
733 os.chdir(cwd[-1])
732
734
733 rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
735 rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
734 path, lui = _getlocal(ui, rpath)
736 path, lui = _getlocal(ui, rpath)
735
737
736 # Now that we're operating in the right directory/repository with
738 # Now that we're operating in the right directory/repository with
737 # the right config settings, check for shell aliases
739 # the right config settings, check for shell aliases
738 shellaliasfn = _checkshellalias(lui, ui, args)
740 shellaliasfn = _checkshellalias(lui, ui, args)
739 if shellaliasfn:
741 if shellaliasfn:
740 return shellaliasfn()
742 return shellaliasfn()
741
743
742 # Configure extensions in phases: uisetup, extsetup, cmdtable, and
744 # Configure extensions in phases: uisetup, extsetup, cmdtable, and
743 # reposetup. Programs like TortoiseHg will call _dispatch several
745 # reposetup. Programs like TortoiseHg will call _dispatch several
744 # times so we keep track of configured extensions in _loaded.
746 # times so we keep track of configured extensions in _loaded.
745 extensions.loadall(lui)
747 extensions.loadall(lui)
746 exts = [ext for ext in extensions.extensions() if ext[0] not in _loaded]
748 exts = [ext for ext in extensions.extensions() if ext[0] not in _loaded]
747 # Propagate any changes to lui.__class__ by extensions
749 # Propagate any changes to lui.__class__ by extensions
748 ui.__class__ = lui.__class__
750 ui.__class__ = lui.__class__
749
751
750 # (uisetup and extsetup are handled in extensions.loadall)
752 # (uisetup and extsetup are handled in extensions.loadall)
751
753
752 for name, module in exts:
754 for name, module in exts:
753 for objname, loadermod, loadername in extraloaders:
755 for objname, loadermod, loadername in extraloaders:
754 extraobj = getattr(module, objname, None)
756 extraobj = getattr(module, objname, None)
755 if extraobj is not None:
757 if extraobj is not None:
756 getattr(loadermod, loadername)(ui, name, extraobj)
758 getattr(loadermod, loadername)(ui, name, extraobj)
757 _loaded.add(name)
759 _loaded.add(name)
758
760
759 # (reposetup is handled in hg.repository)
761 # (reposetup is handled in hg.repository)
760
762
761 addaliases(lui, commands.table)
763 addaliases(lui, commands.table)
762
764
763 if not lui.configbool("ui", "strict"):
765 if not lui.configbool("ui", "strict"):
764 # All aliases and commands are completely defined, now.
766 # All aliases and commands are completely defined, now.
765 # Check abbreviation/ambiguity of shell alias again, because shell
767 # Check abbreviation/ambiguity of shell alias again, because shell
766 # alias may cause failure of "_parse" (see issue4355)
768 # alias may cause failure of "_parse" (see issue4355)
767 shellaliasfn = _checkshellalias(lui, ui, args, precheck=False)
769 shellaliasfn = _checkshellalias(lui, ui, args, precheck=False)
768 if shellaliasfn:
770 if shellaliasfn:
769 return shellaliasfn()
771 return shellaliasfn()
770
772
771 # check for fallback encoding
773 # check for fallback encoding
772 fallback = lui.config('ui', 'fallbackencoding')
774 fallback = lui.config('ui', 'fallbackencoding')
773 if fallback:
775 if fallback:
774 encoding.fallbackencoding = fallback
776 encoding.fallbackencoding = fallback
775
777
776 fullargs = args
778 fullargs = args
777 cmd, func, args, options, cmdoptions = _parse(lui, args)
779 cmd, func, args, options, cmdoptions = _parse(lui, args)
778
780
779 if options["config"]:
781 if options["config"]:
780 raise error.Abort(_("option --config may not be abbreviated!"))
782 raise error.Abort(_("option --config may not be abbreviated!"))
781 if options["cwd"]:
783 if options["cwd"]:
782 raise error.Abort(_("option --cwd may not be abbreviated!"))
784 raise error.Abort(_("option --cwd may not be abbreviated!"))
783 if options["repository"]:
785 if options["repository"]:
784 raise error.Abort(_(
786 raise error.Abort(_(
785 "option -R has to be separated from other options (e.g. not -qR) "
787 "option -R has to be separated from other options (e.g. not -qR) "
786 "and --repository may only be abbreviated as --repo!"))
788 "and --repository may only be abbreviated as --repo!"))
787
789
788 if options["encoding"]:
790 if options["encoding"]:
789 encoding.encoding = options["encoding"]
791 encoding.encoding = options["encoding"]
790 if options["encodingmode"]:
792 if options["encodingmode"]:
791 encoding.encodingmode = options["encodingmode"]
793 encoding.encodingmode = options["encodingmode"]
792 if options["time"]:
794 if options["time"]:
793 def get_times():
795 def get_times():
794 t = os.times()
796 t = os.times()
795 if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()
797 if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()
796 t = (t[0], t[1], t[2], t[3], time.clock())
798 t = (t[0], t[1], t[2], t[3], time.clock())
797 return t
799 return t
798 s = get_times()
800 s = get_times()
799 def print_time():
801 def print_time():
800 t = get_times()
802 t = get_times()
801 ui.warn(_("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
803 ui.warn(_("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
802 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
804 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
803 atexit.register(print_time)
805 atexit.register(print_time)
804
806
805 uis = set([ui, lui])
807 uis = set([ui, lui])
806
808
807 if req.repo:
809 if req.repo:
808 uis.add(req.repo.ui)
810 uis.add(req.repo.ui)
809
811
810 if options['verbose'] or options['debug'] or options['quiet']:
812 if options['verbose'] or options['debug'] or options['quiet']:
811 for opt in ('verbose', 'debug', 'quiet'):
813 for opt in ('verbose', 'debug', 'quiet'):
812 val = str(bool(options[opt]))
814 val = str(bool(options[opt]))
813 for ui_ in uis:
815 for ui_ in uis:
814 ui_.setconfig('ui', opt, val, '--' + opt)
816 ui_.setconfig('ui', opt, val, '--' + opt)
815
817
816 if options['traceback']:
818 if options['traceback']:
817 for ui_ in uis:
819 for ui_ in uis:
818 ui_.setconfig('ui', 'traceback', 'on', '--traceback')
820 ui_.setconfig('ui', 'traceback', 'on', '--traceback')
819
821
820 if options['noninteractive']:
822 if options['noninteractive']:
821 for ui_ in uis:
823 for ui_ in uis:
822 ui_.setconfig('ui', 'interactive', 'off', '-y')
824 ui_.setconfig('ui', 'interactive', 'off', '-y')
823
825
824 if cmdoptions.get('insecure', False):
826 if cmdoptions.get('insecure', False):
825 for ui_ in uis:
827 for ui_ in uis:
826 ui_.setconfig('web', 'cacerts', '!', '--insecure')
828 ui_.setconfig('web', 'cacerts', '!', '--insecure')
827
829
828 if options['version']:
830 if options['version']:
829 return commands.version_(ui)
831 return commands.version_(ui)
830 if options['help']:
832 if options['help']:
831 return commands.help_(ui, cmd, command=cmd is not None)
833 return commands.help_(ui, cmd, command=cmd is not None)
832 elif not cmd:
834 elif not cmd:
833 return commands.help_(ui, 'shortlist')
835 return commands.help_(ui, 'shortlist')
834
836
835 repo = None
837 repo = None
836 cmdpats = args[:]
838 cmdpats = args[:]
837 if not _cmdattr(ui, cmd, func, 'norepo'):
839 if not _cmdattr(ui, cmd, func, 'norepo'):
838 # use the repo from the request only if we don't have -R
840 # use the repo from the request only if we don't have -R
839 if not rpath and not cwd:
841 if not rpath and not cwd:
840 repo = req.repo
842 repo = req.repo
841
843
842 if repo:
844 if repo:
843 # set the descriptors of the repo ui to those of ui
845 # set the descriptors of the repo ui to those of ui
844 repo.ui.fin = ui.fin
846 repo.ui.fin = ui.fin
845 repo.ui.fout = ui.fout
847 repo.ui.fout = ui.fout
846 repo.ui.ferr = ui.ferr
848 repo.ui.ferr = ui.ferr
847 else:
849 else:
848 try:
850 try:
849 repo = hg.repository(ui, path=path)
851 repo = hg.repository(ui, path=path)
850 if not repo.local():
852 if not repo.local():
851 raise error.Abort(_("repository '%s' is not local") % path)
853 raise error.Abort(_("repository '%s' is not local") % path)
852 repo.ui.setconfig("bundle", "mainreporoot", repo.root, 'repo')
854 repo.ui.setconfig("bundle", "mainreporoot", repo.root, 'repo')
853 except error.RequirementError:
855 except error.RequirementError:
854 raise
856 raise
855 except error.RepoError:
857 except error.RepoError:
856 if rpath and rpath[-1]: # invalid -R path
858 if rpath and rpath[-1]: # invalid -R path
857 raise
859 raise
858 if not _cmdattr(ui, cmd, func, 'optionalrepo'):
860 if not _cmdattr(ui, cmd, func, 'optionalrepo'):
859 if (_cmdattr(ui, cmd, func, 'inferrepo') and
861 if (_cmdattr(ui, cmd, func, 'inferrepo') and
860 args and not path):
862 args and not path):
861 # try to infer -R from command args
863 # try to infer -R from command args
862 repos = map(cmdutil.findrepo, args)
864 repos = map(cmdutil.findrepo, args)
863 guess = repos[0]
865 guess = repos[0]
864 if guess and repos.count(guess) == len(repos):
866 if guess and repos.count(guess) == len(repos):
865 req.args = ['--repository', guess] + fullargs
867 req.args = ['--repository', guess] + fullargs
866 return _dispatch(req)
868 return _dispatch(req)
867 if not path:
869 if not path:
868 raise error.RepoError(_("no repository found in '%s'"
870 raise error.RepoError(_("no repository found in '%s'"
869 " (.hg not found)")
871 " (.hg not found)")
870 % os.getcwd())
872 % os.getcwd())
871 raise
873 raise
872 if repo:
874 if repo:
873 ui = repo.ui
875 ui = repo.ui
874 if options['hidden']:
876 if options['hidden']:
875 repo = repo.unfiltered()
877 repo = repo.unfiltered()
876 args.insert(0, repo)
878 args.insert(0, repo)
877 elif rpath:
879 elif rpath:
878 ui.warn(_("warning: --repository ignored\n"))
880 ui.warn(_("warning: --repository ignored\n"))
879
881
880 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
882 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
881 ui.log("command", '%s\n', msg)
883 ui.log("command", '%s\n', msg)
882 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
884 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
883 try:
885 try:
884 return runcommand(lui, repo, cmd, fullargs, ui, options, d,
886 return runcommand(lui, repo, cmd, fullargs, ui, options, d,
885 cmdpats, cmdoptions)
887 cmdpats, cmdoptions)
886 finally:
888 finally:
887 if repo and repo != req.repo:
889 if repo and repo != req.repo:
888 repo.close()
890 repo.close()
889
891
890 def lsprofile(ui, func, fp):
892 def lsprofile(ui, func, fp):
891 format = ui.config('profiling', 'format', default='text')
893 format = ui.config('profiling', 'format', default='text')
892 field = ui.config('profiling', 'sort', default='inlinetime')
894 field = ui.config('profiling', 'sort', default='inlinetime')
893 limit = ui.configint('profiling', 'limit', default=30)
895 limit = ui.configint('profiling', 'limit', default=30)
894 climit = ui.configint('profiling', 'nested', default=0)
896 climit = ui.configint('profiling', 'nested', default=0)
895
897
896 if format not in ['text', 'kcachegrind']:
898 if format not in ['text', 'kcachegrind']:
897 ui.warn(_("unrecognized profiling format '%s'"
899 ui.warn(_("unrecognized profiling format '%s'"
898 " - Ignored\n") % format)
900 " - Ignored\n") % format)
899 format = 'text'
901 format = 'text'
900
902
901 try:
903 try:
902 from . import lsprof
904 from . import lsprof
903 except ImportError:
905 except ImportError:
904 raise error.Abort(_(
906 raise error.Abort(_(
905 'lsprof not available - install from '
907 'lsprof not available - install from '
906 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))
908 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))
907 p = lsprof.Profiler()
909 p = lsprof.Profiler()
908 p.enable(subcalls=True)
910 p.enable(subcalls=True)
909 try:
911 try:
910 return func()
912 return func()
911 finally:
913 finally:
912 p.disable()
914 p.disable()
913
915
914 if format == 'kcachegrind':
916 if format == 'kcachegrind':
915 from . import lsprofcalltree
917 from . import lsprofcalltree
916 calltree = lsprofcalltree.KCacheGrind(p)
918 calltree = lsprofcalltree.KCacheGrind(p)
917 calltree.output(fp)
919 calltree.output(fp)
918 else:
920 else:
919 # format == 'text'
921 # format == 'text'
920 stats = lsprof.Stats(p.getstats())
922 stats = lsprof.Stats(p.getstats())
921 stats.sort(field)
923 stats.sort(field)
922 stats.pprint(limit=limit, file=fp, climit=climit)
924 stats.pprint(limit=limit, file=fp, climit=climit)
923
925
924 def flameprofile(ui, func, fp):
926 def flameprofile(ui, func, fp):
925 try:
927 try:
926 from flamegraph import flamegraph
928 from flamegraph import flamegraph
927 except ImportError:
929 except ImportError:
928 raise error.Abort(_(
930 raise error.Abort(_(
929 'flamegraph not available - install from '
931 'flamegraph not available - install from '
930 'https://github.com/evanhempel/python-flamegraph'))
932 'https://github.com/evanhempel/python-flamegraph'))
931 # developer config: profiling.freq
933 # developer config: profiling.freq
932 freq = ui.configint('profiling', 'freq', default=1000)
934 freq = ui.configint('profiling', 'freq', default=1000)
933 filter_ = None
935 filter_ = None
934 collapse_recursion = True
936 collapse_recursion = True
935 thread = flamegraph.ProfileThread(fp, 1.0 / freq,
937 thread = flamegraph.ProfileThread(fp, 1.0 / freq,
936 filter_, collapse_recursion)
938 filter_, collapse_recursion)
937 start_time = time.clock()
939 start_time = time.clock()
938 try:
940 try:
939 thread.start()
941 thread.start()
940 func()
942 func()
941 finally:
943 finally:
942 thread.stop()
944 thread.stop()
943 thread.join()
945 thread.join()
944 print('Collected %d stack frames (%d unique) in %2.2f seconds.' % (
946 print('Collected %d stack frames (%d unique) in %2.2f seconds.' % (
945 time.clock() - start_time, thread.num_frames(),
947 time.clock() - start_time, thread.num_frames(),
946 thread.num_frames(unique=True)))
948 thread.num_frames(unique=True)))
947
949
948
950
949 def statprofile(ui, func, fp):
951 def statprofile(ui, func, fp):
950 try:
952 try:
951 import statprof
953 import statprof
952 except ImportError:
954 except ImportError:
953 raise error.Abort(_(
955 raise error.Abort(_(
954 'statprof not available - install using "easy_install statprof"'))
956 'statprof not available - install using "easy_install statprof"'))
955
957
956 freq = ui.configint('profiling', 'freq', default=1000)
958 freq = ui.configint('profiling', 'freq', default=1000)
957 if freq > 0:
959 if freq > 0:
958 statprof.reset(freq)
960 statprof.reset(freq)
959 else:
961 else:
960 ui.warn(_("invalid sampling frequency '%s' - ignoring\n") % freq)
962 ui.warn(_("invalid sampling frequency '%s' - ignoring\n") % freq)
961
963
962 statprof.start()
964 statprof.start()
963 try:
965 try:
964 return func()
966 return func()
965 finally:
967 finally:
966 statprof.stop()
968 statprof.stop()
967 statprof.display(fp)
969 statprof.display(fp)
968
970
969 def _runcommand(ui, options, cmd, cmdfunc):
971 def _runcommand(ui, options, cmd, cmdfunc):
970 """Enables the profiler if applicable.
972 """Enables the profiler if applicable.
971
973
972 ``profiling.enabled`` - boolean config that enables or disables profiling
974 ``profiling.enabled`` - boolean config that enables or disables profiling
973 """
975 """
974 def checkargs():
976 def checkargs():
975 try:
977 try:
976 return cmdfunc()
978 return cmdfunc()
977 except error.SignatureError:
979 except error.SignatureError:
978 raise error.CommandError(cmd, _("invalid arguments"))
980 raise error.CommandError(cmd, _("invalid arguments"))
979
981
980 if options['profile'] or ui.configbool('profiling', 'enabled'):
982 if options['profile'] or ui.configbool('profiling', 'enabled'):
981 profiler = os.getenv('HGPROF')
983 profiler = os.getenv('HGPROF')
982 if profiler is None:
984 if profiler is None:
983 profiler = ui.config('profiling', 'type', default='ls')
985 profiler = ui.config('profiling', 'type', default='ls')
984 if profiler not in ('ls', 'stat', 'flame'):
986 if profiler not in ('ls', 'stat', 'flame'):
985 ui.warn(_("unrecognized profiler '%s' - ignored\n") % profiler)
987 ui.warn(_("unrecognized profiler '%s' - ignored\n") % profiler)
986 profiler = 'ls'
988 profiler = 'ls'
987
989
988 output = ui.config('profiling', 'output')
990 output = ui.config('profiling', 'output')
989
991
990 if output == 'blackbox':
992 if output == 'blackbox':
991 import StringIO
993 import StringIO
992 fp = StringIO.StringIO()
994 fp = StringIO.StringIO()
993 elif output:
995 elif output:
994 path = ui.expandpath(output)
996 path = ui.expandpath(output)
995 fp = open(path, 'wb')
997 fp = open(path, 'wb')
996 else:
998 else:
997 fp = sys.stderr
999 fp = sys.stderr
998
1000
999 try:
1001 try:
1000 if profiler == 'ls':
1002 if profiler == 'ls':
1001 return lsprofile(ui, checkargs, fp)
1003 return lsprofile(ui, checkargs, fp)
1002 elif profiler == 'flame':
1004 elif profiler == 'flame':
1003 return flameprofile(ui, checkargs, fp)
1005 return flameprofile(ui, checkargs, fp)
1004 else:
1006 else:
1005 return statprofile(ui, checkargs, fp)
1007 return statprofile(ui, checkargs, fp)
1006 finally:
1008 finally:
1007 if output:
1009 if output:
1008 if output == 'blackbox':
1010 if output == 'blackbox':
1009 val = "Profile:\n%s" % fp.getvalue()
1011 val = "Profile:\n%s" % fp.getvalue()
1010 # ui.log treats the input as a format string,
1012 # ui.log treats the input as a format string,
1011 # so we need to escape any % signs.
1013 # so we need to escape any % signs.
1012 val = val.replace('%', '%%')
1014 val = val.replace('%', '%%')
1013 ui.log('profile', val)
1015 ui.log('profile', val)
1014 fp.close()
1016 fp.close()
1015 else:
1017 else:
1016 return checkargs()
1018 return checkargs()
1017
1019
1018 def _exceptionwarning(ui):
1020 def _exceptionwarning(ui):
1019 """Produce a warning message for the current active exception"""
1021 """Produce a warning message for the current active exception"""
1020
1022
1021 # For compatibility checking, we discard the portion of the hg
1023 # For compatibility checking, we discard the portion of the hg
1022 # version after the + on the assumption that if a "normal
1024 # version after the + on the assumption that if a "normal
1023 # user" is running a build with a + in it the packager
1025 # user" is running a build with a + in it the packager
1024 # probably built from fairly close to a tag and anyone with a
1026 # probably built from fairly close to a tag and anyone with a
1025 # 'make local' copy of hg (where the version number can be out
1027 # 'make local' copy of hg (where the version number can be out
1026 # of date) will be clueful enough to notice the implausible
1028 # of date) will be clueful enough to notice the implausible
1027 # version number and try updating.
1029 # version number and try updating.
1028 ct = util.versiontuple(n=2)
1030 ct = util.versiontuple(n=2)
1029 worst = None, ct, ''
1031 worst = None, ct, ''
1030 if ui.config('ui', 'supportcontact', None) is None:
1032 if ui.config('ui', 'supportcontact', None) is None:
1031 for name, mod in extensions.extensions():
1033 for name, mod in extensions.extensions():
1032 testedwith = getattr(mod, 'testedwith', '')
1034 testedwith = getattr(mod, 'testedwith', '')
1033 report = getattr(mod, 'buglink', _('the extension author.'))
1035 report = getattr(mod, 'buglink', _('the extension author.'))
1034 if not testedwith.strip():
1036 if not testedwith.strip():
1035 # We found an untested extension. It's likely the culprit.
1037 # We found an untested extension. It's likely the culprit.
1036 worst = name, 'unknown', report
1038 worst = name, 'unknown', report
1037 break
1039 break
1038
1040
1039 # Never blame on extensions bundled with Mercurial.
1041 # Never blame on extensions bundled with Mercurial.
1040 if testedwith == 'internal':
1042 if testedwith == 'internal':
1041 continue
1043 continue
1042
1044
1043 tested = [util.versiontuple(t, 2) for t in testedwith.split()]
1045 tested = [util.versiontuple(t, 2) for t in testedwith.split()]
1044 if ct in tested:
1046 if ct in tested:
1045 continue
1047 continue
1046
1048
1047 lower = [t for t in tested if t < ct]
1049 lower = [t for t in tested if t < ct]
1048 nearest = max(lower or tested)
1050 nearest = max(lower or tested)
1049 if worst[0] is None or nearest < worst[1]:
1051 if worst[0] is None or nearest < worst[1]:
1050 worst = name, nearest, report
1052 worst = name, nearest, report
1051 if worst[0] is not None:
1053 if worst[0] is not None:
1052 name, testedwith, report = worst
1054 name, testedwith, report = worst
1053 if not isinstance(testedwith, str):
1055 if not isinstance(testedwith, str):
1054 testedwith = '.'.join([str(c) for c in testedwith])
1056 testedwith = '.'.join([str(c) for c in testedwith])
1055 warning = (_('** Unknown exception encountered with '
1057 warning = (_('** Unknown exception encountered with '
1056 'possibly-broken third-party extension %s\n'
1058 'possibly-broken third-party extension %s\n'
1057 '** which supports versions %s of Mercurial.\n'
1059 '** which supports versions %s of Mercurial.\n'
1058 '** Please disable %s and try your action again.\n'
1060 '** Please disable %s and try your action again.\n'
1059 '** If that fixes the bug please report it to %s\n')
1061 '** If that fixes the bug please report it to %s\n')
1060 % (name, testedwith, name, report))
1062 % (name, testedwith, name, report))
1061 else:
1063 else:
1062 bugtracker = ui.config('ui', 'supportcontact', None)
1064 bugtracker = ui.config('ui', 'supportcontact', None)
1063 if bugtracker is None:
1065 if bugtracker is None:
1064 bugtracker = _("https://mercurial-scm.org/wiki/BugTracker")
1066 bugtracker = _("https://mercurial-scm.org/wiki/BugTracker")
1065 warning = (_("** unknown exception encountered, "
1067 warning = (_("** unknown exception encountered, "
1066 "please report by visiting\n** ") + bugtracker + '\n')
1068 "please report by visiting\n** ") + bugtracker + '\n')
1067 warning += ((_("** Python %s\n") % sys.version.replace('\n', '')) +
1069 warning += ((_("** Python %s\n") % sys.version.replace('\n', '')) +
1068 (_("** Mercurial Distributed SCM (version %s)\n") %
1070 (_("** Mercurial Distributed SCM (version %s)\n") %
1069 util.version()) +
1071 util.version()) +
1070 (_("** Extensions loaded: %s\n") %
1072 (_("** Extensions loaded: %s\n") %
1071 ", ".join([x[0] for x in extensions.extensions()])))
1073 ", ".join([x[0] for x in extensions.extensions()])))
1072 return warning
1074 return warning
1073
1075
1074 def handlecommandexception(ui):
1076 def handlecommandexception(ui):
1075 """Produce a warning message for broken commands
1077 """Produce a warning message for broken commands
1076
1078
1077 Called when handling an exception; the exception is reraised if
1079 Called when handling an exception; the exception is reraised if
1078 this function returns False, ignored otherwise.
1080 this function returns False, ignored otherwise.
1079 """
1081 """
1080 warning = _exceptionwarning(ui)
1082 warning = _exceptionwarning(ui)
1081 ui.log("commandexception", "%s\n%s\n", warning, traceback.format_exc())
1083 ui.log("commandexception", "%s\n%s\n", warning, traceback.format_exc())
1082 ui.warn(warning)
1084 ui.warn(warning)
1083 return False # re-raise the exception
1085 return False # re-raise the exception
@@ -1,604 +1,607 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 filemerge,
23 filemerge,
24 fileset,
24 fileset,
25 minirst,
25 minirst,
26 revset,
26 revset,
27 templatefilters,
27 templatefilters,
28 templatekw,
28 templatekw,
29 templater,
29 templater,
30 util,
30 util,
31 )
31 )
32 from .hgweb import (
32 from .hgweb import (
33 webcommands,
33 webcommands,
34 )
34 )
35
35
36 _exclkeywords = [
36 _exclkeywords = [
37 "(DEPRECATED)",
37 "(DEPRECATED)",
38 "(EXPERIMENTAL)",
38 "(EXPERIMENTAL)",
39 # i18n: "(DEPRECATED)" is a keyword, must be translated consistently
39 # i18n: "(DEPRECATED)" is a keyword, must be translated consistently
40 _("(DEPRECATED)"),
40 _("(DEPRECATED)"),
41 # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently
41 # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently
42 _("(EXPERIMENTAL)"),
42 _("(EXPERIMENTAL)"),
43 ]
43 ]
44
44
45 def listexts(header, exts, indent=1, showdeprecated=False):
45 def listexts(header, exts, indent=1, showdeprecated=False):
46 '''return a text listing of the given extensions'''
46 '''return a text listing of the given extensions'''
47 rst = []
47 rst = []
48 if exts:
48 if exts:
49 for name, desc in sorted(exts.iteritems()):
49 for name, desc in sorted(exts.iteritems()):
50 if not showdeprecated and any(w in desc for w in _exclkeywords):
50 if not showdeprecated and any(w in desc for w in _exclkeywords):
51 continue
51 continue
52 rst.append('%s:%s: %s\n' % (' ' * indent, name, desc))
52 rst.append('%s:%s: %s\n' % (' ' * indent, name, desc))
53 if rst:
53 if rst:
54 rst.insert(0, '\n%s\n\n' % header)
54 rst.insert(0, '\n%s\n\n' % header)
55 return rst
55 return rst
56
56
57 def extshelp(ui):
57 def extshelp(ui):
58 rst = loaddoc('extensions')(ui).splitlines(True)
58 rst = loaddoc('extensions')(ui).splitlines(True)
59 rst.extend(listexts(
59 rst.extend(listexts(
60 _('enabled extensions:'), extensions.enabled(), showdeprecated=True))
60 _('enabled extensions:'), extensions.enabled(), showdeprecated=True))
61 rst.extend(listexts(_('disabled extensions:'), extensions.disabled()))
61 rst.extend(listexts(_('disabled extensions:'), extensions.disabled()))
62 doc = ''.join(rst)
62 doc = ''.join(rst)
63 return doc
63 return doc
64
64
65 def optrst(header, options, verbose):
65 def optrst(header, options, verbose):
66 data = []
66 data = []
67 multioccur = False
67 multioccur = False
68 for option in options:
68 for option in options:
69 if len(option) == 5:
69 if len(option) == 5:
70 shortopt, longopt, default, desc, optlabel = option
70 shortopt, longopt, default, desc, optlabel = option
71 else:
71 else:
72 shortopt, longopt, default, desc = option
72 shortopt, longopt, default, desc = option
73 optlabel = _("VALUE") # default label
73 optlabel = _("VALUE") # default label
74
74
75 if not verbose and any(w in desc for w in _exclkeywords):
75 if not verbose and any(w in desc for w in _exclkeywords):
76 continue
76 continue
77
77
78 so = ''
78 so = ''
79 if shortopt:
79 if shortopt:
80 so = '-' + shortopt
80 so = '-' + shortopt
81 lo = '--' + longopt
81 lo = '--' + longopt
82 if default:
82 if default:
83 desc += _(" (default: %s)") % default
83 desc += _(" (default: %s)") % default
84
84
85 if isinstance(default, list):
85 if isinstance(default, list):
86 lo += " %s [+]" % optlabel
86 lo += " %s [+]" % optlabel
87 multioccur = True
87 multioccur = True
88 elif (default is not None) and not isinstance(default, bool):
88 elif (default is not None) and not isinstance(default, bool):
89 lo += " %s" % optlabel
89 lo += " %s" % optlabel
90
90
91 data.append((so, lo, desc))
91 data.append((so, lo, desc))
92
92
93 if multioccur:
93 if multioccur:
94 header += (_(" ([+] can be repeated)"))
94 header += (_(" ([+] can be repeated)"))
95
95
96 rst = ['\n%s:\n\n' % header]
96 rst = ['\n%s:\n\n' % header]
97 rst.extend(minirst.maketable(data, 1))
97 rst.extend(minirst.maketable(data, 1))
98
98
99 return ''.join(rst)
99 return ''.join(rst)
100
100
101 def indicateomitted(rst, omitted, notomitted=None):
101 def indicateomitted(rst, omitted, notomitted=None):
102 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted)
102 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted)
103 if notomitted:
103 if notomitted:
104 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted)
104 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted)
105
105
106 def filtercmd(ui, cmd, kw, doc):
106 def filtercmd(ui, cmd, kw, doc):
107 if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
107 if not ui.debugflag and cmd.startswith("debug") and kw != "debug":
108 return True
108 return True
109 if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
109 if not ui.verbose and doc and any(w in doc for w in _exclkeywords):
110 return True
110 return True
111 return False
111 return False
112
112
113 def topicmatch(ui, kw):
113 def topicmatch(ui, kw):
114 """Return help topics matching kw.
114 """Return help topics matching kw.
115
115
116 Returns {'section': [(name, summary), ...], ...} where section is
116 Returns {'section': [(name, summary), ...], ...} where section is
117 one of topics, commands, extensions, or extensioncommands.
117 one of topics, commands, extensions, or extensioncommands.
118 """
118 """
119 kw = encoding.lower(kw)
119 kw = encoding.lower(kw)
120 def lowercontains(container):
120 def lowercontains(container):
121 return kw in encoding.lower(container) # translated in helptable
121 return kw in encoding.lower(container) # translated in helptable
122 results = {'topics': [],
122 results = {'topics': [],
123 'commands': [],
123 'commands': [],
124 'extensions': [],
124 'extensions': [],
125 'extensioncommands': [],
125 'extensioncommands': [],
126 }
126 }
127 for names, header, doc in helptable:
127 for names, header, doc in helptable:
128 # Old extensions may use a str as doc.
128 # Old extensions may use a str as doc.
129 if (sum(map(lowercontains, names))
129 if (sum(map(lowercontains, names))
130 or lowercontains(header)
130 or lowercontains(header)
131 or (callable(doc) and lowercontains(doc(ui)))):
131 or (callable(doc) and lowercontains(doc(ui)))):
132 results['topics'].append((names[0], header))
132 results['topics'].append((names[0], header))
133 from . import commands # avoid cycle
133 from . import commands # avoid cycle
134 for cmd, entry in commands.table.iteritems():
134 for cmd, entry in commands.table.iteritems():
135 if len(entry) == 3:
135 if len(entry) == 3:
136 summary = entry[2]
136 summary = entry[2]
137 else:
137 else:
138 summary = ''
138 summary = ''
139 # translate docs *before* searching there
139 # translate docs *before* searching there
140 docs = _(getattr(entry[0], '__doc__', None)) or ''
140 docs = _(getattr(entry[0], '__doc__', None)) or ''
141 if kw in cmd or lowercontains(summary) or lowercontains(docs):
141 if kw in cmd or lowercontains(summary) or lowercontains(docs):
142 doclines = docs.splitlines()
142 doclines = docs.splitlines()
143 if doclines:
143 if doclines:
144 summary = doclines[0]
144 summary = doclines[0]
145 cmdname = cmd.partition('|')[0].lstrip('^')
145 cmdname = cmd.partition('|')[0].lstrip('^')
146 if filtercmd(ui, cmdname, kw, docs):
146 if filtercmd(ui, cmdname, kw, docs):
147 continue
147 continue
148 results['commands'].append((cmdname, summary))
148 results['commands'].append((cmdname, summary))
149 for name, docs in itertools.chain(
149 for name, docs in itertools.chain(
150 extensions.enabled(False).iteritems(),
150 extensions.enabled(False).iteritems(),
151 extensions.disabled().iteritems()):
151 extensions.disabled().iteritems()):
152 if not docs:
152 if not docs:
153 continue
153 continue
154 mod = extensions.load(ui, name, '')
154 mod = extensions.load(ui, name, '')
155 name = name.rpartition('.')[-1]
155 name = name.rpartition('.')[-1]
156 if lowercontains(name) or lowercontains(docs):
156 if lowercontains(name) or lowercontains(docs):
157 # extension docs are already translated
157 # extension docs are already translated
158 results['extensions'].append((name, docs.splitlines()[0]))
158 results['extensions'].append((name, docs.splitlines()[0]))
159 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
159 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
160 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
160 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
161 cmdname = cmd.partition('|')[0].lstrip('^')
161 cmdname = cmd.partition('|')[0].lstrip('^')
162 if entry[0].__doc__:
162 if entry[0].__doc__:
163 cmddoc = gettext(entry[0].__doc__).splitlines()[0]
163 cmddoc = gettext(entry[0].__doc__).splitlines()[0]
164 else:
164 else:
165 cmddoc = _('(no help text available)')
165 cmddoc = _('(no help text available)')
166 if filtercmd(ui, cmdname, kw, cmddoc):
166 if filtercmd(ui, cmdname, kw, cmddoc):
167 continue
167 continue
168 results['extensioncommands'].append((cmdname, cmddoc))
168 results['extensioncommands'].append((cmdname, cmddoc))
169 return results
169 return results
170
170
171 def loaddoc(topic, subdir=None):
171 def loaddoc(topic, subdir=None):
172 """Return a delayed loader for help/topic.txt."""
172 """Return a delayed loader for help/topic.txt."""
173
173
174 def loader(ui):
174 def loader(ui):
175 docdir = os.path.join(util.datapath, 'help')
175 docdir = os.path.join(util.datapath, 'help')
176 if subdir:
176 if subdir:
177 docdir = os.path.join(docdir, subdir)
177 docdir = os.path.join(docdir, subdir)
178 path = os.path.join(docdir, topic + ".txt")
178 path = os.path.join(docdir, topic + ".txt")
179 doc = gettext(util.readfile(path))
179 doc = gettext(util.readfile(path))
180 for rewriter in helphooks.get(topic, []):
180 for rewriter in helphooks.get(topic, []):
181 doc = rewriter(ui, topic, doc)
181 doc = rewriter(ui, topic, doc)
182 return doc
182 return doc
183
183
184 return loader
184 return loader
185
185
186 internalstable = sorted([
186 internalstable = sorted([
187 (['bundles'], _('container for exchange of repository data'),
187 (['bundles'], _('container for exchange of repository data'),
188 loaddoc('bundles', subdir='internals')),
188 loaddoc('bundles', subdir='internals')),
189 (['changegroups'], _('representation of revlog data'),
189 (['changegroups'], _('representation of revlog data'),
190 loaddoc('changegroups', subdir='internals')),
190 loaddoc('changegroups', subdir='internals')),
191 (['requirements'], _('repository requirements'),
191 (['requirements'], _('repository requirements'),
192 loaddoc('requirements', subdir='internals')),
192 loaddoc('requirements', subdir='internals')),
193 (['revlogs'], _('revision storage mechanism'),
193 (['revlogs'], _('revision storage mechanism'),
194 loaddoc('revlogs', subdir='internals')),
194 loaddoc('revlogs', subdir='internals')),
195 ])
195 ])
196
196
197 def internalshelp(ui):
197 def internalshelp(ui):
198 """Generate the index for the "internals" topic."""
198 """Generate the index for the "internals" topic."""
199 lines = []
199 lines = []
200 for names, header, doc in internalstable:
200 for names, header, doc in internalstable:
201 lines.append(' :%s: %s\n' % (names[0], header))
201 lines.append(' :%s: %s\n' % (names[0], header))
202
202
203 return ''.join(lines)
203 return ''.join(lines)
204
204
205 helptable = sorted([
205 helptable = sorted([
206 (["config", "hgrc"], _("Configuration Files"), loaddoc('config')),
206 (["config", "hgrc"], _("Configuration Files"), loaddoc('config')),
207 (["dates"], _("Date Formats"), loaddoc('dates')),
207 (["dates"], _("Date Formats"), loaddoc('dates')),
208 (["patterns"], _("File Name Patterns"), loaddoc('patterns')),
208 (["patterns"], _("File Name Patterns"), loaddoc('patterns')),
209 (['environment', 'env'], _('Environment Variables'),
209 (['environment', 'env'], _('Environment Variables'),
210 loaddoc('environment')),
210 loaddoc('environment')),
211 (['revisions', 'revs'], _('Specifying Single Revisions'),
211 (['revisions', 'revs'], _('Specifying Single Revisions'),
212 loaddoc('revisions')),
212 loaddoc('revisions')),
213 (['multirevs', 'mrevs'], _('Specifying Multiple Revisions'),
213 (['multirevs', 'mrevs'], _('Specifying Multiple Revisions'),
214 loaddoc('multirevs')),
214 loaddoc('multirevs')),
215 (['revsets', 'revset'], _("Specifying Revision Sets"), loaddoc('revsets')),
215 (['revsets', 'revset'], _("Specifying Revision Sets"), loaddoc('revsets')),
216 (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets')),
216 (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets')),
217 (['diffs'], _('Diff Formats'), loaddoc('diffs')),
217 (['diffs'], _('Diff Formats'), loaddoc('diffs')),
218 (['merge-tools', 'mergetools'], _('Merge Tools'), loaddoc('merge-tools')),
218 (['merge-tools', 'mergetools'], _('Merge Tools'), loaddoc('merge-tools')),
219 (['templating', 'templates', 'template', 'style'], _('Template Usage'),
219 (['templating', 'templates', 'template', 'style'], _('Template Usage'),
220 loaddoc('templates')),
220 loaddoc('templates')),
221 (['urls'], _('URL Paths'), loaddoc('urls')),
221 (['urls'], _('URL Paths'), loaddoc('urls')),
222 (["extensions"], _("Using Additional Features"), extshelp),
222 (["extensions"], _("Using Additional Features"), extshelp),
223 (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos')),
223 (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos')),
224 (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')),
224 (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')),
225 (["glossary"], _("Glossary"), loaddoc('glossary')),
225 (["glossary"], _("Glossary"), loaddoc('glossary')),
226 (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"),
226 (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"),
227 loaddoc('hgignore')),
227 loaddoc('hgignore')),
228 (["phases"], _("Working with Phases"), loaddoc('phases')),
228 (["phases"], _("Working with Phases"), loaddoc('phases')),
229 (['scripting'], _('Using Mercurial from scripts and automation'),
229 (['scripting'], _('Using Mercurial from scripts and automation'),
230 loaddoc('scripting')),
230 loaddoc('scripting')),
231 (['internals'], _("Technical implementation topics"),
231 (['internals'], _("Technical implementation topics"),
232 internalshelp),
232 internalshelp),
233 ])
233 ])
234
234
235 # Maps topics with sub-topics to a list of their sub-topics.
235 # Maps topics with sub-topics to a list of their sub-topics.
236 subtopics = {
236 subtopics = {
237 'internals': internalstable,
237 'internals': internalstable,
238 }
238 }
239
239
240 # Map topics to lists of callable taking the current topic help and
240 # Map topics to lists of callable taking the current topic help and
241 # returning the updated version
241 # returning the updated version
242 helphooks = {}
242 helphooks = {}
243
243
244 def addtopichook(topic, rewriter):
244 def addtopichook(topic, rewriter):
245 helphooks.setdefault(topic, []).append(rewriter)
245 helphooks.setdefault(topic, []).append(rewriter)
246
246
247 def makeitemsdoc(ui, topic, doc, marker, items, dedent=False):
247 def makeitemsdoc(ui, topic, doc, marker, items, dedent=False):
248 """Extract docstring from the items key to function mapping, build a
248 """Extract docstring from the items key to function mapping, build a
249 single documentation block and use it to overwrite the marker in doc.
249 single documentation block and use it to overwrite the marker in doc.
250 """
250 """
251 entries = []
251 entries = []
252 for name in sorted(items):
252 for name in sorted(items):
253 text = (items[name].__doc__ or '').rstrip()
253 text = (items[name].__doc__ or '').rstrip()
254 if (not text
254 if (not text
255 or not ui.verbose and any(w in text for w in _exclkeywords)):
255 or not ui.verbose and any(w in text for w in _exclkeywords)):
256 continue
256 continue
257 text = gettext(text)
257 text = gettext(text)
258 if dedent:
258 if dedent:
259 text = textwrap.dedent(text)
259 text = textwrap.dedent(text)
260 lines = text.splitlines()
260 lines = text.splitlines()
261 doclines = [(lines[0])]
261 doclines = [(lines[0])]
262 for l in lines[1:]:
262 for l in lines[1:]:
263 # Stop once we find some Python doctest
263 # Stop once we find some Python doctest
264 if l.strip().startswith('>>>'):
264 if l.strip().startswith('>>>'):
265 break
265 break
266 if dedent:
266 if dedent:
267 doclines.append(l.rstrip())
267 doclines.append(l.rstrip())
268 else:
268 else:
269 doclines.append(' ' + l.strip())
269 doclines.append(' ' + l.strip())
270 entries.append('\n'.join(doclines))
270 entries.append('\n'.join(doclines))
271 entries = '\n\n'.join(entries)
271 entries = '\n\n'.join(entries)
272 return doc.replace(marker, entries)
272 return doc.replace(marker, entries)
273
273
274 def addtopicsymbols(topic, marker, symbols, dedent=False):
274 def addtopicsymbols(topic, marker, symbols, dedent=False):
275 def add(ui, topic, doc):
275 def add(ui, topic, doc):
276 return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent)
276 return makeitemsdoc(ui, topic, doc, marker, symbols, dedent=dedent)
277 addtopichook(topic, add)
277 addtopichook(topic, add)
278
278
279 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
279 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
280 addtopicsymbols('merge-tools', '.. internaltoolsmarker',
280 addtopicsymbols('merge-tools', '.. internaltoolsmarker',
281 filemerge.internalsdoc)
281 filemerge.internalsdoc)
282 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
282 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
283 addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords)
283 addtopicsymbols('templates', '.. keywordsmarker', templatekw.keywords)
284 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
284 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
285 addtopicsymbols('templates', '.. functionsmarker', templater.funcs)
285 addtopicsymbols('templates', '.. functionsmarker', templater.funcs)
286 addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands,
286 addtopicsymbols('hgweb', '.. webcommandsmarker', webcommands.commands,
287 dedent=True)
287 dedent=True)
288
288
289 def help_(ui, name, unknowncmd=False, full=True, subtopic=None, **opts):
289 def help_(ui, name, unknowncmd=False, full=True, subtopic=None, **opts):
290 '''
290 '''
291 Generate the help for 'name' as unformatted restructured text. If
291 Generate the help for 'name' as unformatted restructured text. If
292 'name' is None, describe the commands available.
292 'name' is None, describe the commands available.
293 '''
293 '''
294
294
295 from . import commands # avoid cycle
295 from . import commands # avoid cycle
296
296
297 def helpcmd(name, subtopic=None):
297 def helpcmd(name, subtopic=None):
298 try:
298 try:
299 aliases, entry = cmdutil.findcmd(name, commands.table,
299 aliases, entry = cmdutil.findcmd(name, commands.table,
300 strict=unknowncmd)
300 strict=unknowncmd)
301 except error.AmbiguousCommand as inst:
301 except error.AmbiguousCommand as inst:
302 # py3k fix: except vars can't be used outside the scope of the
302 # py3k fix: except vars can't be used outside the scope of the
303 # except block, nor can be used inside a lambda. python issue4617
303 # except block, nor can be used inside a lambda. python issue4617
304 prefix = inst.args[0]
304 prefix = inst.args[0]
305 select = lambda c: c.lstrip('^').startswith(prefix)
305 select = lambda c: c.lstrip('^').startswith(prefix)
306 rst = helplist(select)
306 rst = helplist(select)
307 return rst
307 return rst
308
308
309 rst = []
309 rst = []
310
310
311 # check if it's an invalid alias and display its error if it is
311 # check if it's an invalid alias and display its error if it is
312 if getattr(entry[0], 'badalias', None):
312 if getattr(entry[0], 'badalias', None):
313 rst.append(entry[0].badalias + '\n')
313 rst.append(entry[0].badalias + '\n')
314 if entry[0].unknowncmd:
314 if entry[0].unknowncmd:
315 try:
315 try:
316 rst.extend(helpextcmd(entry[0].cmdname))
316 rst.extend(helpextcmd(entry[0].cmdname))
317 except error.UnknownCommand:
317 except error.UnknownCommand:
318 pass
318 pass
319 return rst
319 return rst
320
320
321 # synopsis
321 # synopsis
322 if len(entry) > 2:
322 if len(entry) > 2:
323 if entry[2].startswith('hg'):
323 if entry[2].startswith('hg'):
324 rst.append("%s\n" % entry[2])
324 rst.append("%s\n" % entry[2])
325 else:
325 else:
326 rst.append('hg %s %s\n' % (aliases[0], entry[2]))
326 rst.append('hg %s %s\n' % (aliases[0], entry[2]))
327 else:
327 else:
328 rst.append('hg %s\n' % aliases[0])
328 rst.append('hg %s\n' % aliases[0])
329 # aliases
329 # aliases
330 if full and not ui.quiet and len(aliases) > 1:
330 if full and not ui.quiet and len(aliases) > 1:
331 rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:]))
331 rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:]))
332 rst.append('\n')
332 rst.append('\n')
333
333
334 # description
334 # description
335 doc = gettext(entry[0].__doc__)
335 doc = gettext(entry[0].__doc__)
336 if not doc:
336 if not doc:
337 doc = _("(no help text available)")
337 doc = _("(no help text available)")
338 if util.safehasattr(entry[0], 'definition'): # aliased command
338 if util.safehasattr(entry[0], 'definition'): # aliased command
339 source = entry[0].source
339 if entry[0].definition.startswith('!'): # shell alias
340 if entry[0].definition.startswith('!'): # shell alias
340 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:]
341 doc = (_('shell alias for::\n\n %s\n\ndefined by: %s\n') %
342 (entry[0].definition[1:], source))
341 else:
343 else:
342 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
344 doc = (_('alias for: hg %s\n\n%s\n\ndefined by: %s\n') %
345 (entry[0].definition, doc, source))
343 doc = doc.splitlines(True)
346 doc = doc.splitlines(True)
344 if ui.quiet or not full:
347 if ui.quiet or not full:
345 rst.append(doc[0])
348 rst.append(doc[0])
346 else:
349 else:
347 rst.extend(doc)
350 rst.extend(doc)
348 rst.append('\n')
351 rst.append('\n')
349
352
350 # check if this command shadows a non-trivial (multi-line)
353 # check if this command shadows a non-trivial (multi-line)
351 # extension help text
354 # extension help text
352 try:
355 try:
353 mod = extensions.find(name)
356 mod = extensions.find(name)
354 doc = gettext(mod.__doc__) or ''
357 doc = gettext(mod.__doc__) or ''
355 if '\n' in doc.strip():
358 if '\n' in doc.strip():
356 msg = _('(use "hg help -e %s" to show help for '
359 msg = _('(use "hg help -e %s" to show help for '
357 'the %s extension)') % (name, name)
360 'the %s extension)') % (name, name)
358 rst.append('\n%s\n' % msg)
361 rst.append('\n%s\n' % msg)
359 except KeyError:
362 except KeyError:
360 pass
363 pass
361
364
362 # options
365 # options
363 if not ui.quiet and entry[1]:
366 if not ui.quiet and entry[1]:
364 rst.append(optrst(_("options"), entry[1], ui.verbose))
367 rst.append(optrst(_("options"), entry[1], ui.verbose))
365
368
366 if ui.verbose:
369 if ui.verbose:
367 rst.append(optrst(_("global options"),
370 rst.append(optrst(_("global options"),
368 commands.globalopts, ui.verbose))
371 commands.globalopts, ui.verbose))
369
372
370 if not ui.verbose:
373 if not ui.verbose:
371 if not full:
374 if not full:
372 rst.append(_('\n(use "hg %s -h" to show more help)\n')
375 rst.append(_('\n(use "hg %s -h" to show more help)\n')
373 % name)
376 % name)
374 elif not ui.quiet:
377 elif not ui.quiet:
375 rst.append(_('\n(some details hidden, use --verbose '
378 rst.append(_('\n(some details hidden, use --verbose '
376 'to show complete help)'))
379 'to show complete help)'))
377
380
378 return rst
381 return rst
379
382
380
383
381 def helplist(select=None, **opts):
384 def helplist(select=None, **opts):
382 # list of commands
385 # list of commands
383 if name == "shortlist":
386 if name == "shortlist":
384 header = _('basic commands:\n\n')
387 header = _('basic commands:\n\n')
385 elif name == "debug":
388 elif name == "debug":
386 header = _('debug commands (internal and unsupported):\n\n')
389 header = _('debug commands (internal and unsupported):\n\n')
387 else:
390 else:
388 header = _('list of commands:\n\n')
391 header = _('list of commands:\n\n')
389
392
390 h = {}
393 h = {}
391 cmds = {}
394 cmds = {}
392 for c, e in commands.table.iteritems():
395 for c, e in commands.table.iteritems():
393 f = c.partition("|")[0]
396 f = c.partition("|")[0]
394 if select and not select(f):
397 if select and not select(f):
395 continue
398 continue
396 if (not select and name != 'shortlist' and
399 if (not select and name != 'shortlist' and
397 e[0].__module__ != commands.__name__):
400 e[0].__module__ != commands.__name__):
398 continue
401 continue
399 if name == "shortlist" and not f.startswith("^"):
402 if name == "shortlist" and not f.startswith("^"):
400 continue
403 continue
401 f = f.lstrip("^")
404 f = f.lstrip("^")
402 doc = e[0].__doc__
405 doc = e[0].__doc__
403 if filtercmd(ui, f, name, doc):
406 if filtercmd(ui, f, name, doc):
404 continue
407 continue
405 doc = gettext(doc)
408 doc = gettext(doc)
406 if not doc:
409 if not doc:
407 doc = _("(no help text available)")
410 doc = _("(no help text available)")
408 h[f] = doc.splitlines()[0].rstrip()
411 h[f] = doc.splitlines()[0].rstrip()
409 cmds[f] = c.lstrip("^")
412 cmds[f] = c.lstrip("^")
410
413
411 rst = []
414 rst = []
412 if not h:
415 if not h:
413 if not ui.quiet:
416 if not ui.quiet:
414 rst.append(_('no commands defined\n'))
417 rst.append(_('no commands defined\n'))
415 return rst
418 return rst
416
419
417 if not ui.quiet:
420 if not ui.quiet:
418 rst.append(header)
421 rst.append(header)
419 fns = sorted(h)
422 fns = sorted(h)
420 for f in fns:
423 for f in fns:
421 if ui.verbose:
424 if ui.verbose:
422 commacmds = cmds[f].replace("|",", ")
425 commacmds = cmds[f].replace("|",", ")
423 rst.append(" :%s: %s\n" % (commacmds, h[f]))
426 rst.append(" :%s: %s\n" % (commacmds, h[f]))
424 else:
427 else:
425 rst.append(' :%s: %s\n' % (f, h[f]))
428 rst.append(' :%s: %s\n' % (f, h[f]))
426
429
427 ex = opts.get
430 ex = opts.get
428 anyopts = (ex('keyword') or not (ex('command') or ex('extension')))
431 anyopts = (ex('keyword') or not (ex('command') or ex('extension')))
429 if not name and anyopts:
432 if not name and anyopts:
430 exts = listexts(_('enabled extensions:'), extensions.enabled())
433 exts = listexts(_('enabled extensions:'), extensions.enabled())
431 if exts:
434 if exts:
432 rst.append('\n')
435 rst.append('\n')
433 rst.extend(exts)
436 rst.extend(exts)
434
437
435 rst.append(_("\nadditional help topics:\n\n"))
438 rst.append(_("\nadditional help topics:\n\n"))
436 topics = []
439 topics = []
437 for names, header, doc in helptable:
440 for names, header, doc in helptable:
438 topics.append((names[0], header))
441 topics.append((names[0], header))
439 for t, desc in topics:
442 for t, desc in topics:
440 rst.append(" :%s: %s\n" % (t, desc))
443 rst.append(" :%s: %s\n" % (t, desc))
441
444
442 if ui.quiet:
445 if ui.quiet:
443 pass
446 pass
444 elif ui.verbose:
447 elif ui.verbose:
445 rst.append('\n%s\n' % optrst(_("global options"),
448 rst.append('\n%s\n' % optrst(_("global options"),
446 commands.globalopts, ui.verbose))
449 commands.globalopts, ui.verbose))
447 if name == 'shortlist':
450 if name == 'shortlist':
448 rst.append(_('\n(use "hg help" for the full list '
451 rst.append(_('\n(use "hg help" for the full list '
449 'of commands)\n'))
452 'of commands)\n'))
450 else:
453 else:
451 if name == 'shortlist':
454 if name == 'shortlist':
452 rst.append(_('\n(use "hg help" for the full list of commands '
455 rst.append(_('\n(use "hg help" for the full list of commands '
453 'or "hg -v" for details)\n'))
456 'or "hg -v" for details)\n'))
454 elif name and not full:
457 elif name and not full:
455 rst.append(_('\n(use "hg help %s" to show the full help '
458 rst.append(_('\n(use "hg help %s" to show the full help '
456 'text)\n') % name)
459 'text)\n') % name)
457 elif name and cmds and name in cmds.keys():
460 elif name and cmds and name in cmds.keys():
458 rst.append(_('\n(use "hg help -v -e %s" to show built-in '
461 rst.append(_('\n(use "hg help -v -e %s" to show built-in '
459 'aliases and global options)\n') % name)
462 'aliases and global options)\n') % name)
460 else:
463 else:
461 rst.append(_('\n(use "hg help -v%s" to show built-in aliases '
464 rst.append(_('\n(use "hg help -v%s" to show built-in aliases '
462 'and global options)\n')
465 'and global options)\n')
463 % (name and " " + name or ""))
466 % (name and " " + name or ""))
464 return rst
467 return rst
465
468
466 def helptopic(name, subtopic=None):
469 def helptopic(name, subtopic=None):
467 # Look for sub-topic entry first.
470 # Look for sub-topic entry first.
468 header, doc = None, None
471 header, doc = None, None
469 if subtopic and name in subtopics:
472 if subtopic and name in subtopics:
470 for names, header, doc in subtopics[name]:
473 for names, header, doc in subtopics[name]:
471 if subtopic in names:
474 if subtopic in names:
472 break
475 break
473
476
474 if not header:
477 if not header:
475 for names, header, doc in helptable:
478 for names, header, doc in helptable:
476 if name in names:
479 if name in names:
477 break
480 break
478 else:
481 else:
479 raise error.UnknownCommand(name)
482 raise error.UnknownCommand(name)
480
483
481 rst = [minirst.section(header)]
484 rst = [minirst.section(header)]
482
485
483 # description
486 # description
484 if not doc:
487 if not doc:
485 rst.append(" %s\n" % _("(no help text available)"))
488 rst.append(" %s\n" % _("(no help text available)"))
486 if callable(doc):
489 if callable(doc):
487 rst += [" %s\n" % l for l in doc(ui).splitlines()]
490 rst += [" %s\n" % l for l in doc(ui).splitlines()]
488
491
489 if not ui.verbose:
492 if not ui.verbose:
490 omitted = _('(some details hidden, use --verbose'
493 omitted = _('(some details hidden, use --verbose'
491 ' to show complete help)')
494 ' to show complete help)')
492 indicateomitted(rst, omitted)
495 indicateomitted(rst, omitted)
493
496
494 try:
497 try:
495 cmdutil.findcmd(name, commands.table)
498 cmdutil.findcmd(name, commands.table)
496 rst.append(_('\nuse "hg help -c %s" to see help for '
499 rst.append(_('\nuse "hg help -c %s" to see help for '
497 'the %s command\n') % (name, name))
500 'the %s command\n') % (name, name))
498 except error.UnknownCommand:
501 except error.UnknownCommand:
499 pass
502 pass
500 return rst
503 return rst
501
504
502 def helpext(name, subtopic=None):
505 def helpext(name, subtopic=None):
503 try:
506 try:
504 mod = extensions.find(name)
507 mod = extensions.find(name)
505 doc = gettext(mod.__doc__) or _('no help text available')
508 doc = gettext(mod.__doc__) or _('no help text available')
506 except KeyError:
509 except KeyError:
507 mod = None
510 mod = None
508 doc = extensions.disabledext(name)
511 doc = extensions.disabledext(name)
509 if not doc:
512 if not doc:
510 raise error.UnknownCommand(name)
513 raise error.UnknownCommand(name)
511
514
512 if '\n' not in doc:
515 if '\n' not in doc:
513 head, tail = doc, ""
516 head, tail = doc, ""
514 else:
517 else:
515 head, tail = doc.split('\n', 1)
518 head, tail = doc.split('\n', 1)
516 rst = [_('%s extension - %s\n\n') % (name.rpartition('.')[-1], head)]
519 rst = [_('%s extension - %s\n\n') % (name.rpartition('.')[-1], head)]
517 if tail:
520 if tail:
518 rst.extend(tail.splitlines(True))
521 rst.extend(tail.splitlines(True))
519 rst.append('\n')
522 rst.append('\n')
520
523
521 if not ui.verbose:
524 if not ui.verbose:
522 omitted = _('(some details hidden, use --verbose'
525 omitted = _('(some details hidden, use --verbose'
523 ' to show complete help)')
526 ' to show complete help)')
524 indicateomitted(rst, omitted)
527 indicateomitted(rst, omitted)
525
528
526 if mod:
529 if mod:
527 try:
530 try:
528 ct = mod.cmdtable
531 ct = mod.cmdtable
529 except AttributeError:
532 except AttributeError:
530 ct = {}
533 ct = {}
531 modcmds = set([c.partition('|')[0] for c in ct])
534 modcmds = set([c.partition('|')[0] for c in ct])
532 rst.extend(helplist(modcmds.__contains__))
535 rst.extend(helplist(modcmds.__contains__))
533 else:
536 else:
534 rst.append(_('(use "hg help extensions" for information on enabling'
537 rst.append(_('(use "hg help extensions" for information on enabling'
535 ' extensions)\n'))
538 ' extensions)\n'))
536 return rst
539 return rst
537
540
538 def helpextcmd(name, subtopic=None):
541 def helpextcmd(name, subtopic=None):
539 cmd, ext, mod = extensions.disabledcmd(ui, name,
542 cmd, ext, mod = extensions.disabledcmd(ui, name,
540 ui.configbool('ui', 'strict'))
543 ui.configbool('ui', 'strict'))
541 doc = gettext(mod.__doc__).splitlines()[0]
544 doc = gettext(mod.__doc__).splitlines()[0]
542
545
543 rst = listexts(_("'%s' is provided by the following "
546 rst = listexts(_("'%s' is provided by the following "
544 "extension:") % cmd, {ext: doc}, indent=4,
547 "extension:") % cmd, {ext: doc}, indent=4,
545 showdeprecated=True)
548 showdeprecated=True)
546 rst.append('\n')
549 rst.append('\n')
547 rst.append(_('(use "hg help extensions" for information on enabling '
550 rst.append(_('(use "hg help extensions" for information on enabling '
548 'extensions)\n'))
551 'extensions)\n'))
549 return rst
552 return rst
550
553
551
554
552 rst = []
555 rst = []
553 kw = opts.get('keyword')
556 kw = opts.get('keyword')
554 if kw or name is None and any(opts[o] for o in opts):
557 if kw or name is None and any(opts[o] for o in opts):
555 matches = topicmatch(ui, name or '')
558 matches = topicmatch(ui, name or '')
556 helpareas = []
559 helpareas = []
557 if opts.get('extension'):
560 if opts.get('extension'):
558 helpareas += [('extensions', _('Extensions'))]
561 helpareas += [('extensions', _('Extensions'))]
559 if opts.get('command'):
562 if opts.get('command'):
560 helpareas += [('commands', _('Commands'))]
563 helpareas += [('commands', _('Commands'))]
561 if not helpareas:
564 if not helpareas:
562 helpareas = [('topics', _('Topics')),
565 helpareas = [('topics', _('Topics')),
563 ('commands', _('Commands')),
566 ('commands', _('Commands')),
564 ('extensions', _('Extensions')),
567 ('extensions', _('Extensions')),
565 ('extensioncommands', _('Extension Commands'))]
568 ('extensioncommands', _('Extension Commands'))]
566 for t, title in helpareas:
569 for t, title in helpareas:
567 if matches[t]:
570 if matches[t]:
568 rst.append('%s:\n\n' % title)
571 rst.append('%s:\n\n' % title)
569 rst.extend(minirst.maketable(sorted(matches[t]), 1))
572 rst.extend(minirst.maketable(sorted(matches[t]), 1))
570 rst.append('\n')
573 rst.append('\n')
571 if not rst:
574 if not rst:
572 msg = _('no matches')
575 msg = _('no matches')
573 hint = _('try "hg help" for a list of topics')
576 hint = _('try "hg help" for a list of topics')
574 raise error.Abort(msg, hint=hint)
577 raise error.Abort(msg, hint=hint)
575 elif name and name != 'shortlist':
578 elif name and name != 'shortlist':
576 queries = []
579 queries = []
577 if unknowncmd:
580 if unknowncmd:
578 queries += [helpextcmd]
581 queries += [helpextcmd]
579 if opts.get('extension'):
582 if opts.get('extension'):
580 queries += [helpext]
583 queries += [helpext]
581 if opts.get('command'):
584 if opts.get('command'):
582 queries += [helpcmd]
585 queries += [helpcmd]
583 if not queries:
586 if not queries:
584 queries = (helptopic, helpcmd, helpext, helpextcmd)
587 queries = (helptopic, helpcmd, helpext, helpextcmd)
585 for f in queries:
588 for f in queries:
586 try:
589 try:
587 rst = f(name, subtopic)
590 rst = f(name, subtopic)
588 break
591 break
589 except error.UnknownCommand:
592 except error.UnknownCommand:
590 pass
593 pass
591 else:
594 else:
592 if unknowncmd:
595 if unknowncmd:
593 raise error.UnknownCommand(name)
596 raise error.UnknownCommand(name)
594 else:
597 else:
595 msg = _('no such help topic: %s') % name
598 msg = _('no such help topic: %s') % name
596 hint = _('try "hg help --keyword %s"') % name
599 hint = _('try "hg help --keyword %s"') % name
597 raise error.Abort(msg, hint=hint)
600 raise error.Abort(msg, hint=hint)
598 else:
601 else:
599 # program name
602 # program name
600 if not ui.quiet:
603 if not ui.quiet:
601 rst = [_("Mercurial Distributed SCM\n"), '\n']
604 rst = [_("Mercurial Distributed SCM\n"), '\n']
602 rst.extend(helplist(None, **opts))
605 rst.extend(helplist(None, **opts))
603
606
604 return ''.join(rst)
607 return ''.join(rst)
@@ -1,3003 +1,3057 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 $ hg help
47 $ hg help
48 Mercurial Distributed SCM
48 Mercurial Distributed SCM
49
49
50 list of commands:
50 list of commands:
51
51
52 add add the specified files on the next commit
52 add add the specified files on the next commit
53 addremove add all new files, delete all missing files
53 addremove add all new files, delete all missing files
54 annotate show changeset information by line for each file
54 annotate show changeset information by line for each file
55 archive create an unversioned archive of a repository revision
55 archive create an unversioned archive of a repository revision
56 backout reverse effect of earlier changeset
56 backout reverse effect of earlier changeset
57 bisect subdivision search of changesets
57 bisect subdivision search of changesets
58 bookmarks create a new bookmark or list existing bookmarks
58 bookmarks create a new bookmark or list existing bookmarks
59 branch set or show the current branch name
59 branch set or show the current branch name
60 branches list repository named branches
60 branches list repository named branches
61 bundle create a changegroup file
61 bundle create a changegroup file
62 cat output the current or given revision of files
62 cat output the current or given revision of files
63 clone make a copy of an existing repository
63 clone make a copy of an existing repository
64 commit commit the specified files or all outstanding changes
64 commit commit the specified files or all outstanding changes
65 config show combined config settings from all hgrc files
65 config show combined config settings from all hgrc files
66 copy mark files as copied for the next commit
66 copy mark files as copied for the next commit
67 diff diff repository (or selected files)
67 diff diff repository (or selected files)
68 export dump the header and diffs for one or more changesets
68 export dump the header and diffs for one or more changesets
69 files list tracked files
69 files list tracked files
70 forget forget the specified files on the next commit
70 forget forget the specified files on the next commit
71 graft copy changes from other branches onto the current branch
71 graft copy changes from other branches onto the current branch
72 grep search for a pattern in specified files and revisions
72 grep search for a pattern in specified files and revisions
73 heads show branch heads
73 heads show branch heads
74 help show help for a given topic or a help overview
74 help show help for a given topic or a help overview
75 identify identify the working directory or specified revision
75 identify identify the working directory or specified revision
76 import import an ordered set of patches
76 import import an ordered set of patches
77 incoming show new changesets found in source
77 incoming show new changesets found in source
78 init create a new repository in the given directory
78 init create a new repository in the given directory
79 log show revision history of entire repository or files
79 log show revision history of entire repository or files
80 manifest output the current or given revision of the project manifest
80 manifest output the current or given revision of the project manifest
81 merge merge another revision into working directory
81 merge merge another revision into working directory
82 outgoing show changesets not found in the destination
82 outgoing show changesets not found in the destination
83 paths show aliases for remote repositories
83 paths show aliases for remote repositories
84 phase set or show the current phase name
84 phase set or show the current phase name
85 pull pull changes from the specified source
85 pull pull changes from the specified source
86 push push changes to the specified destination
86 push push changes to the specified destination
87 recover roll back an interrupted transaction
87 recover roll back an interrupted transaction
88 remove remove the specified files on the next commit
88 remove remove the specified files on the next commit
89 rename rename files; equivalent of copy + remove
89 rename rename files; equivalent of copy + remove
90 resolve redo merges or set/view the merge status of files
90 resolve redo merges or set/view the merge status of files
91 revert restore files to their checkout state
91 revert restore files to their checkout state
92 root print the root (top) of the current working directory
92 root print the root (top) of the current working directory
93 serve start stand-alone webserver
93 serve start stand-alone webserver
94 status show changed files in the working directory
94 status show changed files in the working directory
95 summary summarize working directory state
95 summary summarize working directory state
96 tag add one or more tags for the current or given revision
96 tag add one or more tags for the current or given revision
97 tags list repository tags
97 tags list repository tags
98 unbundle apply one or more changegroup files
98 unbundle apply one or more changegroup files
99 update update working directory (or switch revisions)
99 update update working directory (or switch revisions)
100 verify verify the integrity of the repository
100 verify verify the integrity of the repository
101 version output version and copyright information
101 version output version and copyright information
102
102
103 additional help topics:
103 additional help topics:
104
104
105 config Configuration Files
105 config Configuration Files
106 dates Date Formats
106 dates Date Formats
107 diffs Diff Formats
107 diffs Diff Formats
108 environment Environment Variables
108 environment Environment Variables
109 extensions Using Additional Features
109 extensions Using Additional Features
110 filesets Specifying File Sets
110 filesets Specifying File Sets
111 glossary Glossary
111 glossary Glossary
112 hgignore Syntax for Mercurial Ignore Files
112 hgignore Syntax for Mercurial Ignore Files
113 hgweb Configuring hgweb
113 hgweb Configuring hgweb
114 internals Technical implementation topics
114 internals Technical implementation topics
115 merge-tools Merge Tools
115 merge-tools Merge Tools
116 multirevs Specifying Multiple Revisions
116 multirevs Specifying Multiple Revisions
117 patterns File Name Patterns
117 patterns File Name Patterns
118 phases Working with Phases
118 phases Working with Phases
119 revisions Specifying Single Revisions
119 revisions Specifying Single Revisions
120 revsets Specifying Revision Sets
120 revsets Specifying Revision Sets
121 scripting Using Mercurial from scripts and automation
121 scripting Using Mercurial from scripts and automation
122 subrepos Subrepositories
122 subrepos Subrepositories
123 templating Template Usage
123 templating Template Usage
124 urls URL Paths
124 urls URL Paths
125
125
126 (use "hg help -v" to show built-in aliases and global options)
126 (use "hg help -v" to show built-in aliases and global options)
127
127
128 $ hg -q help
128 $ hg -q help
129 add add the specified files on the next commit
129 add add the specified files on the next commit
130 addremove add all new files, delete all missing files
130 addremove add all new files, delete all missing files
131 annotate show changeset information by line for each file
131 annotate show changeset information by line for each file
132 archive create an unversioned archive of a repository revision
132 archive create an unversioned archive of a repository revision
133 backout reverse effect of earlier changeset
133 backout reverse effect of earlier changeset
134 bisect subdivision search of changesets
134 bisect subdivision search of changesets
135 bookmarks create a new bookmark or list existing bookmarks
135 bookmarks create a new bookmark or list existing bookmarks
136 branch set or show the current branch name
136 branch set or show the current branch name
137 branches list repository named branches
137 branches list repository named branches
138 bundle create a changegroup file
138 bundle create a changegroup file
139 cat output the current or given revision of files
139 cat output the current or given revision of files
140 clone make a copy of an existing repository
140 clone make a copy of an existing repository
141 commit commit the specified files or all outstanding changes
141 commit commit the specified files or all outstanding changes
142 config show combined config settings from all hgrc files
142 config show combined config settings from all hgrc files
143 copy mark files as copied for the next commit
143 copy mark files as copied for the next commit
144 diff diff repository (or selected files)
144 diff diff repository (or selected files)
145 export dump the header and diffs for one or more changesets
145 export dump the header and diffs for one or more changesets
146 files list tracked files
146 files list tracked files
147 forget forget the specified files on the next commit
147 forget forget the specified files on the next commit
148 graft copy changes from other branches onto the current branch
148 graft copy changes from other branches onto the current branch
149 grep search for a pattern in specified files and revisions
149 grep search for a pattern in specified files and revisions
150 heads show branch heads
150 heads show branch heads
151 help show help for a given topic or a help overview
151 help show help for a given topic or a help overview
152 identify identify the working directory or specified revision
152 identify identify the working directory or specified revision
153 import import an ordered set of patches
153 import import an ordered set of patches
154 incoming show new changesets found in source
154 incoming show new changesets found in source
155 init create a new repository in the given directory
155 init create a new repository in the given directory
156 log show revision history of entire repository or files
156 log show revision history of entire repository or files
157 manifest output the current or given revision of the project manifest
157 manifest output the current or given revision of the project manifest
158 merge merge another revision into working directory
158 merge merge another revision into working directory
159 outgoing show changesets not found in the destination
159 outgoing show changesets not found in the destination
160 paths show aliases for remote repositories
160 paths show aliases for remote repositories
161 phase set or show the current phase name
161 phase set or show the current phase name
162 pull pull changes from the specified source
162 pull pull changes from the specified source
163 push push changes to the specified destination
163 push push changes to the specified destination
164 recover roll back an interrupted transaction
164 recover roll back an interrupted transaction
165 remove remove the specified files on the next commit
165 remove remove the specified files on the next commit
166 rename rename files; equivalent of copy + remove
166 rename rename files; equivalent of copy + remove
167 resolve redo merges or set/view the merge status of files
167 resolve redo merges or set/view the merge status of files
168 revert restore files to their checkout state
168 revert restore files to their checkout state
169 root print the root (top) of the current working directory
169 root print the root (top) of the current working directory
170 serve start stand-alone webserver
170 serve start stand-alone webserver
171 status show changed files in the working directory
171 status show changed files in the working directory
172 summary summarize working directory state
172 summary summarize working directory state
173 tag add one or more tags for the current or given revision
173 tag add one or more tags for the current or given revision
174 tags list repository tags
174 tags list repository tags
175 unbundle apply one or more changegroup files
175 unbundle apply one or more changegroup files
176 update update working directory (or switch revisions)
176 update update working directory (or switch revisions)
177 verify verify the integrity of the repository
177 verify verify the integrity of the repository
178 version output version and copyright information
178 version output version and copyright information
179
179
180 additional help topics:
180 additional help topics:
181
181
182 config Configuration Files
182 config Configuration Files
183 dates Date Formats
183 dates Date Formats
184 diffs Diff Formats
184 diffs Diff Formats
185 environment Environment Variables
185 environment Environment Variables
186 extensions Using Additional Features
186 extensions Using Additional Features
187 filesets Specifying File Sets
187 filesets Specifying File Sets
188 glossary Glossary
188 glossary Glossary
189 hgignore Syntax for Mercurial Ignore Files
189 hgignore Syntax for Mercurial Ignore Files
190 hgweb Configuring hgweb
190 hgweb Configuring hgweb
191 internals Technical implementation topics
191 internals Technical implementation topics
192 merge-tools Merge Tools
192 merge-tools Merge Tools
193 multirevs Specifying Multiple Revisions
193 multirevs Specifying Multiple Revisions
194 patterns File Name Patterns
194 patterns File Name Patterns
195 phases Working with Phases
195 phases Working with Phases
196 revisions Specifying Single Revisions
196 revisions Specifying Single Revisions
197 revsets Specifying Revision Sets
197 revsets Specifying Revision Sets
198 scripting Using Mercurial from scripts and automation
198 scripting Using Mercurial from scripts and automation
199 subrepos Subrepositories
199 subrepos Subrepositories
200 templating Template Usage
200 templating Template Usage
201 urls URL Paths
201 urls URL Paths
202
202
203 Test extension help:
203 Test extension help:
204 $ hg help extensions --config extensions.rebase= --config extensions.children=
204 $ hg help extensions --config extensions.rebase= --config extensions.children=
205 Using Additional Features
205 Using Additional Features
206 """""""""""""""""""""""""
206 """""""""""""""""""""""""
207
207
208 Mercurial has the ability to add new features through the use of
208 Mercurial has the ability to add new features through the use of
209 extensions. Extensions may add new commands, add options to existing
209 extensions. Extensions may add new commands, add options to existing
210 commands, change the default behavior of commands, or implement hooks.
210 commands, change the default behavior of commands, or implement hooks.
211
211
212 To enable the "foo" extension, either shipped with Mercurial or in the
212 To enable the "foo" extension, either shipped with Mercurial or in the
213 Python search path, create an entry for it in your configuration file,
213 Python search path, create an entry for it in your configuration file,
214 like this:
214 like this:
215
215
216 [extensions]
216 [extensions]
217 foo =
217 foo =
218
218
219 You may also specify the full path to an extension:
219 You may also specify the full path to an extension:
220
220
221 [extensions]
221 [extensions]
222 myfeature = ~/.hgext/myfeature.py
222 myfeature = ~/.hgext/myfeature.py
223
223
224 See 'hg help config' for more information on configuration files.
224 See 'hg help config' for more information on configuration files.
225
225
226 Extensions are not loaded by default for a variety of reasons: they can
226 Extensions are not loaded by default for a variety of reasons: they can
227 increase startup overhead; they may be meant for advanced usage only; they
227 increase startup overhead; they may be meant for advanced usage only; they
228 may provide potentially dangerous abilities (such as letting you destroy
228 may provide potentially dangerous abilities (such as letting you destroy
229 or modify history); they might not be ready for prime time; or they may
229 or modify history); they might not be ready for prime time; or they may
230 alter some usual behaviors of stock Mercurial. It is thus up to the user
230 alter some usual behaviors of stock Mercurial. It is thus up to the user
231 to activate extensions as needed.
231 to activate extensions as needed.
232
232
233 To explicitly disable an extension enabled in a configuration file of
233 To explicitly disable an extension enabled in a configuration file of
234 broader scope, prepend its path with !:
234 broader scope, prepend its path with !:
235
235
236 [extensions]
236 [extensions]
237 # disabling extension bar residing in /path/to/extension/bar.py
237 # disabling extension bar residing in /path/to/extension/bar.py
238 bar = !/path/to/extension/bar.py
238 bar = !/path/to/extension/bar.py
239 # ditto, but no path was supplied for extension baz
239 # ditto, but no path was supplied for extension baz
240 baz = !
240 baz = !
241
241
242 enabled extensions:
242 enabled extensions:
243
243
244 chgserver command server extension for cHg (EXPERIMENTAL) (?)
244 chgserver command server extension for cHg (EXPERIMENTAL) (?)
245 children command to display child changesets (DEPRECATED)
245 children command to display child changesets (DEPRECATED)
246 rebase command to move sets of revisions to a different ancestor
246 rebase command to move sets of revisions to a different ancestor
247
247
248 disabled extensions:
248 disabled extensions:
249
249
250 acl hooks for controlling repository access
250 acl hooks for controlling repository access
251 blackbox log repository events to a blackbox for debugging
251 blackbox log repository events to a blackbox for debugging
252 bugzilla hooks for integrating with the Bugzilla bug tracker
252 bugzilla hooks for integrating with the Bugzilla bug tracker
253 censor erase file content at a given revision
253 censor erase file content at a given revision
254 churn command to display statistics about repository history
254 churn command to display statistics about repository history
255 clonebundles advertise pre-generated bundles to seed clones
255 clonebundles advertise pre-generated bundles to seed clones
256 color colorize output from some commands
256 color colorize output from some commands
257 convert import revisions from foreign VCS repositories into
257 convert import revisions from foreign VCS repositories into
258 Mercurial
258 Mercurial
259 eol automatically manage newlines in repository files
259 eol automatically manage newlines in repository files
260 extdiff command to allow external programs to compare revisions
260 extdiff command to allow external programs to compare revisions
261 factotum http authentication with factotum
261 factotum http authentication with factotum
262 gpg commands to sign and verify changesets
262 gpg commands to sign and verify changesets
263 hgcia hooks for integrating with the CIA.vc notification service
263 hgcia hooks for integrating with the CIA.vc notification service
264 hgk browse the repository in a graphical way
264 hgk browse the repository in a graphical way
265 highlight syntax highlighting for hgweb (requires Pygments)
265 highlight syntax highlighting for hgweb (requires Pygments)
266 histedit interactive history editing
266 histedit interactive history editing
267 keyword expand keywords in tracked files
267 keyword expand keywords in tracked files
268 largefiles track large binary files
268 largefiles track large binary files
269 mq manage a stack of patches
269 mq manage a stack of patches
270 notify hooks for sending email push notifications
270 notify hooks for sending email push notifications
271 pager browse command output with an external pager
271 pager browse command output with an external pager
272 patchbomb command to send changesets as (a series of) patch emails
272 patchbomb command to send changesets as (a series of) patch emails
273 purge command to delete untracked files from the working
273 purge command to delete untracked files from the working
274 directory
274 directory
275 relink recreates hardlinks between repository clones
275 relink recreates hardlinks between repository clones
276 schemes extend schemes with shortcuts to repository swarms
276 schemes extend schemes with shortcuts to repository swarms
277 share share a common history between several working directories
277 share share a common history between several working directories
278 shelve save and restore changes to the working directory
278 shelve save and restore changes to the working directory
279 strip strip changesets and their descendants from history
279 strip strip changesets and their descendants from history
280 transplant command to transplant changesets from another branch
280 transplant command to transplant changesets from another branch
281 win32mbcs allow the use of MBCS paths with problematic encodings
281 win32mbcs allow the use of MBCS paths with problematic encodings
282 zeroconf discover and advertise repositories on the local network
282 zeroconf discover and advertise repositories on the local network
283
283
284 Verify that extension keywords appear in help templates
284 Verify that extension keywords appear in help templates
285
285
286 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
286 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
287
287
288 Test short command list with verbose option
288 Test short command list with verbose option
289
289
290 $ hg -v help shortlist
290 $ hg -v help shortlist
291 Mercurial Distributed SCM
291 Mercurial Distributed SCM
292
292
293 basic commands:
293 basic commands:
294
294
295 add add the specified files on the next commit
295 add add the specified files on the next commit
296 annotate, blame
296 annotate, blame
297 show changeset information by line for each file
297 show changeset information by line for each file
298 clone make a copy of an existing repository
298 clone make a copy of an existing repository
299 commit, ci commit the specified files or all outstanding changes
299 commit, ci commit the specified files or all outstanding changes
300 diff diff repository (or selected files)
300 diff diff repository (or selected files)
301 export dump the header and diffs for one or more changesets
301 export dump the header and diffs for one or more changesets
302 forget forget the specified files on the next commit
302 forget forget the specified files on the next commit
303 init create a new repository in the given directory
303 init create a new repository in the given directory
304 log, history show revision history of entire repository or files
304 log, history show revision history of entire repository or files
305 merge merge another revision into working directory
305 merge merge another revision into working directory
306 pull pull changes from the specified source
306 pull pull changes from the specified source
307 push push changes to the specified destination
307 push push changes to the specified destination
308 remove, rm remove the specified files on the next commit
308 remove, rm remove the specified files on the next commit
309 serve start stand-alone webserver
309 serve start stand-alone webserver
310 status, st show changed files in the working directory
310 status, st show changed files in the working directory
311 summary, sum summarize working directory state
311 summary, sum summarize working directory state
312 update, up, checkout, co
312 update, up, checkout, co
313 update working directory (or switch revisions)
313 update working directory (or switch revisions)
314
314
315 global options ([+] can be repeated):
315 global options ([+] can be repeated):
316
316
317 -R --repository REPO repository root directory or name of overlay bundle
317 -R --repository REPO repository root directory or name of overlay bundle
318 file
318 file
319 --cwd DIR change working directory
319 --cwd DIR change working directory
320 -y --noninteractive do not prompt, automatically pick the first choice for
320 -y --noninteractive do not prompt, automatically pick the first choice for
321 all prompts
321 all prompts
322 -q --quiet suppress output
322 -q --quiet suppress output
323 -v --verbose enable additional output
323 -v --verbose enable additional output
324 --config CONFIG [+] set/override config option (use 'section.name=value')
324 --config CONFIG [+] set/override config option (use 'section.name=value')
325 --debug enable debugging output
325 --debug enable debugging output
326 --debugger start debugger
326 --debugger start debugger
327 --encoding ENCODE set the charset encoding (default: ascii)
327 --encoding ENCODE set the charset encoding (default: ascii)
328 --encodingmode MODE set the charset encoding mode (default: strict)
328 --encodingmode MODE set the charset encoding mode (default: strict)
329 --traceback always print a traceback on exception
329 --traceback always print a traceback on exception
330 --time time how long the command takes
330 --time time how long the command takes
331 --profile print command execution profile
331 --profile print command execution profile
332 --version output version information and exit
332 --version output version information and exit
333 -h --help display help and exit
333 -h --help display help and exit
334 --hidden consider hidden changesets
334 --hidden consider hidden changesets
335
335
336 (use "hg help" for the full list of commands)
336 (use "hg help" for the full list of commands)
337
337
338 $ hg add -h
338 $ hg add -h
339 hg add [OPTION]... [FILE]...
339 hg add [OPTION]... [FILE]...
340
340
341 add the specified files on the next commit
341 add the specified files on the next commit
342
342
343 Schedule files to be version controlled and added to the repository.
343 Schedule files to be version controlled and added to the repository.
344
344
345 The files will be added to the repository at the next commit. To undo an
345 The files will be added to the repository at the next commit. To undo an
346 add before that, see 'hg forget'.
346 add before that, see 'hg forget'.
347
347
348 If no names are given, add all files to the repository (except files
348 If no names are given, add all files to the repository (except files
349 matching ".hgignore").
349 matching ".hgignore").
350
350
351 Returns 0 if all files are successfully added.
351 Returns 0 if all files are successfully added.
352
352
353 options ([+] can be repeated):
353 options ([+] can be repeated):
354
354
355 -I --include PATTERN [+] include names matching the given patterns
355 -I --include PATTERN [+] include names matching the given patterns
356 -X --exclude PATTERN [+] exclude names matching the given patterns
356 -X --exclude PATTERN [+] exclude names matching the given patterns
357 -S --subrepos recurse into subrepositories
357 -S --subrepos recurse into subrepositories
358 -n --dry-run do not perform actions, just print output
358 -n --dry-run do not perform actions, just print output
359
359
360 (some details hidden, use --verbose to show complete help)
360 (some details hidden, use --verbose to show complete help)
361
361
362 Verbose help for add
362 Verbose help for add
363
363
364 $ hg add -hv
364 $ hg add -hv
365 hg add [OPTION]... [FILE]...
365 hg add [OPTION]... [FILE]...
366
366
367 add the specified files on the next commit
367 add the specified files on the next commit
368
368
369 Schedule files to be version controlled and added to the repository.
369 Schedule files to be version controlled and added to the repository.
370
370
371 The files will be added to the repository at the next commit. To undo an
371 The files will be added to the repository at the next commit. To undo an
372 add before that, see 'hg forget'.
372 add before that, see 'hg forget'.
373
373
374 If no names are given, add all files to the repository (except files
374 If no names are given, add all files to the repository (except files
375 matching ".hgignore").
375 matching ".hgignore").
376
376
377 Examples:
377 Examples:
378
378
379 - New (unknown) files are added automatically by 'hg add':
379 - New (unknown) files are added automatically by 'hg add':
380
380
381 $ ls
381 $ ls
382 foo.c
382 foo.c
383 $ hg status
383 $ hg status
384 ? foo.c
384 ? foo.c
385 $ hg add
385 $ hg add
386 adding foo.c
386 adding foo.c
387 $ hg status
387 $ hg status
388 A foo.c
388 A foo.c
389
389
390 - Specific files to be added can be specified:
390 - Specific files to be added can be specified:
391
391
392 $ ls
392 $ ls
393 bar.c foo.c
393 bar.c foo.c
394 $ hg status
394 $ hg status
395 ? bar.c
395 ? bar.c
396 ? foo.c
396 ? foo.c
397 $ hg add bar.c
397 $ hg add bar.c
398 $ hg status
398 $ hg status
399 A bar.c
399 A bar.c
400 ? foo.c
400 ? foo.c
401
401
402 Returns 0 if all files are successfully added.
402 Returns 0 if all files are successfully added.
403
403
404 options ([+] can be repeated):
404 options ([+] can be repeated):
405
405
406 -I --include PATTERN [+] include names matching the given patterns
406 -I --include PATTERN [+] include names matching the given patterns
407 -X --exclude PATTERN [+] exclude names matching the given patterns
407 -X --exclude PATTERN [+] exclude names matching the given patterns
408 -S --subrepos recurse into subrepositories
408 -S --subrepos recurse into subrepositories
409 -n --dry-run do not perform actions, just print output
409 -n --dry-run do not perform actions, just print output
410
410
411 global options ([+] can be repeated):
411 global options ([+] can be repeated):
412
412
413 -R --repository REPO repository root directory or name of overlay bundle
413 -R --repository REPO repository root directory or name of overlay bundle
414 file
414 file
415 --cwd DIR change working directory
415 --cwd DIR change working directory
416 -y --noninteractive do not prompt, automatically pick the first choice for
416 -y --noninteractive do not prompt, automatically pick the first choice for
417 all prompts
417 all prompts
418 -q --quiet suppress output
418 -q --quiet suppress output
419 -v --verbose enable additional output
419 -v --verbose enable additional output
420 --config CONFIG [+] set/override config option (use 'section.name=value')
420 --config CONFIG [+] set/override config option (use 'section.name=value')
421 --debug enable debugging output
421 --debug enable debugging output
422 --debugger start debugger
422 --debugger start debugger
423 --encoding ENCODE set the charset encoding (default: ascii)
423 --encoding ENCODE set the charset encoding (default: ascii)
424 --encodingmode MODE set the charset encoding mode (default: strict)
424 --encodingmode MODE set the charset encoding mode (default: strict)
425 --traceback always print a traceback on exception
425 --traceback always print a traceback on exception
426 --time time how long the command takes
426 --time time how long the command takes
427 --profile print command execution profile
427 --profile print command execution profile
428 --version output version information and exit
428 --version output version information and exit
429 -h --help display help and exit
429 -h --help display help and exit
430 --hidden consider hidden changesets
430 --hidden consider hidden changesets
431
431
432 Test help option with version option
432 Test help option with version option
433
433
434 $ hg add -h --version
434 $ hg add -h --version
435 Mercurial Distributed SCM (version *) (glob)
435 Mercurial Distributed SCM (version *) (glob)
436 (see https://mercurial-scm.org for more information)
436 (see https://mercurial-scm.org for more information)
437
437
438 Copyright (C) 2005-2016 Matt Mackall and others
438 Copyright (C) 2005-2016 Matt Mackall and others
439 This is free software; see the source for copying conditions. There is NO
439 This is free software; see the source for copying conditions. There is NO
440 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
440 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
441
441
442 $ hg add --skjdfks
442 $ hg add --skjdfks
443 hg add: option --skjdfks not recognized
443 hg add: option --skjdfks not recognized
444 hg add [OPTION]... [FILE]...
444 hg add [OPTION]... [FILE]...
445
445
446 add the specified files on the next commit
446 add the specified files on the next commit
447
447
448 options ([+] can be repeated):
448 options ([+] can be repeated):
449
449
450 -I --include PATTERN [+] include names matching the given patterns
450 -I --include PATTERN [+] include names matching the given patterns
451 -X --exclude PATTERN [+] exclude names matching the given patterns
451 -X --exclude PATTERN [+] exclude names matching the given patterns
452 -S --subrepos recurse into subrepositories
452 -S --subrepos recurse into subrepositories
453 -n --dry-run do not perform actions, just print output
453 -n --dry-run do not perform actions, just print output
454
454
455 (use "hg add -h" to show more help)
455 (use "hg add -h" to show more help)
456 [255]
456 [255]
457
457
458 Test ambiguous command help
458 Test ambiguous command help
459
459
460 $ hg help ad
460 $ hg help ad
461 list of commands:
461 list of commands:
462
462
463 add add the specified files on the next commit
463 add add the specified files on the next commit
464 addremove add all new files, delete all missing files
464 addremove add all new files, delete all missing files
465
465
466 (use "hg help -v ad" to show built-in aliases and global options)
466 (use "hg help -v ad" to show built-in aliases and global options)
467
467
468 Test command without options
468 Test command without options
469
469
470 $ hg help verify
470 $ hg help verify
471 hg verify
471 hg verify
472
472
473 verify the integrity of the repository
473 verify the integrity of the repository
474
474
475 Verify the integrity of the current repository.
475 Verify the integrity of the current repository.
476
476
477 This will perform an extensive check of the repository's integrity,
477 This will perform an extensive check of the repository's integrity,
478 validating the hashes and checksums of each entry in the changelog,
478 validating the hashes and checksums of each entry in the changelog,
479 manifest, and tracked files, as well as the integrity of their crosslinks
479 manifest, and tracked files, as well as the integrity of their crosslinks
480 and indices.
480 and indices.
481
481
482 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
482 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
483 information about recovery from corruption of the repository.
483 information about recovery from corruption of the repository.
484
484
485 Returns 0 on success, 1 if errors are encountered.
485 Returns 0 on success, 1 if errors are encountered.
486
486
487 (some details hidden, use --verbose to show complete help)
487 (some details hidden, use --verbose to show complete help)
488
488
489 $ hg help diff
489 $ hg help diff
490 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
490 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
491
491
492 diff repository (or selected files)
492 diff repository (or selected files)
493
493
494 Show differences between revisions for the specified files.
494 Show differences between revisions for the specified files.
495
495
496 Differences between files are shown using the unified diff format.
496 Differences between files are shown using the unified diff format.
497
497
498 Note:
498 Note:
499 'hg diff' may generate unexpected results for merges, as it will
499 'hg diff' may generate unexpected results for merges, as it will
500 default to comparing against the working directory's first parent
500 default to comparing against the working directory's first parent
501 changeset if no revisions are specified.
501 changeset if no revisions are specified.
502
502
503 When two revision arguments are given, then changes are shown between
503 When two revision arguments are given, then changes are shown between
504 those revisions. If only one revision is specified then that revision is
504 those revisions. If only one revision is specified then that revision is
505 compared to the working directory, and, when no revisions are specified,
505 compared to the working directory, and, when no revisions are specified,
506 the working directory files are compared to its first parent.
506 the working directory files are compared to its first parent.
507
507
508 Alternatively you can specify -c/--change with a revision to see the
508 Alternatively you can specify -c/--change with a revision to see the
509 changes in that changeset relative to its first parent.
509 changes in that changeset relative to its first parent.
510
510
511 Without the -a/--text option, diff will avoid generating diffs of files it
511 Without the -a/--text option, diff will avoid generating diffs of files it
512 detects as binary. With -a, diff will generate a diff anyway, probably
512 detects as binary. With -a, diff will generate a diff anyway, probably
513 with undesirable results.
513 with undesirable results.
514
514
515 Use the -g/--git option to generate diffs in the git extended diff format.
515 Use the -g/--git option to generate diffs in the git extended diff format.
516 For more information, read 'hg help diffs'.
516 For more information, read 'hg help diffs'.
517
517
518 Returns 0 on success.
518 Returns 0 on success.
519
519
520 options ([+] can be repeated):
520 options ([+] can be repeated):
521
521
522 -r --rev REV [+] revision
522 -r --rev REV [+] revision
523 -c --change REV change made by revision
523 -c --change REV change made by revision
524 -a --text treat all files as text
524 -a --text treat all files as text
525 -g --git use git extended diff format
525 -g --git use git extended diff format
526 --nodates omit dates from diff headers
526 --nodates omit dates from diff headers
527 --noprefix omit a/ and b/ prefixes from filenames
527 --noprefix omit a/ and b/ prefixes from filenames
528 -p --show-function show which function each change is in
528 -p --show-function show which function each change is in
529 --reverse produce a diff that undoes the changes
529 --reverse produce a diff that undoes the changes
530 -w --ignore-all-space ignore white space when comparing lines
530 -w --ignore-all-space ignore white space when comparing lines
531 -b --ignore-space-change ignore changes in the amount of white space
531 -b --ignore-space-change ignore changes in the amount of white space
532 -B --ignore-blank-lines ignore changes whose lines are all blank
532 -B --ignore-blank-lines ignore changes whose lines are all blank
533 -U --unified NUM number of lines of context to show
533 -U --unified NUM number of lines of context to show
534 --stat output diffstat-style summary of changes
534 --stat output diffstat-style summary of changes
535 --root DIR produce diffs relative to subdirectory
535 --root DIR produce diffs relative to subdirectory
536 -I --include PATTERN [+] include names matching the given patterns
536 -I --include PATTERN [+] include names matching the given patterns
537 -X --exclude PATTERN [+] exclude names matching the given patterns
537 -X --exclude PATTERN [+] exclude names matching the given patterns
538 -S --subrepos recurse into subrepositories
538 -S --subrepos recurse into subrepositories
539
539
540 (some details hidden, use --verbose to show complete help)
540 (some details hidden, use --verbose to show complete help)
541
541
542 $ hg help status
542 $ hg help status
543 hg status [OPTION]... [FILE]...
543 hg status [OPTION]... [FILE]...
544
544
545 aliases: st
545 aliases: st
546
546
547 show changed files in the working directory
547 show changed files in the working directory
548
548
549 Show status of files in the repository. If names are given, only files
549 Show status of files in the repository. If names are given, only files
550 that match are shown. Files that are clean or ignored or the source of a
550 that match are shown. Files that are clean or ignored or the source of a
551 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
551 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
552 -C/--copies or -A/--all are given. Unless options described with "show
552 -C/--copies or -A/--all are given. Unless options described with "show
553 only ..." are given, the options -mardu are used.
553 only ..." are given, the options -mardu are used.
554
554
555 Option -q/--quiet hides untracked (unknown and ignored) files unless
555 Option -q/--quiet hides untracked (unknown and ignored) files unless
556 explicitly requested with -u/--unknown or -i/--ignored.
556 explicitly requested with -u/--unknown or -i/--ignored.
557
557
558 Note:
558 Note:
559 'hg status' may appear to disagree with diff if permissions have
559 'hg status' may appear to disagree with diff if permissions have
560 changed or a merge has occurred. The standard diff format does not
560 changed or a merge has occurred. The standard diff format does not
561 report permission changes and diff only reports changes relative to one
561 report permission changes and diff only reports changes relative to one
562 merge parent.
562 merge parent.
563
563
564 If one revision is given, it is used as the base revision. If two
564 If one revision is given, it is used as the base revision. If two
565 revisions are given, the differences between them are shown. The --change
565 revisions are given, the differences between them are shown. The --change
566 option can also be used as a shortcut to list the changed files of a
566 option can also be used as a shortcut to list the changed files of a
567 revision from its first parent.
567 revision from its first parent.
568
568
569 The codes used to show the status of files are:
569 The codes used to show the status of files are:
570
570
571 M = modified
571 M = modified
572 A = added
572 A = added
573 R = removed
573 R = removed
574 C = clean
574 C = clean
575 ! = missing (deleted by non-hg command, but still tracked)
575 ! = missing (deleted by non-hg command, but still tracked)
576 ? = not tracked
576 ? = not tracked
577 I = ignored
577 I = ignored
578 = origin of the previous file (with --copies)
578 = origin of the previous file (with --copies)
579
579
580 Returns 0 on success.
580 Returns 0 on success.
581
581
582 options ([+] can be repeated):
582 options ([+] can be repeated):
583
583
584 -A --all show status of all files
584 -A --all show status of all files
585 -m --modified show only modified files
585 -m --modified show only modified files
586 -a --added show only added files
586 -a --added show only added files
587 -r --removed show only removed files
587 -r --removed show only removed files
588 -d --deleted show only deleted (but tracked) files
588 -d --deleted show only deleted (but tracked) files
589 -c --clean show only files without changes
589 -c --clean show only files without changes
590 -u --unknown show only unknown (not tracked) files
590 -u --unknown show only unknown (not tracked) files
591 -i --ignored show only ignored files
591 -i --ignored show only ignored files
592 -n --no-status hide status prefix
592 -n --no-status hide status prefix
593 -C --copies show source of copied files
593 -C --copies show source of copied files
594 -0 --print0 end filenames with NUL, for use with xargs
594 -0 --print0 end filenames with NUL, for use with xargs
595 --rev REV [+] show difference from revision
595 --rev REV [+] show difference from revision
596 --change REV list the changed files of a revision
596 --change REV list the changed files of a revision
597 -I --include PATTERN [+] include names matching the given patterns
597 -I --include PATTERN [+] include names matching the given patterns
598 -X --exclude PATTERN [+] exclude names matching the given patterns
598 -X --exclude PATTERN [+] exclude names matching the given patterns
599 -S --subrepos recurse into subrepositories
599 -S --subrepos recurse into subrepositories
600
600
601 (some details hidden, use --verbose to show complete help)
601 (some details hidden, use --verbose to show complete help)
602
602
603 $ hg -q help status
603 $ hg -q help status
604 hg status [OPTION]... [FILE]...
604 hg status [OPTION]... [FILE]...
605
605
606 show changed files in the working directory
606 show changed files in the working directory
607
607
608 $ hg help foo
608 $ hg help foo
609 abort: no such help topic: foo
609 abort: no such help topic: foo
610 (try "hg help --keyword foo")
610 (try "hg help --keyword foo")
611 [255]
611 [255]
612
612
613 $ hg skjdfks
613 $ hg skjdfks
614 hg: unknown command 'skjdfks'
614 hg: unknown command 'skjdfks'
615 Mercurial Distributed SCM
615 Mercurial Distributed SCM
616
616
617 basic commands:
617 basic commands:
618
618
619 add add the specified files on the next commit
619 add add the specified files on the next commit
620 annotate show changeset information by line for each file
620 annotate show changeset information by line for each file
621 clone make a copy of an existing repository
621 clone make a copy of an existing repository
622 commit commit the specified files or all outstanding changes
622 commit commit the specified files or all outstanding changes
623 diff diff repository (or selected files)
623 diff diff repository (or selected files)
624 export dump the header and diffs for one or more changesets
624 export dump the header and diffs for one or more changesets
625 forget forget the specified files on the next commit
625 forget forget the specified files on the next commit
626 init create a new repository in the given directory
626 init create a new repository in the given directory
627 log show revision history of entire repository or files
627 log show revision history of entire repository or files
628 merge merge another revision into working directory
628 merge merge another revision into working directory
629 pull pull changes from the specified source
629 pull pull changes from the specified source
630 push push changes to the specified destination
630 push push changes to the specified destination
631 remove remove the specified files on the next commit
631 remove remove the specified files on the next commit
632 serve start stand-alone webserver
632 serve start stand-alone webserver
633 status show changed files in the working directory
633 status show changed files in the working directory
634 summary summarize working directory state
634 summary summarize working directory state
635 update update working directory (or switch revisions)
635 update update working directory (or switch revisions)
636
636
637 (use "hg help" for the full list of commands or "hg -v" for details)
637 (use "hg help" for the full list of commands or "hg -v" for details)
638 [255]
638 [255]
639
639
640
640
641 Make sure that we don't run afoul of the help system thinking that
641 Make sure that we don't run afoul of the help system thinking that
642 this is a section and erroring out weirdly.
642 this is a section and erroring out weirdly.
643
643
644 $ hg .log
644 $ hg .log
645 hg: unknown command '.log'
645 hg: unknown command '.log'
646 (did you mean log?)
646 (did you mean log?)
647 [255]
647 [255]
648
648
649 $ hg log.
649 $ hg log.
650 hg: unknown command 'log.'
650 hg: unknown command 'log.'
651 (did you mean log?)
651 (did you mean log?)
652 [255]
652 [255]
653 $ hg pu.lh
653 $ hg pu.lh
654 hg: unknown command 'pu.lh'
654 hg: unknown command 'pu.lh'
655 (did you mean one of pull, push?)
655 (did you mean one of pull, push?)
656 [255]
656 [255]
657
657
658 $ cat > helpext.py <<EOF
658 $ cat > helpext.py <<EOF
659 > import os
659 > import os
660 > from mercurial import cmdutil, commands
660 > from mercurial import cmdutil, commands
661 >
661 >
662 > cmdtable = {}
662 > cmdtable = {}
663 > command = cmdutil.command(cmdtable)
663 > command = cmdutil.command(cmdtable)
664 >
664 >
665 > @command('nohelp',
665 > @command('nohelp',
666 > [('', 'longdesc', 3, 'x'*90),
666 > [('', 'longdesc', 3, 'x'*90),
667 > ('n', '', None, 'normal desc'),
667 > ('n', '', None, 'normal desc'),
668 > ('', 'newline', '', 'line1\nline2')],
668 > ('', 'newline', '', 'line1\nline2')],
669 > 'hg nohelp',
669 > 'hg nohelp',
670 > norepo=True)
670 > norepo=True)
671 > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
671 > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
672 > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
672 > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
673 > def nohelp(ui, *args, **kwargs):
673 > def nohelp(ui, *args, **kwargs):
674 > pass
674 > pass
675 >
675 >
676 > def uisetup(ui):
677 > ui.setconfig('alias', 'shellalias', '!echo hi', 'helpext')
678 > ui.setconfig('alias', 'hgalias', 'summary', 'helpext')
679 >
676 > EOF
680 > EOF
677 $ echo '[extensions]' >> $HGRCPATH
681 $ echo '[extensions]' >> $HGRCPATH
678 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
682 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
679
683
684 Test for aliases
685
686 $ hg help hgalias
687 hg hgalias [--remote]
688
689 alias for: hg summary
690
691 summarize working directory state
692
693 This generates a brief summary of the working directory state, including
694 parents, branch, commit status, phase and available updates.
695
696 With the --remote option, this will check the default paths for incoming
697 and outgoing changes. This can be time-consuming.
698
699 Returns 0 on success.
700
701 defined by: helpext
702
703 options:
704
705 --remote check for push and pull
706
707 (some details hidden, use --verbose to show complete help)
708
709 $ hg help shellalias
710 hg shellalias
711
712 shell alias for:
713
714 echo hi
715
716 defined by: helpext
717
718 (some details hidden, use --verbose to show complete help)
719
680 Test command with no help text
720 Test command with no help text
681
721
682 $ hg help nohelp
722 $ hg help nohelp
683 hg nohelp
723 hg nohelp
684
724
685 (no help text available)
725 (no help text available)
686
726
687 options:
727 options:
688
728
689 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
729 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
690 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
730 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
691 -n -- normal desc
731 -n -- normal desc
692 --newline VALUE line1 line2
732 --newline VALUE line1 line2
693
733
694 (some details hidden, use --verbose to show complete help)
734 (some details hidden, use --verbose to show complete help)
695
735
696 $ hg help -k nohelp
736 $ hg help -k nohelp
697 Commands:
737 Commands:
698
738
699 nohelp hg nohelp
739 nohelp hg nohelp
700
740
701 Extension Commands:
741 Extension Commands:
702
742
703 nohelp (no help text available)
743 nohelp (no help text available)
704
744
705 Test that default list of commands omits extension commands
745 Test that default list of commands omits extension commands
706
746
707 $ hg help
747 $ hg help
708 Mercurial Distributed SCM
748 Mercurial Distributed SCM
709
749
710 list of commands:
750 list of commands:
711
751
712 add add the specified files on the next commit
752 add add the specified files on the next commit
713 addremove add all new files, delete all missing files
753 addremove add all new files, delete all missing files
714 annotate show changeset information by line for each file
754 annotate show changeset information by line for each file
715 archive create an unversioned archive of a repository revision
755 archive create an unversioned archive of a repository revision
716 backout reverse effect of earlier changeset
756 backout reverse effect of earlier changeset
717 bisect subdivision search of changesets
757 bisect subdivision search of changesets
718 bookmarks create a new bookmark or list existing bookmarks
758 bookmarks create a new bookmark or list existing bookmarks
719 branch set or show the current branch name
759 branch set or show the current branch name
720 branches list repository named branches
760 branches list repository named branches
721 bundle create a changegroup file
761 bundle create a changegroup file
722 cat output the current or given revision of files
762 cat output the current or given revision of files
723 clone make a copy of an existing repository
763 clone make a copy of an existing repository
724 commit commit the specified files or all outstanding changes
764 commit commit the specified files or all outstanding changes
725 config show combined config settings from all hgrc files
765 config show combined config settings from all hgrc files
726 copy mark files as copied for the next commit
766 copy mark files as copied for the next commit
727 diff diff repository (or selected files)
767 diff diff repository (or selected files)
728 export dump the header and diffs for one or more changesets
768 export dump the header and diffs for one or more changesets
729 files list tracked files
769 files list tracked files
730 forget forget the specified files on the next commit
770 forget forget the specified files on the next commit
731 graft copy changes from other branches onto the current branch
771 graft copy changes from other branches onto the current branch
732 grep search for a pattern in specified files and revisions
772 grep search for a pattern in specified files and revisions
733 heads show branch heads
773 heads show branch heads
734 help show help for a given topic or a help overview
774 help show help for a given topic or a help overview
735 identify identify the working directory or specified revision
775 identify identify the working directory or specified revision
736 import import an ordered set of patches
776 import import an ordered set of patches
737 incoming show new changesets found in source
777 incoming show new changesets found in source
738 init create a new repository in the given directory
778 init create a new repository in the given directory
739 log show revision history of entire repository or files
779 log show revision history of entire repository or files
740 manifest output the current or given revision of the project manifest
780 manifest output the current or given revision of the project manifest
741 merge merge another revision into working directory
781 merge merge another revision into working directory
742 outgoing show changesets not found in the destination
782 outgoing show changesets not found in the destination
743 paths show aliases for remote repositories
783 paths show aliases for remote repositories
744 phase set or show the current phase name
784 phase set or show the current phase name
745 pull pull changes from the specified source
785 pull pull changes from the specified source
746 push push changes to the specified destination
786 push push changes to the specified destination
747 recover roll back an interrupted transaction
787 recover roll back an interrupted transaction
748 remove remove the specified files on the next commit
788 remove remove the specified files on the next commit
749 rename rename files; equivalent of copy + remove
789 rename rename files; equivalent of copy + remove
750 resolve redo merges or set/view the merge status of files
790 resolve redo merges or set/view the merge status of files
751 revert restore files to their checkout state
791 revert restore files to their checkout state
752 root print the root (top) of the current working directory
792 root print the root (top) of the current working directory
753 serve start stand-alone webserver
793 serve start stand-alone webserver
754 status show changed files in the working directory
794 status show changed files in the working directory
755 summary summarize working directory state
795 summary summarize working directory state
756 tag add one or more tags for the current or given revision
796 tag add one or more tags for the current or given revision
757 tags list repository tags
797 tags list repository tags
758 unbundle apply one or more changegroup files
798 unbundle apply one or more changegroup files
759 update update working directory (or switch revisions)
799 update update working directory (or switch revisions)
760 verify verify the integrity of the repository
800 verify verify the integrity of the repository
761 version output version and copyright information
801 version output version and copyright information
762
802
763 enabled extensions:
803 enabled extensions:
764
804
765 helpext (no help text available)
805 helpext (no help text available)
766
806
767 additional help topics:
807 additional help topics:
768
808
769 config Configuration Files
809 config Configuration Files
770 dates Date Formats
810 dates Date Formats
771 diffs Diff Formats
811 diffs Diff Formats
772 environment Environment Variables
812 environment Environment Variables
773 extensions Using Additional Features
813 extensions Using Additional Features
774 filesets Specifying File Sets
814 filesets Specifying File Sets
775 glossary Glossary
815 glossary Glossary
776 hgignore Syntax for Mercurial Ignore Files
816 hgignore Syntax for Mercurial Ignore Files
777 hgweb Configuring hgweb
817 hgweb Configuring hgweb
778 internals Technical implementation topics
818 internals Technical implementation topics
779 merge-tools Merge Tools
819 merge-tools Merge Tools
780 multirevs Specifying Multiple Revisions
820 multirevs Specifying Multiple Revisions
781 patterns File Name Patterns
821 patterns File Name Patterns
782 phases Working with Phases
822 phases Working with Phases
783 revisions Specifying Single Revisions
823 revisions Specifying Single Revisions
784 revsets Specifying Revision Sets
824 revsets Specifying Revision Sets
785 scripting Using Mercurial from scripts and automation
825 scripting Using Mercurial from scripts and automation
786 subrepos Subrepositories
826 subrepos Subrepositories
787 templating Template Usage
827 templating Template Usage
788 urls URL Paths
828 urls URL Paths
789
829
790 (use "hg help -v" to show built-in aliases and global options)
830 (use "hg help -v" to show built-in aliases and global options)
791
831
792
832
793 Test list of internal help commands
833 Test list of internal help commands
794
834
795 $ hg help debug
835 $ hg help debug
796 debug commands (internal and unsupported):
836 debug commands (internal and unsupported):
797
837
798 debugancestor
838 debugancestor
799 find the ancestor revision of two revisions in a given index
839 find the ancestor revision of two revisions in a given index
800 debugapplystreamclonebundle
840 debugapplystreamclonebundle
801 apply a stream clone bundle file
841 apply a stream clone bundle file
802 debugbuilddag
842 debugbuilddag
803 builds a repo with a given DAG from scratch in the current
843 builds a repo with a given DAG from scratch in the current
804 empty repo
844 empty repo
805 debugbundle lists the contents of a bundle
845 debugbundle lists the contents of a bundle
806 debugcheckstate
846 debugcheckstate
807 validate the correctness of the current dirstate
847 validate the correctness of the current dirstate
808 debugcommands
848 debugcommands
809 list all available commands and options
849 list all available commands and options
810 debugcomplete
850 debugcomplete
811 returns the completion list associated with the given command
851 returns the completion list associated with the given command
812 debugcreatestreamclonebundle
852 debugcreatestreamclonebundle
813 create a stream clone bundle file
853 create a stream clone bundle file
814 debugdag format the changelog or an index DAG as a concise textual
854 debugdag format the changelog or an index DAG as a concise textual
815 description
855 description
816 debugdata dump the contents of a data file revision
856 debugdata dump the contents of a data file revision
817 debugdate parse and display a date
857 debugdate parse and display a date
818 debugdeltachain
858 debugdeltachain
819 dump information about delta chains in a revlog
859 dump information about delta chains in a revlog
820 debugdirstate
860 debugdirstate
821 show the contents of the current dirstate
861 show the contents of the current dirstate
822 debugdiscovery
862 debugdiscovery
823 runs the changeset discovery protocol in isolation
863 runs the changeset discovery protocol in isolation
824 debugextensions
864 debugextensions
825 show information about active extensions
865 show information about active extensions
826 debugfileset parse and apply a fileset specification
866 debugfileset parse and apply a fileset specification
827 debugfsinfo show information detected about current filesystem
867 debugfsinfo show information detected about current filesystem
828 debuggetbundle
868 debuggetbundle
829 retrieves a bundle from a repo
869 retrieves a bundle from a repo
830 debugignore display the combined ignore pattern and information about
870 debugignore display the combined ignore pattern and information about
831 ignored files
871 ignored files
832 debugindex dump the contents of an index file
872 debugindex dump the contents of an index file
833 debugindexdot
873 debugindexdot
834 dump an index DAG as a graphviz dot file
874 dump an index DAG as a graphviz dot file
835 debuginstall test Mercurial installation
875 debuginstall test Mercurial installation
836 debugknown test whether node ids are known to a repo
876 debugknown test whether node ids are known to a repo
837 debuglocks show or modify state of locks
877 debuglocks show or modify state of locks
838 debugmergestate
878 debugmergestate
839 print merge state
879 print merge state
840 debugnamecomplete
880 debugnamecomplete
841 complete "names" - tags, open branch names, bookmark names
881 complete "names" - tags, open branch names, bookmark names
842 debugobsolete
882 debugobsolete
843 create arbitrary obsolete marker
883 create arbitrary obsolete marker
844 debugoptDEP (no help text available)
884 debugoptDEP (no help text available)
845 debugoptEXP (no help text available)
885 debugoptEXP (no help text available)
846 debugpathcomplete
886 debugpathcomplete
847 complete part or all of a tracked path
887 complete part or all of a tracked path
848 debugpushkey access the pushkey key/value protocol
888 debugpushkey access the pushkey key/value protocol
849 debugpvec (no help text available)
889 debugpvec (no help text available)
850 debugrebuilddirstate
890 debugrebuilddirstate
851 rebuild the dirstate as it would look like for the given
891 rebuild the dirstate as it would look like for the given
852 revision
892 revision
853 debugrebuildfncache
893 debugrebuildfncache
854 rebuild the fncache file
894 rebuild the fncache file
855 debugrename dump rename information
895 debugrename dump rename information
856 debugrevlog show data and statistics about a revlog
896 debugrevlog show data and statistics about a revlog
857 debugrevspec parse and apply a revision specification
897 debugrevspec parse and apply a revision specification
858 debugsetparents
898 debugsetparents
859 manually set the parents of the current working directory
899 manually set the parents of the current working directory
860 debugsub (no help text available)
900 debugsub (no help text available)
861 debugsuccessorssets
901 debugsuccessorssets
862 show set of successors for revision
902 show set of successors for revision
863 debugtemplate
903 debugtemplate
864 parse and apply a template
904 parse and apply a template
865 debugwalk show how files match on given patterns
905 debugwalk show how files match on given patterns
866 debugwireargs
906 debugwireargs
867 (no help text available)
907 (no help text available)
868
908
869 (use "hg help -v debug" to show built-in aliases and global options)
909 (use "hg help -v debug" to show built-in aliases and global options)
870
910
871 internals topic renders index of available sub-topics
911 internals topic renders index of available sub-topics
872
912
873 $ hg help internals
913 $ hg help internals
874 Technical implementation topics
914 Technical implementation topics
875 """""""""""""""""""""""""""""""
915 """""""""""""""""""""""""""""""
876
916
877 bundles container for exchange of repository data
917 bundles container for exchange of repository data
878 changegroups representation of revlog data
918 changegroups representation of revlog data
879 requirements repository requirements
919 requirements repository requirements
880 revlogs revision storage mechanism
920 revlogs revision storage mechanism
881
921
882 sub-topics can be accessed
922 sub-topics can be accessed
883
923
884 $ hg help internals.changegroups
924 $ hg help internals.changegroups
885 Changegroups
925 Changegroups
886 ============
926 ============
887
927
888 Changegroups are representations of repository revlog data, specifically
928 Changegroups are representations of repository revlog data, specifically
889 the changelog, manifest, and filelogs.
929 the changelog, manifest, and filelogs.
890
930
891 There are 3 versions of changegroups: "1", "2", and "3". From a high-
931 There are 3 versions of changegroups: "1", "2", and "3". From a high-
892 level, versions "1" and "2" are almost exactly the same, with the only
932 level, versions "1" and "2" are almost exactly the same, with the only
893 difference being a header on entries in the changeset segment. Version "3"
933 difference being a header on entries in the changeset segment. Version "3"
894 adds support for exchanging treemanifests and includes revlog flags in the
934 adds support for exchanging treemanifests and includes revlog flags in the
895 delta header.
935 delta header.
896
936
897 Changegroups consists of 3 logical segments:
937 Changegroups consists of 3 logical segments:
898
938
899 +---------------------------------+
939 +---------------------------------+
900 | | | |
940 | | | |
901 | changeset | manifest | filelogs |
941 | changeset | manifest | filelogs |
902 | | | |
942 | | | |
903 +---------------------------------+
943 +---------------------------------+
904
944
905 The principle building block of each segment is a *chunk*. A *chunk* is a
945 The principle building block of each segment is a *chunk*. A *chunk* is a
906 framed piece of data:
946 framed piece of data:
907
947
908 +---------------------------------------+
948 +---------------------------------------+
909 | | |
949 | | |
910 | length | data |
950 | length | data |
911 | (32 bits) | <length> bytes |
951 | (32 bits) | <length> bytes |
912 | | |
952 | | |
913 +---------------------------------------+
953 +---------------------------------------+
914
954
915 Each chunk starts with a 32-bit big-endian signed integer indicating the
955 Each chunk starts with a 32-bit big-endian signed integer indicating the
916 length of the raw data that follows.
956 length of the raw data that follows.
917
957
918 There is a special case chunk that has 0 length ("0x00000000"). We call
958 There is a special case chunk that has 0 length ("0x00000000"). We call
919 this an *empty chunk*.
959 this an *empty chunk*.
920
960
921 Delta Groups
961 Delta Groups
922 ------------
962 ------------
923
963
924 A *delta group* expresses the content of a revlog as a series of deltas,
964 A *delta group* expresses the content of a revlog as a series of deltas,
925 or patches against previous revisions.
965 or patches against previous revisions.
926
966
927 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
967 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
928 to signal the end of the delta group:
968 to signal the end of the delta group:
929
969
930 +------------------------------------------------------------------------+
970 +------------------------------------------------------------------------+
931 | | | | | |
971 | | | | | |
932 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
972 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
933 | (32 bits) | (various) | (32 bits) | (various) | (32 bits) |
973 | (32 bits) | (various) | (32 bits) | (various) | (32 bits) |
934 | | | | | |
974 | | | | | |
935 +------------------------------------------------------------+-----------+
975 +------------------------------------------------------------+-----------+
936
976
937 Each *chunk*'s data consists of the following:
977 Each *chunk*'s data consists of the following:
938
978
939 +-----------------------------------------+
979 +-----------------------------------------+
940 | | | |
980 | | | |
941 | delta header | mdiff header | delta |
981 | delta header | mdiff header | delta |
942 | (various) | (12 bytes) | (various) |
982 | (various) | (12 bytes) | (various) |
943 | | | |
983 | | | |
944 +-----------------------------------------+
984 +-----------------------------------------+
945
985
946 The *length* field is the byte length of the remaining 3 logical pieces of
986 The *length* field is the byte length of the remaining 3 logical pieces of
947 data. The *delta* is a diff from an existing entry in the changelog.
987 data. The *delta* is a diff from an existing entry in the changelog.
948
988
949 The *delta header* is different between versions "1", "2", and "3" of the
989 The *delta header* is different between versions "1", "2", and "3" of the
950 changegroup format.
990 changegroup format.
951
991
952 Version 1:
992 Version 1:
953
993
954 +------------------------------------------------------+
994 +------------------------------------------------------+
955 | | | | |
995 | | | | |
956 | node | p1 node | p2 node | link node |
996 | node | p1 node | p2 node | link node |
957 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
997 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
958 | | | | |
998 | | | | |
959 +------------------------------------------------------+
999 +------------------------------------------------------+
960
1000
961 Version 2:
1001 Version 2:
962
1002
963 +------------------------------------------------------------------+
1003 +------------------------------------------------------------------+
964 | | | | | |
1004 | | | | | |
965 | node | p1 node | p2 node | base node | link node |
1005 | node | p1 node | p2 node | base node | link node |
966 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
1006 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
967 | | | | | |
1007 | | | | | |
968 +------------------------------------------------------------------+
1008 +------------------------------------------------------------------+
969
1009
970 Version 3:
1010 Version 3:
971
1011
972 +------------------------------------------------------------------------------+
1012 +------------------------------------------------------------------------------+
973 | | | | | | |
1013 | | | | | | |
974 | node | p1 node | p2 node | base node | link node | flags |
1014 | node | p1 node | p2 node | base node | link node | flags |
975 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
1015 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
976 | | | | | | |
1016 | | | | | | |
977 +------------------------------------------------------------------------------+
1017 +------------------------------------------------------------------------------+
978
1018
979 The *mdiff header* consists of 3 32-bit big-endian signed integers
1019 The *mdiff header* consists of 3 32-bit big-endian signed integers
980 describing offsets at which to apply the following delta content:
1020 describing offsets at which to apply the following delta content:
981
1021
982 +-------------------------------------+
1022 +-------------------------------------+
983 | | | |
1023 | | | |
984 | offset | old length | new length |
1024 | offset | old length | new length |
985 | (32 bits) | (32 bits) | (32 bits) |
1025 | (32 bits) | (32 bits) | (32 bits) |
986 | | | |
1026 | | | |
987 +-------------------------------------+
1027 +-------------------------------------+
988
1028
989 In version 1, the delta is always applied against the previous node from
1029 In version 1, the delta is always applied against the previous node from
990 the changegroup or the first parent if this is the first entry in the
1030 the changegroup or the first parent if this is the first entry in the
991 changegroup.
1031 changegroup.
992
1032
993 In version 2, the delta base node is encoded in the entry in the
1033 In version 2, the delta base node is encoded in the entry in the
994 changegroup. This allows the delta to be expressed against any parent,
1034 changegroup. This allows the delta to be expressed against any parent,
995 which can result in smaller deltas and more efficient encoding of data.
1035 which can result in smaller deltas and more efficient encoding of data.
996
1036
997 Changeset Segment
1037 Changeset Segment
998 -----------------
1038 -----------------
999
1039
1000 The *changeset segment* consists of a single *delta group* holding
1040 The *changeset segment* consists of a single *delta group* holding
1001 changelog data. It is followed by an *empty chunk* to denote the boundary
1041 changelog data. It is followed by an *empty chunk* to denote the boundary
1002 to the *manifests segment*.
1042 to the *manifests segment*.
1003
1043
1004 Manifest Segment
1044 Manifest Segment
1005 ----------------
1045 ----------------
1006
1046
1007 The *manifest segment* consists of a single *delta group* holding manifest
1047 The *manifest segment* consists of a single *delta group* holding manifest
1008 data. It is followed by an *empty chunk* to denote the boundary to the
1048 data. It is followed by an *empty chunk* to denote the boundary to the
1009 *filelogs segment*.
1049 *filelogs segment*.
1010
1050
1011 Filelogs Segment
1051 Filelogs Segment
1012 ----------------
1052 ----------------
1013
1053
1014 The *filelogs* segment consists of multiple sub-segments, each
1054 The *filelogs* segment consists of multiple sub-segments, each
1015 corresponding to an individual file whose data is being described:
1055 corresponding to an individual file whose data is being described:
1016
1056
1017 +--------------------------------------+
1057 +--------------------------------------+
1018 | | | | |
1058 | | | | |
1019 | filelog0 | filelog1 | filelog2 | ... |
1059 | filelog0 | filelog1 | filelog2 | ... |
1020 | | | | |
1060 | | | | |
1021 +--------------------------------------+
1061 +--------------------------------------+
1022
1062
1023 In version "3" of the changegroup format, filelogs may include directory
1063 In version "3" of the changegroup format, filelogs may include directory
1024 logs when treemanifests are in use. directory logs are identified by
1064 logs when treemanifests are in use. directory logs are identified by
1025 having a trailing '/' on their filename (see below).
1065 having a trailing '/' on their filename (see below).
1026
1066
1027 The final filelog sub-segment is followed by an *empty chunk* to denote
1067 The final filelog sub-segment is followed by an *empty chunk* to denote
1028 the end of the segment and the overall changegroup.
1068 the end of the segment and the overall changegroup.
1029
1069
1030 Each filelog sub-segment consists of the following:
1070 Each filelog sub-segment consists of the following:
1031
1071
1032 +------------------------------------------+
1072 +------------------------------------------+
1033 | | | |
1073 | | | |
1034 | filename size | filename | delta group |
1074 | filename size | filename | delta group |
1035 | (32 bits) | (various) | (various) |
1075 | (32 bits) | (various) | (various) |
1036 | | | |
1076 | | | |
1037 +------------------------------------------+
1077 +------------------------------------------+
1038
1078
1039 That is, a *chunk* consisting of the filename (not terminated or padded)
1079 That is, a *chunk* consisting of the filename (not terminated or padded)
1040 followed by N chunks constituting the *delta group* for this file.
1080 followed by N chunks constituting the *delta group* for this file.
1041
1081
1042 Test list of commands with command with no help text
1082 Test list of commands with command with no help text
1043
1083
1044 $ hg help helpext
1084 $ hg help helpext
1045 helpext extension - no help text available
1085 helpext extension - no help text available
1046
1086
1047 list of commands:
1087 list of commands:
1048
1088
1049 nohelp (no help text available)
1089 nohelp (no help text available)
1050
1090
1051 (use "hg help -v helpext" to show built-in aliases and global options)
1091 (use "hg help -v helpext" to show built-in aliases and global options)
1052
1092
1053
1093
1054 test deprecated and experimental options are hidden in command help
1094 test deprecated and experimental options are hidden in command help
1055 $ hg help debugoptDEP
1095 $ hg help debugoptDEP
1056 hg debugoptDEP
1096 hg debugoptDEP
1057
1097
1058 (no help text available)
1098 (no help text available)
1059
1099
1060 options:
1100 options:
1061
1101
1062 (some details hidden, use --verbose to show complete help)
1102 (some details hidden, use --verbose to show complete help)
1063
1103
1064 $ hg help debugoptEXP
1104 $ hg help debugoptEXP
1065 hg debugoptEXP
1105 hg debugoptEXP
1066
1106
1067 (no help text available)
1107 (no help text available)
1068
1108
1069 options:
1109 options:
1070
1110
1071 (some details hidden, use --verbose to show complete help)
1111 (some details hidden, use --verbose to show complete help)
1072
1112
1073 test deprecated and experimental options is shown with -v
1113 test deprecated and experimental options is shown with -v
1074 $ hg help -v debugoptDEP | grep dopt
1114 $ hg help -v debugoptDEP | grep dopt
1075 --dopt option is (DEPRECATED)
1115 --dopt option is (DEPRECATED)
1076 $ hg help -v debugoptEXP | grep eopt
1116 $ hg help -v debugoptEXP | grep eopt
1077 --eopt option is (EXPERIMENTAL)
1117 --eopt option is (EXPERIMENTAL)
1078
1118
1079 #if gettext
1119 #if gettext
1080 test deprecated option is hidden with translation with untranslated description
1120 test deprecated option is hidden with translation with untranslated description
1081 (use many globy for not failing on changed transaction)
1121 (use many globy for not failing on changed transaction)
1082 $ LANGUAGE=sv hg help debugoptDEP
1122 $ LANGUAGE=sv hg help debugoptDEP
1083 hg debugoptDEP
1123 hg debugoptDEP
1084
1124
1085 (*) (glob)
1125 (*) (glob)
1086
1126
1087 options:
1127 options:
1088
1128
1089 (some details hidden, use --verbose to show complete help)
1129 (some details hidden, use --verbose to show complete help)
1090 #endif
1130 #endif
1091
1131
1092 Test commands that collide with topics (issue4240)
1132 Test commands that collide with topics (issue4240)
1093
1133
1094 $ hg config -hq
1134 $ hg config -hq
1095 hg config [-u] [NAME]...
1135 hg config [-u] [NAME]...
1096
1136
1097 show combined config settings from all hgrc files
1137 show combined config settings from all hgrc files
1098 $ hg showconfig -hq
1138 $ hg showconfig -hq
1099 hg config [-u] [NAME]...
1139 hg config [-u] [NAME]...
1100
1140
1101 show combined config settings from all hgrc files
1141 show combined config settings from all hgrc files
1102
1142
1103 Test a help topic
1143 Test a help topic
1104
1144
1105 $ hg help revs
1145 $ hg help revs
1106 Specifying Single Revisions
1146 Specifying Single Revisions
1107 """""""""""""""""""""""""""
1147 """""""""""""""""""""""""""
1108
1148
1109 Mercurial supports several ways to specify individual revisions.
1149 Mercurial supports several ways to specify individual revisions.
1110
1150
1111 A plain integer is treated as a revision number. Negative integers are
1151 A plain integer is treated as a revision number. Negative integers are
1112 treated as sequential offsets from the tip, with -1 denoting the tip, -2
1152 treated as sequential offsets from the tip, with -1 denoting the tip, -2
1113 denoting the revision prior to the tip, and so forth.
1153 denoting the revision prior to the tip, and so forth.
1114
1154
1115 A 40-digit hexadecimal string is treated as a unique revision identifier.
1155 A 40-digit hexadecimal string is treated as a unique revision identifier.
1116
1156
1117 A hexadecimal string less than 40 characters long is treated as a unique
1157 A hexadecimal string less than 40 characters long is treated as a unique
1118 revision identifier and is referred to as a short-form identifier. A
1158 revision identifier and is referred to as a short-form identifier. A
1119 short-form identifier is only valid if it is the prefix of exactly one
1159 short-form identifier is only valid if it is the prefix of exactly one
1120 full-length identifier.
1160 full-length identifier.
1121
1161
1122 Any other string is treated as a bookmark, tag, or branch name. A bookmark
1162 Any other string is treated as a bookmark, tag, or branch name. A bookmark
1123 is a movable pointer to a revision. A tag is a permanent name associated
1163 is a movable pointer to a revision. A tag is a permanent name associated
1124 with a revision. A branch name denotes the tipmost open branch head of
1164 with a revision. A branch name denotes the tipmost open branch head of
1125 that branch - or if they are all closed, the tipmost closed head of the
1165 that branch - or if they are all closed, the tipmost closed head of the
1126 branch. Bookmark, tag, and branch names must not contain the ":"
1166 branch. Bookmark, tag, and branch names must not contain the ":"
1127 character.
1167 character.
1128
1168
1129 The reserved name "tip" always identifies the most recent revision.
1169 The reserved name "tip" always identifies the most recent revision.
1130
1170
1131 The reserved name "null" indicates the null revision. This is the revision
1171 The reserved name "null" indicates the null revision. This is the revision
1132 of an empty repository, and the parent of revision 0.
1172 of an empty repository, and the parent of revision 0.
1133
1173
1134 The reserved name "." indicates the working directory parent. If no
1174 The reserved name "." indicates the working directory parent. If no
1135 working directory is checked out, it is equivalent to null. If an
1175 working directory is checked out, it is equivalent to null. If an
1136 uncommitted merge is in progress, "." is the revision of the first parent.
1176 uncommitted merge is in progress, "." is the revision of the first parent.
1137
1177
1138 Test repeated config section name
1178 Test repeated config section name
1139
1179
1140 $ hg help config.host
1180 $ hg help config.host
1141 "http_proxy.host"
1181 "http_proxy.host"
1142 Host name and (optional) port of the proxy server, for example
1182 Host name and (optional) port of the proxy server, for example
1143 "myproxy:8000".
1183 "myproxy:8000".
1144
1184
1145 "smtp.host"
1185 "smtp.host"
1146 Host name of mail server, e.g. "mail.example.com".
1186 Host name of mail server, e.g. "mail.example.com".
1147
1187
1148 Unrelated trailing paragraphs shouldn't be included
1188 Unrelated trailing paragraphs shouldn't be included
1149
1189
1150 $ hg help config.extramsg | grep '^$'
1190 $ hg help config.extramsg | grep '^$'
1151
1191
1152
1192
1153 Test capitalized section name
1193 Test capitalized section name
1154
1194
1155 $ hg help scripting.HGPLAIN > /dev/null
1195 $ hg help scripting.HGPLAIN > /dev/null
1156
1196
1157 Help subsection:
1197 Help subsection:
1158
1198
1159 $ hg help config.charsets |grep "Email example:" > /dev/null
1199 $ hg help config.charsets |grep "Email example:" > /dev/null
1160 [1]
1200 [1]
1161
1201
1162 Show nested definitions
1202 Show nested definitions
1163 ("profiling.type"[break]"ls"[break]"stat"[break])
1203 ("profiling.type"[break]"ls"[break]"stat"[break])
1164
1204
1165 $ hg help config.type | egrep '^$'|wc -l
1205 $ hg help config.type | egrep '^$'|wc -l
1166 \s*3 (re)
1206 \s*3 (re)
1167
1207
1168 Separate sections from subsections
1208 Separate sections from subsections
1169
1209
1170 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1210 $ hg help config.format | egrep '^ ("|-)|^\s*$' | uniq
1171 "format"
1211 "format"
1172 --------
1212 --------
1173
1213
1174 "usegeneraldelta"
1214 "usegeneraldelta"
1175
1215
1176 "dotencode"
1216 "dotencode"
1177
1217
1178 "usefncache"
1218 "usefncache"
1179
1219
1180 "usestore"
1220 "usestore"
1181
1221
1182 "profiling"
1222 "profiling"
1183 -----------
1223 -----------
1184
1224
1185 "format"
1225 "format"
1186
1226
1187 "progress"
1227 "progress"
1188 ----------
1228 ----------
1189
1229
1190 "format"
1230 "format"
1191
1231
1192
1232
1193 Last item in help config.*:
1233 Last item in help config.*:
1194
1234
1195 $ hg help config.`hg help config|grep '^ "'| \
1235 $ hg help config.`hg help config|grep '^ "'| \
1196 > tail -1|sed 's![ "]*!!g'`| \
1236 > tail -1|sed 's![ "]*!!g'`| \
1197 > grep "hg help -c config" > /dev/null
1237 > grep "hg help -c config" > /dev/null
1198 [1]
1238 [1]
1199
1239
1200 note to use help -c for general hg help config:
1240 note to use help -c for general hg help config:
1201
1241
1202 $ hg help config |grep "hg help -c config" > /dev/null
1242 $ hg help config |grep "hg help -c config" > /dev/null
1203
1243
1204 Test templating help
1244 Test templating help
1205
1245
1206 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1246 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
1207 desc String. The text of the changeset description.
1247 desc String. The text of the changeset description.
1208 diffstat String. Statistics of changes with the following format:
1248 diffstat String. Statistics of changes with the following format:
1209 firstline Any text. Returns the first line of text.
1249 firstline Any text. Returns the first line of text.
1210 nonempty Any text. Returns '(none)' if the string is empty.
1250 nonempty Any text. Returns '(none)' if the string is empty.
1211
1251
1212 Test deprecated items
1252 Test deprecated items
1213
1253
1214 $ hg help -v templating | grep currentbookmark
1254 $ hg help -v templating | grep currentbookmark
1215 currentbookmark
1255 currentbookmark
1216 $ hg help templating | (grep currentbookmark || true)
1256 $ hg help templating | (grep currentbookmark || true)
1217
1257
1218 Test help hooks
1258 Test help hooks
1219
1259
1220 $ cat > helphook1.py <<EOF
1260 $ cat > helphook1.py <<EOF
1221 > from mercurial import help
1261 > from mercurial import help
1222 >
1262 >
1223 > def rewrite(ui, topic, doc):
1263 > def rewrite(ui, topic, doc):
1224 > return doc + '\nhelphook1\n'
1264 > return doc + '\nhelphook1\n'
1225 >
1265 >
1226 > def extsetup(ui):
1266 > def extsetup(ui):
1227 > help.addtopichook('revsets', rewrite)
1267 > help.addtopichook('revsets', rewrite)
1228 > EOF
1268 > EOF
1229 $ cat > helphook2.py <<EOF
1269 $ cat > helphook2.py <<EOF
1230 > from mercurial import help
1270 > from mercurial import help
1231 >
1271 >
1232 > def rewrite(ui, topic, doc):
1272 > def rewrite(ui, topic, doc):
1233 > return doc + '\nhelphook2\n'
1273 > return doc + '\nhelphook2\n'
1234 >
1274 >
1235 > def extsetup(ui):
1275 > def extsetup(ui):
1236 > help.addtopichook('revsets', rewrite)
1276 > help.addtopichook('revsets', rewrite)
1237 > EOF
1277 > EOF
1238 $ echo '[extensions]' >> $HGRCPATH
1278 $ echo '[extensions]' >> $HGRCPATH
1239 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1279 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1240 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1280 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1241 $ hg help revsets | grep helphook
1281 $ hg help revsets | grep helphook
1242 helphook1
1282 helphook1
1243 helphook2
1283 helphook2
1244
1284
1245 help -c should only show debug --debug
1285 help -c should only show debug --debug
1246
1286
1247 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1287 $ hg help -c --debug|egrep debug|wc -l|egrep '^\s*0\s*$'
1248 [1]
1288 [1]
1249
1289
1250 help -c should only show deprecated for -v
1290 help -c should only show deprecated for -v
1251
1291
1252 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1292 $ hg help -c -v|egrep DEPRECATED|wc -l|egrep '^\s*0\s*$'
1253 [1]
1293 [1]
1254
1294
1255 Test -s / --system
1295 Test -s / --system
1256
1296
1257 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1297 $ hg help config.files -s windows |grep 'etc/mercurial' | \
1258 > wc -l | sed -e 's/ //g'
1298 > wc -l | sed -e 's/ //g'
1259 0
1299 0
1260 $ hg help config.files --system unix | grep 'USER' | \
1300 $ hg help config.files --system unix | grep 'USER' | \
1261 > wc -l | sed -e 's/ //g'
1301 > wc -l | sed -e 's/ //g'
1262 0
1302 0
1263
1303
1264 Test -e / -c / -k combinations
1304 Test -e / -c / -k combinations
1265
1305
1266 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1306 $ hg help -c|egrep '^[A-Z].*:|^ debug'
1267 Commands:
1307 Commands:
1268 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1308 $ hg help -e|egrep '^[A-Z].*:|^ debug'
1269 Extensions:
1309 Extensions:
1270 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1310 $ hg help -k|egrep '^[A-Z].*:|^ debug'
1271 Topics:
1311 Topics:
1272 Commands:
1312 Commands:
1273 Extensions:
1313 Extensions:
1274 Extension Commands:
1314 Extension Commands:
1275 $ hg help -c schemes
1315 $ hg help -c schemes
1276 abort: no such help topic: schemes
1316 abort: no such help topic: schemes
1277 (try "hg help --keyword schemes")
1317 (try "hg help --keyword schemes")
1278 [255]
1318 [255]
1279 $ hg help -e schemes |head -1
1319 $ hg help -e schemes |head -1
1280 schemes extension - extend schemes with shortcuts to repository swarms
1320 schemes extension - extend schemes with shortcuts to repository swarms
1281 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1321 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1282 Commands:
1322 Commands:
1283 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1323 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1284 Extensions:
1324 Extensions:
1285 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1325 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1286 Extensions:
1326 Extensions:
1287 Commands:
1327 Commands:
1288 $ hg help -c commit > /dev/null
1328 $ hg help -c commit > /dev/null
1289 $ hg help -e -c commit > /dev/null
1329 $ hg help -e -c commit > /dev/null
1290 $ hg help -e commit > /dev/null
1330 $ hg help -e commit > /dev/null
1291 abort: no such help topic: commit
1331 abort: no such help topic: commit
1292 (try "hg help --keyword commit")
1332 (try "hg help --keyword commit")
1293 [255]
1333 [255]
1294
1334
1295 Test keyword search help
1335 Test keyword search help
1296
1336
1297 $ cat > prefixedname.py <<EOF
1337 $ cat > prefixedname.py <<EOF
1298 > '''matched against word "clone"
1338 > '''matched against word "clone"
1299 > '''
1339 > '''
1300 > EOF
1340 > EOF
1301 $ echo '[extensions]' >> $HGRCPATH
1341 $ echo '[extensions]' >> $HGRCPATH
1302 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1342 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1303 $ hg help -k clone
1343 $ hg help -k clone
1304 Topics:
1344 Topics:
1305
1345
1306 config Configuration Files
1346 config Configuration Files
1307 extensions Using Additional Features
1347 extensions Using Additional Features
1308 glossary Glossary
1348 glossary Glossary
1309 phases Working with Phases
1349 phases Working with Phases
1310 subrepos Subrepositories
1350 subrepos Subrepositories
1311 urls URL Paths
1351 urls URL Paths
1312
1352
1313 Commands:
1353 Commands:
1314
1354
1315 bookmarks create a new bookmark or list existing bookmarks
1355 bookmarks create a new bookmark or list existing bookmarks
1316 clone make a copy of an existing repository
1356 clone make a copy of an existing repository
1317 paths show aliases for remote repositories
1357 paths show aliases for remote repositories
1318 update update working directory (or switch revisions)
1358 update update working directory (or switch revisions)
1319
1359
1320 Extensions:
1360 Extensions:
1321
1361
1322 clonebundles advertise pre-generated bundles to seed clones
1362 clonebundles advertise pre-generated bundles to seed clones
1323 prefixedname matched against word "clone"
1363 prefixedname matched against word "clone"
1324 relink recreates hardlinks between repository clones
1364 relink recreates hardlinks between repository clones
1325
1365
1326 Extension Commands:
1366 Extension Commands:
1327
1367
1328 qclone clone main and patch repository at same time
1368 qclone clone main and patch repository at same time
1329
1369
1330 Test unfound topic
1370 Test unfound topic
1331
1371
1332 $ hg help nonexistingtopicthatwillneverexisteverever
1372 $ hg help nonexistingtopicthatwillneverexisteverever
1333 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1373 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1334 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
1374 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
1335 [255]
1375 [255]
1336
1376
1337 Test unfound keyword
1377 Test unfound keyword
1338
1378
1339 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1379 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1340 abort: no matches
1380 abort: no matches
1341 (try "hg help" for a list of topics)
1381 (try "hg help" for a list of topics)
1342 [255]
1382 [255]
1343
1383
1344 Test omit indicating for help
1384 Test omit indicating for help
1345
1385
1346 $ cat > addverboseitems.py <<EOF
1386 $ cat > addverboseitems.py <<EOF
1347 > '''extension to test omit indicating.
1387 > '''extension to test omit indicating.
1348 >
1388 >
1349 > This paragraph is never omitted (for extension)
1389 > This paragraph is never omitted (for extension)
1350 >
1390 >
1351 > .. container:: verbose
1391 > .. container:: verbose
1352 >
1392 >
1353 > This paragraph is omitted,
1393 > This paragraph is omitted,
1354 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1394 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1355 >
1395 >
1356 > This paragraph is never omitted, too (for extension)
1396 > This paragraph is never omitted, too (for extension)
1357 > '''
1397 > '''
1358 >
1398 >
1359 > from mercurial import help, commands
1399 > from mercurial import help, commands
1360 > testtopic = """This paragraph is never omitted (for topic).
1400 > testtopic = """This paragraph is never omitted (for topic).
1361 >
1401 >
1362 > .. container:: verbose
1402 > .. container:: verbose
1363 >
1403 >
1364 > This paragraph is omitted,
1404 > This paragraph is omitted,
1365 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1405 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1366 >
1406 >
1367 > This paragraph is never omitted, too (for topic)
1407 > This paragraph is never omitted, too (for topic)
1368 > """
1408 > """
1369 > def extsetup(ui):
1409 > def extsetup(ui):
1370 > help.helptable.append((["topic-containing-verbose"],
1410 > help.helptable.append((["topic-containing-verbose"],
1371 > "This is the topic to test omit indicating.",
1411 > "This is the topic to test omit indicating.",
1372 > lambda ui: testtopic))
1412 > lambda ui: testtopic))
1373 > EOF
1413 > EOF
1374 $ echo '[extensions]' >> $HGRCPATH
1414 $ echo '[extensions]' >> $HGRCPATH
1375 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1415 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1376 $ hg help addverboseitems
1416 $ hg help addverboseitems
1377 addverboseitems extension - extension to test omit indicating.
1417 addverboseitems extension - extension to test omit indicating.
1378
1418
1379 This paragraph is never omitted (for extension)
1419 This paragraph is never omitted (for extension)
1380
1420
1381 This paragraph is never omitted, too (for extension)
1421 This paragraph is never omitted, too (for extension)
1382
1422
1383 (some details hidden, use --verbose to show complete help)
1423 (some details hidden, use --verbose to show complete help)
1384
1424
1385 no commands defined
1425 no commands defined
1386 $ hg help -v addverboseitems
1426 $ hg help -v addverboseitems
1387 addverboseitems extension - extension to test omit indicating.
1427 addverboseitems extension - extension to test omit indicating.
1388
1428
1389 This paragraph is never omitted (for extension)
1429 This paragraph is never omitted (for extension)
1390
1430
1391 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1431 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1392 extension)
1432 extension)
1393
1433
1394 This paragraph is never omitted, too (for extension)
1434 This paragraph is never omitted, too (for extension)
1395
1435
1396 no commands defined
1436 no commands defined
1397 $ hg help topic-containing-verbose
1437 $ hg help topic-containing-verbose
1398 This is the topic to test omit indicating.
1438 This is the topic to test omit indicating.
1399 """"""""""""""""""""""""""""""""""""""""""
1439 """"""""""""""""""""""""""""""""""""""""""
1400
1440
1401 This paragraph is never omitted (for topic).
1441 This paragraph is never omitted (for topic).
1402
1442
1403 This paragraph is never omitted, too (for topic)
1443 This paragraph is never omitted, too (for topic)
1404
1444
1405 (some details hidden, use --verbose to show complete help)
1445 (some details hidden, use --verbose to show complete help)
1406 $ hg help -v topic-containing-verbose
1446 $ hg help -v topic-containing-verbose
1407 This is the topic to test omit indicating.
1447 This is the topic to test omit indicating.
1408 """"""""""""""""""""""""""""""""""""""""""
1448 """"""""""""""""""""""""""""""""""""""""""
1409
1449
1410 This paragraph is never omitted (for topic).
1450 This paragraph is never omitted (for topic).
1411
1451
1412 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1452 This paragraph is omitted, if 'hg help' is invoked without "-v" (for
1413 topic)
1453 topic)
1414
1454
1415 This paragraph is never omitted, too (for topic)
1455 This paragraph is never omitted, too (for topic)
1416
1456
1417 Test section lookup
1457 Test section lookup
1418
1458
1419 $ hg help revset.merge
1459 $ hg help revset.merge
1420 "merge()"
1460 "merge()"
1421 Changeset is a merge changeset.
1461 Changeset is a merge changeset.
1422
1462
1423 $ hg help glossary.dag
1463 $ hg help glossary.dag
1424 DAG
1464 DAG
1425 The repository of changesets of a distributed version control system
1465 The repository of changesets of a distributed version control system
1426 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1466 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1427 of nodes and edges, where nodes correspond to changesets and edges
1467 of nodes and edges, where nodes correspond to changesets and edges
1428 imply a parent -> child relation. This graph can be visualized by
1468 imply a parent -> child relation. This graph can be visualized by
1429 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1469 graphical tools such as 'hg log --graph'. In Mercurial, the DAG is
1430 limited by the requirement for children to have at most two parents.
1470 limited by the requirement for children to have at most two parents.
1431
1471
1432
1472
1433 $ hg help hgrc.paths
1473 $ hg help hgrc.paths
1434 "paths"
1474 "paths"
1435 -------
1475 -------
1436
1476
1437 Assigns symbolic names and behavior to repositories.
1477 Assigns symbolic names and behavior to repositories.
1438
1478
1439 Options are symbolic names defining the URL or directory that is the
1479 Options are symbolic names defining the URL or directory that is the
1440 location of the repository. Example:
1480 location of the repository. Example:
1441
1481
1442 [paths]
1482 [paths]
1443 my_server = https://example.com/my_repo
1483 my_server = https://example.com/my_repo
1444 local_path = /home/me/repo
1484 local_path = /home/me/repo
1445
1485
1446 These symbolic names can be used from the command line. To pull from
1486 These symbolic names can be used from the command line. To pull from
1447 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1487 "my_server": 'hg pull my_server'. To push to "local_path": 'hg push
1448 local_path'.
1488 local_path'.
1449
1489
1450 Options containing colons (":") denote sub-options that can influence
1490 Options containing colons (":") denote sub-options that can influence
1451 behavior for that specific path. Example:
1491 behavior for that specific path. Example:
1452
1492
1453 [paths]
1493 [paths]
1454 my_server = https://example.com/my_path
1494 my_server = https://example.com/my_path
1455 my_server:pushurl = ssh://example.com/my_path
1495 my_server:pushurl = ssh://example.com/my_path
1456
1496
1457 The following sub-options can be defined:
1497 The following sub-options can be defined:
1458
1498
1459 "pushurl"
1499 "pushurl"
1460 The URL to use for push operations. If not defined, the location
1500 The URL to use for push operations. If not defined, the location
1461 defined by the path's main entry is used.
1501 defined by the path's main entry is used.
1462
1502
1463 The following special named paths exist:
1503 The following special named paths exist:
1464
1504
1465 "default"
1505 "default"
1466 The URL or directory to use when no source or remote is specified.
1506 The URL or directory to use when no source or remote is specified.
1467
1507
1468 'hg clone' will automatically define this path to the location the
1508 'hg clone' will automatically define this path to the location the
1469 repository was cloned from.
1509 repository was cloned from.
1470
1510
1471 "default-push"
1511 "default-push"
1472 (deprecated) The URL or directory for the default 'hg push' location.
1512 (deprecated) The URL or directory for the default 'hg push' location.
1473 "default:pushurl" should be used instead.
1513 "default:pushurl" should be used instead.
1474
1514
1475 $ hg help glossary.mcguffin
1515 $ hg help glossary.mcguffin
1476 abort: help section not found
1516 abort: help section not found
1477 [255]
1517 [255]
1478
1518
1479 $ hg help glossary.mc.guffin
1519 $ hg help glossary.mc.guffin
1480 abort: help section not found
1520 abort: help section not found
1481 [255]
1521 [255]
1482
1522
1483 $ hg help template.files
1523 $ hg help template.files
1484 files List of strings. All files modified, added, or removed by
1524 files List of strings. All files modified, added, or removed by
1485 this changeset.
1525 this changeset.
1486
1526
1487 Test dynamic list of merge tools only shows up once
1527 Test dynamic list of merge tools only shows up once
1488 $ hg help merge-tools
1528 $ hg help merge-tools
1489 Merge Tools
1529 Merge Tools
1490 """""""""""
1530 """""""""""
1491
1531
1492 To merge files Mercurial uses merge tools.
1532 To merge files Mercurial uses merge tools.
1493
1533
1494 A merge tool combines two different versions of a file into a merged file.
1534 A merge tool combines two different versions of a file into a merged file.
1495 Merge tools are given the two files and the greatest common ancestor of
1535 Merge tools are given the two files and the greatest common ancestor of
1496 the two file versions, so they can determine the changes made on both
1536 the two file versions, so they can determine the changes made on both
1497 branches.
1537 branches.
1498
1538
1499 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1539 Merge tools are used both for 'hg resolve', 'hg merge', 'hg update', 'hg
1500 backout' and in several extensions.
1540 backout' and in several extensions.
1501
1541
1502 Usually, the merge tool tries to automatically reconcile the files by
1542 Usually, the merge tool tries to automatically reconcile the files by
1503 combining all non-overlapping changes that occurred separately in the two
1543 combining all non-overlapping changes that occurred separately in the two
1504 different evolutions of the same initial base file. Furthermore, some
1544 different evolutions of the same initial base file. Furthermore, some
1505 interactive merge programs make it easier to manually resolve conflicting
1545 interactive merge programs make it easier to manually resolve conflicting
1506 merges, either in a graphical way, or by inserting some conflict markers.
1546 merges, either in a graphical way, or by inserting some conflict markers.
1507 Mercurial does not include any interactive merge programs but relies on
1547 Mercurial does not include any interactive merge programs but relies on
1508 external tools for that.
1548 external tools for that.
1509
1549
1510 Available merge tools
1550 Available merge tools
1511 =====================
1551 =====================
1512
1552
1513 External merge tools and their properties are configured in the merge-
1553 External merge tools and their properties are configured in the merge-
1514 tools configuration section - see hgrc(5) - but they can often just be
1554 tools configuration section - see hgrc(5) - but they can often just be
1515 named by their executable.
1555 named by their executable.
1516
1556
1517 A merge tool is generally usable if its executable can be found on the
1557 A merge tool is generally usable if its executable can be found on the
1518 system and if it can handle the merge. The executable is found if it is an
1558 system and if it can handle the merge. The executable is found if it is an
1519 absolute or relative executable path or the name of an application in the
1559 absolute or relative executable path or the name of an application in the
1520 executable search path. The tool is assumed to be able to handle the merge
1560 executable search path. The tool is assumed to be able to handle the merge
1521 if it can handle symlinks if the file is a symlink, if it can handle
1561 if it can handle symlinks if the file is a symlink, if it can handle
1522 binary files if the file is binary, and if a GUI is available if the tool
1562 binary files if the file is binary, and if a GUI is available if the tool
1523 requires a GUI.
1563 requires a GUI.
1524
1564
1525 There are some internal merge tools which can be used. The internal merge
1565 There are some internal merge tools which can be used. The internal merge
1526 tools are:
1566 tools are:
1527
1567
1528 ":dump"
1568 ":dump"
1529 Creates three versions of the files to merge, containing the contents of
1569 Creates three versions of the files to merge, containing the contents of
1530 local, other and base. These files can then be used to perform a merge
1570 local, other and base. These files can then be used to perform a merge
1531 manually. If the file to be merged is named "a.txt", these files will
1571 manually. If the file to be merged is named "a.txt", these files will
1532 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1572 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1533 they will be placed in the same directory as "a.txt".
1573 they will be placed in the same directory as "a.txt".
1534
1574
1535 ":fail"
1575 ":fail"
1536 Rather than attempting to merge files that were modified on both
1576 Rather than attempting to merge files that were modified on both
1537 branches, it marks them as unresolved. The resolve command must be used
1577 branches, it marks them as unresolved. The resolve command must be used
1538 to resolve these conflicts.
1578 to resolve these conflicts.
1539
1579
1540 ":local"
1580 ":local"
1541 Uses the local 'p1()' version of files as the merged version.
1581 Uses the local 'p1()' version of files as the merged version.
1542
1582
1543 ":merge"
1583 ":merge"
1544 Uses the internal non-interactive simple merge algorithm for merging
1584 Uses the internal non-interactive simple merge algorithm for merging
1545 files. It will fail if there are any conflicts and leave markers in the
1585 files. It will fail if there are any conflicts and leave markers in the
1546 partially merged file. Markers will have two sections, one for each side
1586 partially merged file. Markers will have two sections, one for each side
1547 of merge.
1587 of merge.
1548
1588
1549 ":merge-local"
1589 ":merge-local"
1550 Like :merge, but resolve all conflicts non-interactively in favor of the
1590 Like :merge, but resolve all conflicts non-interactively in favor of the
1551 local 'p1()' changes.
1591 local 'p1()' changes.
1552
1592
1553 ":merge-other"
1593 ":merge-other"
1554 Like :merge, but resolve all conflicts non-interactively in favor of the
1594 Like :merge, but resolve all conflicts non-interactively in favor of the
1555 other 'p2()' changes.
1595 other 'p2()' changes.
1556
1596
1557 ":merge3"
1597 ":merge3"
1558 Uses the internal non-interactive simple merge algorithm for merging
1598 Uses the internal non-interactive simple merge algorithm for merging
1559 files. It will fail if there are any conflicts and leave markers in the
1599 files. It will fail if there are any conflicts and leave markers in the
1560 partially merged file. Marker will have three sections, one from each
1600 partially merged file. Marker will have three sections, one from each
1561 side of the merge and one for the base content.
1601 side of the merge and one for the base content.
1562
1602
1563 ":other"
1603 ":other"
1564 Uses the other 'p2()' version of files as the merged version.
1604 Uses the other 'p2()' version of files as the merged version.
1565
1605
1566 ":prompt"
1606 ":prompt"
1567 Asks the user which of the local 'p1()' or the other 'p2()' version to
1607 Asks the user which of the local 'p1()' or the other 'p2()' version to
1568 keep as the merged version.
1608 keep as the merged version.
1569
1609
1570 ":tagmerge"
1610 ":tagmerge"
1571 Uses the internal tag merge algorithm (experimental).
1611 Uses the internal tag merge algorithm (experimental).
1572
1612
1573 ":union"
1613 ":union"
1574 Uses the internal non-interactive simple merge algorithm for merging
1614 Uses the internal non-interactive simple merge algorithm for merging
1575 files. It will use both left and right sides for conflict regions. No
1615 files. It will use both left and right sides for conflict regions. No
1576 markers are inserted.
1616 markers are inserted.
1577
1617
1578 Internal tools are always available and do not require a GUI but will by
1618 Internal tools are always available and do not require a GUI but will by
1579 default not handle symlinks or binary files.
1619 default not handle symlinks or binary files.
1580
1620
1581 Choosing a merge tool
1621 Choosing a merge tool
1582 =====================
1622 =====================
1583
1623
1584 Mercurial uses these rules when deciding which merge tool to use:
1624 Mercurial uses these rules when deciding which merge tool to use:
1585
1625
1586 1. If a tool has been specified with the --tool option to merge or
1626 1. If a tool has been specified with the --tool option to merge or
1587 resolve, it is used. If it is the name of a tool in the merge-tools
1627 resolve, it is used. If it is the name of a tool in the merge-tools
1588 configuration, its configuration is used. Otherwise the specified tool
1628 configuration, its configuration is used. Otherwise the specified tool
1589 must be executable by the shell.
1629 must be executable by the shell.
1590 2. If the "HGMERGE" environment variable is present, its value is used and
1630 2. If the "HGMERGE" environment variable is present, its value is used and
1591 must be executable by the shell.
1631 must be executable by the shell.
1592 3. If the filename of the file to be merged matches any of the patterns in
1632 3. If the filename of the file to be merged matches any of the patterns in
1593 the merge-patterns configuration section, the first usable merge tool
1633 the merge-patterns configuration section, the first usable merge tool
1594 corresponding to a matching pattern is used. Here, binary capabilities
1634 corresponding to a matching pattern is used. Here, binary capabilities
1595 of the merge tool are not considered.
1635 of the merge tool are not considered.
1596 4. If ui.merge is set it will be considered next. If the value is not the
1636 4. If ui.merge is set it will be considered next. If the value is not the
1597 name of a configured tool, the specified value is used and must be
1637 name of a configured tool, the specified value is used and must be
1598 executable by the shell. Otherwise the named tool is used if it is
1638 executable by the shell. Otherwise the named tool is used if it is
1599 usable.
1639 usable.
1600 5. If any usable merge tools are present in the merge-tools configuration
1640 5. If any usable merge tools are present in the merge-tools configuration
1601 section, the one with the highest priority is used.
1641 section, the one with the highest priority is used.
1602 6. If a program named "hgmerge" can be found on the system, it is used -
1642 6. If a program named "hgmerge" can be found on the system, it is used -
1603 but it will by default not be used for symlinks and binary files.
1643 but it will by default not be used for symlinks and binary files.
1604 7. If the file to be merged is not binary and is not a symlink, then
1644 7. If the file to be merged is not binary and is not a symlink, then
1605 internal ":merge" is used.
1645 internal ":merge" is used.
1606 8. The merge of the file fails and must be resolved before commit.
1646 8. The merge of the file fails and must be resolved before commit.
1607
1647
1608 Note:
1648 Note:
1609 After selecting a merge program, Mercurial will by default attempt to
1649 After selecting a merge program, Mercurial will by default attempt to
1610 merge the files using a simple merge algorithm first. Only if it
1650 merge the files using a simple merge algorithm first. Only if it
1611 doesn't succeed because of conflicting changes Mercurial will actually
1651 doesn't succeed because of conflicting changes Mercurial will actually
1612 execute the merge program. Whether to use the simple merge algorithm
1652 execute the merge program. Whether to use the simple merge algorithm
1613 first can be controlled by the premerge setting of the merge tool.
1653 first can be controlled by the premerge setting of the merge tool.
1614 Premerge is enabled by default unless the file is binary or a symlink.
1654 Premerge is enabled by default unless the file is binary or a symlink.
1615
1655
1616 See the merge-tools and ui sections of hgrc(5) for details on the
1656 See the merge-tools and ui sections of hgrc(5) for details on the
1617 configuration of merge tools.
1657 configuration of merge tools.
1618
1658
1619 Test usage of section marks in help documents
1659 Test usage of section marks in help documents
1620
1660
1621 $ cd "$TESTDIR"/../doc
1661 $ cd "$TESTDIR"/../doc
1622 $ python check-seclevel.py
1662 $ python check-seclevel.py
1623 $ cd $TESTTMP
1663 $ cd $TESTTMP
1624
1664
1625 #if serve
1665 #if serve
1626
1666
1627 Test the help pages in hgweb.
1667 Test the help pages in hgweb.
1628
1668
1629 Dish up an empty repo; serve it cold.
1669 Dish up an empty repo; serve it cold.
1630
1670
1631 $ hg init "$TESTTMP/test"
1671 $ hg init "$TESTTMP/test"
1632 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1672 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1633 $ cat hg.pid >> $DAEMON_PIDS
1673 $ cat hg.pid >> $DAEMON_PIDS
1634
1674
1635 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1675 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1636 200 Script output follows
1676 200 Script output follows
1637
1677
1638 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1678 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1639 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1679 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1640 <head>
1680 <head>
1641 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1681 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1642 <meta name="robots" content="index, nofollow" />
1682 <meta name="robots" content="index, nofollow" />
1643 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1683 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1644 <script type="text/javascript" src="/static/mercurial.js"></script>
1684 <script type="text/javascript" src="/static/mercurial.js"></script>
1645
1685
1646 <title>Help: Index</title>
1686 <title>Help: Index</title>
1647 </head>
1687 </head>
1648 <body>
1688 <body>
1649
1689
1650 <div class="container">
1690 <div class="container">
1651 <div class="menu">
1691 <div class="menu">
1652 <div class="logo">
1692 <div class="logo">
1653 <a href="https://mercurial-scm.org/">
1693 <a href="https://mercurial-scm.org/">
1654 <img src="/static/hglogo.png" alt="mercurial" /></a>
1694 <img src="/static/hglogo.png" alt="mercurial" /></a>
1655 </div>
1695 </div>
1656 <ul>
1696 <ul>
1657 <li><a href="/shortlog">log</a></li>
1697 <li><a href="/shortlog">log</a></li>
1658 <li><a href="/graph">graph</a></li>
1698 <li><a href="/graph">graph</a></li>
1659 <li><a href="/tags">tags</a></li>
1699 <li><a href="/tags">tags</a></li>
1660 <li><a href="/bookmarks">bookmarks</a></li>
1700 <li><a href="/bookmarks">bookmarks</a></li>
1661 <li><a href="/branches">branches</a></li>
1701 <li><a href="/branches">branches</a></li>
1662 </ul>
1702 </ul>
1663 <ul>
1703 <ul>
1664 <li class="active">help</li>
1704 <li class="active">help</li>
1665 </ul>
1705 </ul>
1666 </div>
1706 </div>
1667
1707
1668 <div class="main">
1708 <div class="main">
1669 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1709 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1670 <form class="search" action="/log">
1710 <form class="search" action="/log">
1671
1711
1672 <p><input name="rev" id="search1" type="text" size="30" /></p>
1712 <p><input name="rev" id="search1" type="text" size="30" /></p>
1673 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1713 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1674 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1714 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1675 </form>
1715 </form>
1676 <table class="bigtable">
1716 <table class="bigtable">
1677 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1717 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1678
1718
1679 <tr><td>
1719 <tr><td>
1680 <a href="/help/config">
1720 <a href="/help/config">
1681 config
1721 config
1682 </a>
1722 </a>
1683 </td><td>
1723 </td><td>
1684 Configuration Files
1724 Configuration Files
1685 </td></tr>
1725 </td></tr>
1686 <tr><td>
1726 <tr><td>
1687 <a href="/help/dates">
1727 <a href="/help/dates">
1688 dates
1728 dates
1689 </a>
1729 </a>
1690 </td><td>
1730 </td><td>
1691 Date Formats
1731 Date Formats
1692 </td></tr>
1732 </td></tr>
1693 <tr><td>
1733 <tr><td>
1694 <a href="/help/diffs">
1734 <a href="/help/diffs">
1695 diffs
1735 diffs
1696 </a>
1736 </a>
1697 </td><td>
1737 </td><td>
1698 Diff Formats
1738 Diff Formats
1699 </td></tr>
1739 </td></tr>
1700 <tr><td>
1740 <tr><td>
1701 <a href="/help/environment">
1741 <a href="/help/environment">
1702 environment
1742 environment
1703 </a>
1743 </a>
1704 </td><td>
1744 </td><td>
1705 Environment Variables
1745 Environment Variables
1706 </td></tr>
1746 </td></tr>
1707 <tr><td>
1747 <tr><td>
1708 <a href="/help/extensions">
1748 <a href="/help/extensions">
1709 extensions
1749 extensions
1710 </a>
1750 </a>
1711 </td><td>
1751 </td><td>
1712 Using Additional Features
1752 Using Additional Features
1713 </td></tr>
1753 </td></tr>
1714 <tr><td>
1754 <tr><td>
1715 <a href="/help/filesets">
1755 <a href="/help/filesets">
1716 filesets
1756 filesets
1717 </a>
1757 </a>
1718 </td><td>
1758 </td><td>
1719 Specifying File Sets
1759 Specifying File Sets
1720 </td></tr>
1760 </td></tr>
1721 <tr><td>
1761 <tr><td>
1722 <a href="/help/glossary">
1762 <a href="/help/glossary">
1723 glossary
1763 glossary
1724 </a>
1764 </a>
1725 </td><td>
1765 </td><td>
1726 Glossary
1766 Glossary
1727 </td></tr>
1767 </td></tr>
1728 <tr><td>
1768 <tr><td>
1729 <a href="/help/hgignore">
1769 <a href="/help/hgignore">
1730 hgignore
1770 hgignore
1731 </a>
1771 </a>
1732 </td><td>
1772 </td><td>
1733 Syntax for Mercurial Ignore Files
1773 Syntax for Mercurial Ignore Files
1734 </td></tr>
1774 </td></tr>
1735 <tr><td>
1775 <tr><td>
1736 <a href="/help/hgweb">
1776 <a href="/help/hgweb">
1737 hgweb
1777 hgweb
1738 </a>
1778 </a>
1739 </td><td>
1779 </td><td>
1740 Configuring hgweb
1780 Configuring hgweb
1741 </td></tr>
1781 </td></tr>
1742 <tr><td>
1782 <tr><td>
1743 <a href="/help/internals">
1783 <a href="/help/internals">
1744 internals
1784 internals
1745 </a>
1785 </a>
1746 </td><td>
1786 </td><td>
1747 Technical implementation topics
1787 Technical implementation topics
1748 </td></tr>
1788 </td></tr>
1749 <tr><td>
1789 <tr><td>
1750 <a href="/help/merge-tools">
1790 <a href="/help/merge-tools">
1751 merge-tools
1791 merge-tools
1752 </a>
1792 </a>
1753 </td><td>
1793 </td><td>
1754 Merge Tools
1794 Merge Tools
1755 </td></tr>
1795 </td></tr>
1756 <tr><td>
1796 <tr><td>
1757 <a href="/help/multirevs">
1797 <a href="/help/multirevs">
1758 multirevs
1798 multirevs
1759 </a>
1799 </a>
1760 </td><td>
1800 </td><td>
1761 Specifying Multiple Revisions
1801 Specifying Multiple Revisions
1762 </td></tr>
1802 </td></tr>
1763 <tr><td>
1803 <tr><td>
1764 <a href="/help/patterns">
1804 <a href="/help/patterns">
1765 patterns
1805 patterns
1766 </a>
1806 </a>
1767 </td><td>
1807 </td><td>
1768 File Name Patterns
1808 File Name Patterns
1769 </td></tr>
1809 </td></tr>
1770 <tr><td>
1810 <tr><td>
1771 <a href="/help/phases">
1811 <a href="/help/phases">
1772 phases
1812 phases
1773 </a>
1813 </a>
1774 </td><td>
1814 </td><td>
1775 Working with Phases
1815 Working with Phases
1776 </td></tr>
1816 </td></tr>
1777 <tr><td>
1817 <tr><td>
1778 <a href="/help/revisions">
1818 <a href="/help/revisions">
1779 revisions
1819 revisions
1780 </a>
1820 </a>
1781 </td><td>
1821 </td><td>
1782 Specifying Single Revisions
1822 Specifying Single Revisions
1783 </td></tr>
1823 </td></tr>
1784 <tr><td>
1824 <tr><td>
1785 <a href="/help/revsets">
1825 <a href="/help/revsets">
1786 revsets
1826 revsets
1787 </a>
1827 </a>
1788 </td><td>
1828 </td><td>
1789 Specifying Revision Sets
1829 Specifying Revision Sets
1790 </td></tr>
1830 </td></tr>
1791 <tr><td>
1831 <tr><td>
1792 <a href="/help/scripting">
1832 <a href="/help/scripting">
1793 scripting
1833 scripting
1794 </a>
1834 </a>
1795 </td><td>
1835 </td><td>
1796 Using Mercurial from scripts and automation
1836 Using Mercurial from scripts and automation
1797 </td></tr>
1837 </td></tr>
1798 <tr><td>
1838 <tr><td>
1799 <a href="/help/subrepos">
1839 <a href="/help/subrepos">
1800 subrepos
1840 subrepos
1801 </a>
1841 </a>
1802 </td><td>
1842 </td><td>
1803 Subrepositories
1843 Subrepositories
1804 </td></tr>
1844 </td></tr>
1805 <tr><td>
1845 <tr><td>
1806 <a href="/help/templating">
1846 <a href="/help/templating">
1807 templating
1847 templating
1808 </a>
1848 </a>
1809 </td><td>
1849 </td><td>
1810 Template Usage
1850 Template Usage
1811 </td></tr>
1851 </td></tr>
1812 <tr><td>
1852 <tr><td>
1813 <a href="/help/urls">
1853 <a href="/help/urls">
1814 urls
1854 urls
1815 </a>
1855 </a>
1816 </td><td>
1856 </td><td>
1817 URL Paths
1857 URL Paths
1818 </td></tr>
1858 </td></tr>
1819 <tr><td>
1859 <tr><td>
1820 <a href="/help/topic-containing-verbose">
1860 <a href="/help/topic-containing-verbose">
1821 topic-containing-verbose
1861 topic-containing-verbose
1822 </a>
1862 </a>
1823 </td><td>
1863 </td><td>
1824 This is the topic to test omit indicating.
1864 This is the topic to test omit indicating.
1825 </td></tr>
1865 </td></tr>
1826
1866
1827
1867
1828 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1868 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1829
1869
1830 <tr><td>
1870 <tr><td>
1831 <a href="/help/add">
1871 <a href="/help/add">
1832 add
1872 add
1833 </a>
1873 </a>
1834 </td><td>
1874 </td><td>
1835 add the specified files on the next commit
1875 add the specified files on the next commit
1836 </td></tr>
1876 </td></tr>
1837 <tr><td>
1877 <tr><td>
1838 <a href="/help/annotate">
1878 <a href="/help/annotate">
1839 annotate
1879 annotate
1840 </a>
1880 </a>
1841 </td><td>
1881 </td><td>
1842 show changeset information by line for each file
1882 show changeset information by line for each file
1843 </td></tr>
1883 </td></tr>
1844 <tr><td>
1884 <tr><td>
1845 <a href="/help/clone">
1885 <a href="/help/clone">
1846 clone
1886 clone
1847 </a>
1887 </a>
1848 </td><td>
1888 </td><td>
1849 make a copy of an existing repository
1889 make a copy of an existing repository
1850 </td></tr>
1890 </td></tr>
1851 <tr><td>
1891 <tr><td>
1852 <a href="/help/commit">
1892 <a href="/help/commit">
1853 commit
1893 commit
1854 </a>
1894 </a>
1855 </td><td>
1895 </td><td>
1856 commit the specified files or all outstanding changes
1896 commit the specified files or all outstanding changes
1857 </td></tr>
1897 </td></tr>
1858 <tr><td>
1898 <tr><td>
1859 <a href="/help/diff">
1899 <a href="/help/diff">
1860 diff
1900 diff
1861 </a>
1901 </a>
1862 </td><td>
1902 </td><td>
1863 diff repository (or selected files)
1903 diff repository (or selected files)
1864 </td></tr>
1904 </td></tr>
1865 <tr><td>
1905 <tr><td>
1866 <a href="/help/export">
1906 <a href="/help/export">
1867 export
1907 export
1868 </a>
1908 </a>
1869 </td><td>
1909 </td><td>
1870 dump the header and diffs for one or more changesets
1910 dump the header and diffs for one or more changesets
1871 </td></tr>
1911 </td></tr>
1872 <tr><td>
1912 <tr><td>
1873 <a href="/help/forget">
1913 <a href="/help/forget">
1874 forget
1914 forget
1875 </a>
1915 </a>
1876 </td><td>
1916 </td><td>
1877 forget the specified files on the next commit
1917 forget the specified files on the next commit
1878 </td></tr>
1918 </td></tr>
1879 <tr><td>
1919 <tr><td>
1880 <a href="/help/init">
1920 <a href="/help/init">
1881 init
1921 init
1882 </a>
1922 </a>
1883 </td><td>
1923 </td><td>
1884 create a new repository in the given directory
1924 create a new repository in the given directory
1885 </td></tr>
1925 </td></tr>
1886 <tr><td>
1926 <tr><td>
1887 <a href="/help/log">
1927 <a href="/help/log">
1888 log
1928 log
1889 </a>
1929 </a>
1890 </td><td>
1930 </td><td>
1891 show revision history of entire repository or files
1931 show revision history of entire repository or files
1892 </td></tr>
1932 </td></tr>
1893 <tr><td>
1933 <tr><td>
1894 <a href="/help/merge">
1934 <a href="/help/merge">
1895 merge
1935 merge
1896 </a>
1936 </a>
1897 </td><td>
1937 </td><td>
1898 merge another revision into working directory
1938 merge another revision into working directory
1899 </td></tr>
1939 </td></tr>
1900 <tr><td>
1940 <tr><td>
1901 <a href="/help/pull">
1941 <a href="/help/pull">
1902 pull
1942 pull
1903 </a>
1943 </a>
1904 </td><td>
1944 </td><td>
1905 pull changes from the specified source
1945 pull changes from the specified source
1906 </td></tr>
1946 </td></tr>
1907 <tr><td>
1947 <tr><td>
1908 <a href="/help/push">
1948 <a href="/help/push">
1909 push
1949 push
1910 </a>
1950 </a>
1911 </td><td>
1951 </td><td>
1912 push changes to the specified destination
1952 push changes to the specified destination
1913 </td></tr>
1953 </td></tr>
1914 <tr><td>
1954 <tr><td>
1915 <a href="/help/remove">
1955 <a href="/help/remove">
1916 remove
1956 remove
1917 </a>
1957 </a>
1918 </td><td>
1958 </td><td>
1919 remove the specified files on the next commit
1959 remove the specified files on the next commit
1920 </td></tr>
1960 </td></tr>
1921 <tr><td>
1961 <tr><td>
1922 <a href="/help/serve">
1962 <a href="/help/serve">
1923 serve
1963 serve
1924 </a>
1964 </a>
1925 </td><td>
1965 </td><td>
1926 start stand-alone webserver
1966 start stand-alone webserver
1927 </td></tr>
1967 </td></tr>
1928 <tr><td>
1968 <tr><td>
1929 <a href="/help/status">
1969 <a href="/help/status">
1930 status
1970 status
1931 </a>
1971 </a>
1932 </td><td>
1972 </td><td>
1933 show changed files in the working directory
1973 show changed files in the working directory
1934 </td></tr>
1974 </td></tr>
1935 <tr><td>
1975 <tr><td>
1936 <a href="/help/summary">
1976 <a href="/help/summary">
1937 summary
1977 summary
1938 </a>
1978 </a>
1939 </td><td>
1979 </td><td>
1940 summarize working directory state
1980 summarize working directory state
1941 </td></tr>
1981 </td></tr>
1942 <tr><td>
1982 <tr><td>
1943 <a href="/help/update">
1983 <a href="/help/update">
1944 update
1984 update
1945 </a>
1985 </a>
1946 </td><td>
1986 </td><td>
1947 update working directory (or switch revisions)
1987 update working directory (or switch revisions)
1948 </td></tr>
1988 </td></tr>
1949
1989
1950
1990
1951
1991
1952 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1992 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1953
1993
1954 <tr><td>
1994 <tr><td>
1955 <a href="/help/addremove">
1995 <a href="/help/addremove">
1956 addremove
1996 addremove
1957 </a>
1997 </a>
1958 </td><td>
1998 </td><td>
1959 add all new files, delete all missing files
1999 add all new files, delete all missing files
1960 </td></tr>
2000 </td></tr>
1961 <tr><td>
2001 <tr><td>
1962 <a href="/help/archive">
2002 <a href="/help/archive">
1963 archive
2003 archive
1964 </a>
2004 </a>
1965 </td><td>
2005 </td><td>
1966 create an unversioned archive of a repository revision
2006 create an unversioned archive of a repository revision
1967 </td></tr>
2007 </td></tr>
1968 <tr><td>
2008 <tr><td>
1969 <a href="/help/backout">
2009 <a href="/help/backout">
1970 backout
2010 backout
1971 </a>
2011 </a>
1972 </td><td>
2012 </td><td>
1973 reverse effect of earlier changeset
2013 reverse effect of earlier changeset
1974 </td></tr>
2014 </td></tr>
1975 <tr><td>
2015 <tr><td>
1976 <a href="/help/bisect">
2016 <a href="/help/bisect">
1977 bisect
2017 bisect
1978 </a>
2018 </a>
1979 </td><td>
2019 </td><td>
1980 subdivision search of changesets
2020 subdivision search of changesets
1981 </td></tr>
2021 </td></tr>
1982 <tr><td>
2022 <tr><td>
1983 <a href="/help/bookmarks">
2023 <a href="/help/bookmarks">
1984 bookmarks
2024 bookmarks
1985 </a>
2025 </a>
1986 </td><td>
2026 </td><td>
1987 create a new bookmark or list existing bookmarks
2027 create a new bookmark or list existing bookmarks
1988 </td></tr>
2028 </td></tr>
1989 <tr><td>
2029 <tr><td>
1990 <a href="/help/branch">
2030 <a href="/help/branch">
1991 branch
2031 branch
1992 </a>
2032 </a>
1993 </td><td>
2033 </td><td>
1994 set or show the current branch name
2034 set or show the current branch name
1995 </td></tr>
2035 </td></tr>
1996 <tr><td>
2036 <tr><td>
1997 <a href="/help/branches">
2037 <a href="/help/branches">
1998 branches
2038 branches
1999 </a>
2039 </a>
2000 </td><td>
2040 </td><td>
2001 list repository named branches
2041 list repository named branches
2002 </td></tr>
2042 </td></tr>
2003 <tr><td>
2043 <tr><td>
2004 <a href="/help/bundle">
2044 <a href="/help/bundle">
2005 bundle
2045 bundle
2006 </a>
2046 </a>
2007 </td><td>
2047 </td><td>
2008 create a changegroup file
2048 create a changegroup file
2009 </td></tr>
2049 </td></tr>
2010 <tr><td>
2050 <tr><td>
2011 <a href="/help/cat">
2051 <a href="/help/cat">
2012 cat
2052 cat
2013 </a>
2053 </a>
2014 </td><td>
2054 </td><td>
2015 output the current or given revision of files
2055 output the current or given revision of files
2016 </td></tr>
2056 </td></tr>
2017 <tr><td>
2057 <tr><td>
2018 <a href="/help/config">
2058 <a href="/help/config">
2019 config
2059 config
2020 </a>
2060 </a>
2021 </td><td>
2061 </td><td>
2022 show combined config settings from all hgrc files
2062 show combined config settings from all hgrc files
2023 </td></tr>
2063 </td></tr>
2024 <tr><td>
2064 <tr><td>
2025 <a href="/help/copy">
2065 <a href="/help/copy">
2026 copy
2066 copy
2027 </a>
2067 </a>
2028 </td><td>
2068 </td><td>
2029 mark files as copied for the next commit
2069 mark files as copied for the next commit
2030 </td></tr>
2070 </td></tr>
2031 <tr><td>
2071 <tr><td>
2032 <a href="/help/files">
2072 <a href="/help/files">
2033 files
2073 files
2034 </a>
2074 </a>
2035 </td><td>
2075 </td><td>
2036 list tracked files
2076 list tracked files
2037 </td></tr>
2077 </td></tr>
2038 <tr><td>
2078 <tr><td>
2039 <a href="/help/graft">
2079 <a href="/help/graft">
2040 graft
2080 graft
2041 </a>
2081 </a>
2042 </td><td>
2082 </td><td>
2043 copy changes from other branches onto the current branch
2083 copy changes from other branches onto the current branch
2044 </td></tr>
2084 </td></tr>
2045 <tr><td>
2085 <tr><td>
2046 <a href="/help/grep">
2086 <a href="/help/grep">
2047 grep
2087 grep
2048 </a>
2088 </a>
2049 </td><td>
2089 </td><td>
2050 search for a pattern in specified files and revisions
2090 search for a pattern in specified files and revisions
2051 </td></tr>
2091 </td></tr>
2052 <tr><td>
2092 <tr><td>
2053 <a href="/help/heads">
2093 <a href="/help/heads">
2054 heads
2094 heads
2055 </a>
2095 </a>
2056 </td><td>
2096 </td><td>
2057 show branch heads
2097 show branch heads
2058 </td></tr>
2098 </td></tr>
2059 <tr><td>
2099 <tr><td>
2060 <a href="/help/help">
2100 <a href="/help/help">
2061 help
2101 help
2062 </a>
2102 </a>
2063 </td><td>
2103 </td><td>
2064 show help for a given topic or a help overview
2104 show help for a given topic or a help overview
2065 </td></tr>
2105 </td></tr>
2066 <tr><td>
2106 <tr><td>
2107 <a href="/help/hgalias">
2108 hgalias
2109 </a>
2110 </td><td>
2111 summarize working directory state
2112 </td></tr>
2113 <tr><td>
2067 <a href="/help/identify">
2114 <a href="/help/identify">
2068 identify
2115 identify
2069 </a>
2116 </a>
2070 </td><td>
2117 </td><td>
2071 identify the working directory or specified revision
2118 identify the working directory or specified revision
2072 </td></tr>
2119 </td></tr>
2073 <tr><td>
2120 <tr><td>
2074 <a href="/help/import">
2121 <a href="/help/import">
2075 import
2122 import
2076 </a>
2123 </a>
2077 </td><td>
2124 </td><td>
2078 import an ordered set of patches
2125 import an ordered set of patches
2079 </td></tr>
2126 </td></tr>
2080 <tr><td>
2127 <tr><td>
2081 <a href="/help/incoming">
2128 <a href="/help/incoming">
2082 incoming
2129 incoming
2083 </a>
2130 </a>
2084 </td><td>
2131 </td><td>
2085 show new changesets found in source
2132 show new changesets found in source
2086 </td></tr>
2133 </td></tr>
2087 <tr><td>
2134 <tr><td>
2088 <a href="/help/manifest">
2135 <a href="/help/manifest">
2089 manifest
2136 manifest
2090 </a>
2137 </a>
2091 </td><td>
2138 </td><td>
2092 output the current or given revision of the project manifest
2139 output the current or given revision of the project manifest
2093 </td></tr>
2140 </td></tr>
2094 <tr><td>
2141 <tr><td>
2095 <a href="/help/nohelp">
2142 <a href="/help/nohelp">
2096 nohelp
2143 nohelp
2097 </a>
2144 </a>
2098 </td><td>
2145 </td><td>
2099 (no help text available)
2146 (no help text available)
2100 </td></tr>
2147 </td></tr>
2101 <tr><td>
2148 <tr><td>
2102 <a href="/help/outgoing">
2149 <a href="/help/outgoing">
2103 outgoing
2150 outgoing
2104 </a>
2151 </a>
2105 </td><td>
2152 </td><td>
2106 show changesets not found in the destination
2153 show changesets not found in the destination
2107 </td></tr>
2154 </td></tr>
2108 <tr><td>
2155 <tr><td>
2109 <a href="/help/paths">
2156 <a href="/help/paths">
2110 paths
2157 paths
2111 </a>
2158 </a>
2112 </td><td>
2159 </td><td>
2113 show aliases for remote repositories
2160 show aliases for remote repositories
2114 </td></tr>
2161 </td></tr>
2115 <tr><td>
2162 <tr><td>
2116 <a href="/help/phase">
2163 <a href="/help/phase">
2117 phase
2164 phase
2118 </a>
2165 </a>
2119 </td><td>
2166 </td><td>
2120 set or show the current phase name
2167 set or show the current phase name
2121 </td></tr>
2168 </td></tr>
2122 <tr><td>
2169 <tr><td>
2123 <a href="/help/recover">
2170 <a href="/help/recover">
2124 recover
2171 recover
2125 </a>
2172 </a>
2126 </td><td>
2173 </td><td>
2127 roll back an interrupted transaction
2174 roll back an interrupted transaction
2128 </td></tr>
2175 </td></tr>
2129 <tr><td>
2176 <tr><td>
2130 <a href="/help/rename">
2177 <a href="/help/rename">
2131 rename
2178 rename
2132 </a>
2179 </a>
2133 </td><td>
2180 </td><td>
2134 rename files; equivalent of copy + remove
2181 rename files; equivalent of copy + remove
2135 </td></tr>
2182 </td></tr>
2136 <tr><td>
2183 <tr><td>
2137 <a href="/help/resolve">
2184 <a href="/help/resolve">
2138 resolve
2185 resolve
2139 </a>
2186 </a>
2140 </td><td>
2187 </td><td>
2141 redo merges or set/view the merge status of files
2188 redo merges or set/view the merge status of files
2142 </td></tr>
2189 </td></tr>
2143 <tr><td>
2190 <tr><td>
2144 <a href="/help/revert">
2191 <a href="/help/revert">
2145 revert
2192 revert
2146 </a>
2193 </a>
2147 </td><td>
2194 </td><td>
2148 restore files to their checkout state
2195 restore files to their checkout state
2149 </td></tr>
2196 </td></tr>
2150 <tr><td>
2197 <tr><td>
2151 <a href="/help/root">
2198 <a href="/help/root">
2152 root
2199 root
2153 </a>
2200 </a>
2154 </td><td>
2201 </td><td>
2155 print the root (top) of the current working directory
2202 print the root (top) of the current working directory
2156 </td></tr>
2203 </td></tr>
2157 <tr><td>
2204 <tr><td>
2205 <a href="/help/shellalias">
2206 shellalias
2207 </a>
2208 </td><td>
2209 (no help text available)
2210 </td></tr>
2211 <tr><td>
2158 <a href="/help/tag">
2212 <a href="/help/tag">
2159 tag
2213 tag
2160 </a>
2214 </a>
2161 </td><td>
2215 </td><td>
2162 add one or more tags for the current or given revision
2216 add one or more tags for the current or given revision
2163 </td></tr>
2217 </td></tr>
2164 <tr><td>
2218 <tr><td>
2165 <a href="/help/tags">
2219 <a href="/help/tags">
2166 tags
2220 tags
2167 </a>
2221 </a>
2168 </td><td>
2222 </td><td>
2169 list repository tags
2223 list repository tags
2170 </td></tr>
2224 </td></tr>
2171 <tr><td>
2225 <tr><td>
2172 <a href="/help/unbundle">
2226 <a href="/help/unbundle">
2173 unbundle
2227 unbundle
2174 </a>
2228 </a>
2175 </td><td>
2229 </td><td>
2176 apply one or more changegroup files
2230 apply one or more changegroup files
2177 </td></tr>
2231 </td></tr>
2178 <tr><td>
2232 <tr><td>
2179 <a href="/help/verify">
2233 <a href="/help/verify">
2180 verify
2234 verify
2181 </a>
2235 </a>
2182 </td><td>
2236 </td><td>
2183 verify the integrity of the repository
2237 verify the integrity of the repository
2184 </td></tr>
2238 </td></tr>
2185 <tr><td>
2239 <tr><td>
2186 <a href="/help/version">
2240 <a href="/help/version">
2187 version
2241 version
2188 </a>
2242 </a>
2189 </td><td>
2243 </td><td>
2190 output version and copyright information
2244 output version and copyright information
2191 </td></tr>
2245 </td></tr>
2192
2246
2193
2247
2194 </table>
2248 </table>
2195 </div>
2249 </div>
2196 </div>
2250 </div>
2197
2251
2198 <script type="text/javascript">process_dates()</script>
2252 <script type="text/javascript">process_dates()</script>
2199
2253
2200
2254
2201 </body>
2255 </body>
2202 </html>
2256 </html>
2203
2257
2204
2258
2205 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
2259 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
2206 200 Script output follows
2260 200 Script output follows
2207
2261
2208 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2262 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2209 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2263 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2210 <head>
2264 <head>
2211 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2265 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2212 <meta name="robots" content="index, nofollow" />
2266 <meta name="robots" content="index, nofollow" />
2213 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2267 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2214 <script type="text/javascript" src="/static/mercurial.js"></script>
2268 <script type="text/javascript" src="/static/mercurial.js"></script>
2215
2269
2216 <title>Help: add</title>
2270 <title>Help: add</title>
2217 </head>
2271 </head>
2218 <body>
2272 <body>
2219
2273
2220 <div class="container">
2274 <div class="container">
2221 <div class="menu">
2275 <div class="menu">
2222 <div class="logo">
2276 <div class="logo">
2223 <a href="https://mercurial-scm.org/">
2277 <a href="https://mercurial-scm.org/">
2224 <img src="/static/hglogo.png" alt="mercurial" /></a>
2278 <img src="/static/hglogo.png" alt="mercurial" /></a>
2225 </div>
2279 </div>
2226 <ul>
2280 <ul>
2227 <li><a href="/shortlog">log</a></li>
2281 <li><a href="/shortlog">log</a></li>
2228 <li><a href="/graph">graph</a></li>
2282 <li><a href="/graph">graph</a></li>
2229 <li><a href="/tags">tags</a></li>
2283 <li><a href="/tags">tags</a></li>
2230 <li><a href="/bookmarks">bookmarks</a></li>
2284 <li><a href="/bookmarks">bookmarks</a></li>
2231 <li><a href="/branches">branches</a></li>
2285 <li><a href="/branches">branches</a></li>
2232 </ul>
2286 </ul>
2233 <ul>
2287 <ul>
2234 <li class="active"><a href="/help">help</a></li>
2288 <li class="active"><a href="/help">help</a></li>
2235 </ul>
2289 </ul>
2236 </div>
2290 </div>
2237
2291
2238 <div class="main">
2292 <div class="main">
2239 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2293 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2240 <h3>Help: add</h3>
2294 <h3>Help: add</h3>
2241
2295
2242 <form class="search" action="/log">
2296 <form class="search" action="/log">
2243
2297
2244 <p><input name="rev" id="search1" type="text" size="30" /></p>
2298 <p><input name="rev" id="search1" type="text" size="30" /></p>
2245 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2299 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2246 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2300 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2247 </form>
2301 </form>
2248 <div id="doc">
2302 <div id="doc">
2249 <p>
2303 <p>
2250 hg add [OPTION]... [FILE]...
2304 hg add [OPTION]... [FILE]...
2251 </p>
2305 </p>
2252 <p>
2306 <p>
2253 add the specified files on the next commit
2307 add the specified files on the next commit
2254 </p>
2308 </p>
2255 <p>
2309 <p>
2256 Schedule files to be version controlled and added to the
2310 Schedule files to be version controlled and added to the
2257 repository.
2311 repository.
2258 </p>
2312 </p>
2259 <p>
2313 <p>
2260 The files will be added to the repository at the next commit. To
2314 The files will be added to the repository at the next commit. To
2261 undo an add before that, see 'hg forget'.
2315 undo an add before that, see 'hg forget'.
2262 </p>
2316 </p>
2263 <p>
2317 <p>
2264 If no names are given, add all files to the repository (except
2318 If no names are given, add all files to the repository (except
2265 files matching &quot;.hgignore&quot;).
2319 files matching &quot;.hgignore&quot;).
2266 </p>
2320 </p>
2267 <p>
2321 <p>
2268 Examples:
2322 Examples:
2269 </p>
2323 </p>
2270 <ul>
2324 <ul>
2271 <li> New (unknown) files are added automatically by 'hg add':
2325 <li> New (unknown) files are added automatically by 'hg add':
2272 <pre>
2326 <pre>
2273 \$ ls (re)
2327 \$ ls (re)
2274 foo.c
2328 foo.c
2275 \$ hg status (re)
2329 \$ hg status (re)
2276 ? foo.c
2330 ? foo.c
2277 \$ hg add (re)
2331 \$ hg add (re)
2278 adding foo.c
2332 adding foo.c
2279 \$ hg status (re)
2333 \$ hg status (re)
2280 A foo.c
2334 A foo.c
2281 </pre>
2335 </pre>
2282 <li> Specific files to be added can be specified:
2336 <li> Specific files to be added can be specified:
2283 <pre>
2337 <pre>
2284 \$ ls (re)
2338 \$ ls (re)
2285 bar.c foo.c
2339 bar.c foo.c
2286 \$ hg status (re)
2340 \$ hg status (re)
2287 ? bar.c
2341 ? bar.c
2288 ? foo.c
2342 ? foo.c
2289 \$ hg add bar.c (re)
2343 \$ hg add bar.c (re)
2290 \$ hg status (re)
2344 \$ hg status (re)
2291 A bar.c
2345 A bar.c
2292 ? foo.c
2346 ? foo.c
2293 </pre>
2347 </pre>
2294 </ul>
2348 </ul>
2295 <p>
2349 <p>
2296 Returns 0 if all files are successfully added.
2350 Returns 0 if all files are successfully added.
2297 </p>
2351 </p>
2298 <p>
2352 <p>
2299 options ([+] can be repeated):
2353 options ([+] can be repeated):
2300 </p>
2354 </p>
2301 <table>
2355 <table>
2302 <tr><td>-I</td>
2356 <tr><td>-I</td>
2303 <td>--include PATTERN [+]</td>
2357 <td>--include PATTERN [+]</td>
2304 <td>include names matching the given patterns</td></tr>
2358 <td>include names matching the given patterns</td></tr>
2305 <tr><td>-X</td>
2359 <tr><td>-X</td>
2306 <td>--exclude PATTERN [+]</td>
2360 <td>--exclude PATTERN [+]</td>
2307 <td>exclude names matching the given patterns</td></tr>
2361 <td>exclude names matching the given patterns</td></tr>
2308 <tr><td>-S</td>
2362 <tr><td>-S</td>
2309 <td>--subrepos</td>
2363 <td>--subrepos</td>
2310 <td>recurse into subrepositories</td></tr>
2364 <td>recurse into subrepositories</td></tr>
2311 <tr><td>-n</td>
2365 <tr><td>-n</td>
2312 <td>--dry-run</td>
2366 <td>--dry-run</td>
2313 <td>do not perform actions, just print output</td></tr>
2367 <td>do not perform actions, just print output</td></tr>
2314 </table>
2368 </table>
2315 <p>
2369 <p>
2316 global options ([+] can be repeated):
2370 global options ([+] can be repeated):
2317 </p>
2371 </p>
2318 <table>
2372 <table>
2319 <tr><td>-R</td>
2373 <tr><td>-R</td>
2320 <td>--repository REPO</td>
2374 <td>--repository REPO</td>
2321 <td>repository root directory or name of overlay bundle file</td></tr>
2375 <td>repository root directory or name of overlay bundle file</td></tr>
2322 <tr><td></td>
2376 <tr><td></td>
2323 <td>--cwd DIR</td>
2377 <td>--cwd DIR</td>
2324 <td>change working directory</td></tr>
2378 <td>change working directory</td></tr>
2325 <tr><td>-y</td>
2379 <tr><td>-y</td>
2326 <td>--noninteractive</td>
2380 <td>--noninteractive</td>
2327 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2381 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2328 <tr><td>-q</td>
2382 <tr><td>-q</td>
2329 <td>--quiet</td>
2383 <td>--quiet</td>
2330 <td>suppress output</td></tr>
2384 <td>suppress output</td></tr>
2331 <tr><td>-v</td>
2385 <tr><td>-v</td>
2332 <td>--verbose</td>
2386 <td>--verbose</td>
2333 <td>enable additional output</td></tr>
2387 <td>enable additional output</td></tr>
2334 <tr><td></td>
2388 <tr><td></td>
2335 <td>--config CONFIG [+]</td>
2389 <td>--config CONFIG [+]</td>
2336 <td>set/override config option (use 'section.name=value')</td></tr>
2390 <td>set/override config option (use 'section.name=value')</td></tr>
2337 <tr><td></td>
2391 <tr><td></td>
2338 <td>--debug</td>
2392 <td>--debug</td>
2339 <td>enable debugging output</td></tr>
2393 <td>enable debugging output</td></tr>
2340 <tr><td></td>
2394 <tr><td></td>
2341 <td>--debugger</td>
2395 <td>--debugger</td>
2342 <td>start debugger</td></tr>
2396 <td>start debugger</td></tr>
2343 <tr><td></td>
2397 <tr><td></td>
2344 <td>--encoding ENCODE</td>
2398 <td>--encoding ENCODE</td>
2345 <td>set the charset encoding (default: ascii)</td></tr>
2399 <td>set the charset encoding (default: ascii)</td></tr>
2346 <tr><td></td>
2400 <tr><td></td>
2347 <td>--encodingmode MODE</td>
2401 <td>--encodingmode MODE</td>
2348 <td>set the charset encoding mode (default: strict)</td></tr>
2402 <td>set the charset encoding mode (default: strict)</td></tr>
2349 <tr><td></td>
2403 <tr><td></td>
2350 <td>--traceback</td>
2404 <td>--traceback</td>
2351 <td>always print a traceback on exception</td></tr>
2405 <td>always print a traceback on exception</td></tr>
2352 <tr><td></td>
2406 <tr><td></td>
2353 <td>--time</td>
2407 <td>--time</td>
2354 <td>time how long the command takes</td></tr>
2408 <td>time how long the command takes</td></tr>
2355 <tr><td></td>
2409 <tr><td></td>
2356 <td>--profile</td>
2410 <td>--profile</td>
2357 <td>print command execution profile</td></tr>
2411 <td>print command execution profile</td></tr>
2358 <tr><td></td>
2412 <tr><td></td>
2359 <td>--version</td>
2413 <td>--version</td>
2360 <td>output version information and exit</td></tr>
2414 <td>output version information and exit</td></tr>
2361 <tr><td>-h</td>
2415 <tr><td>-h</td>
2362 <td>--help</td>
2416 <td>--help</td>
2363 <td>display help and exit</td></tr>
2417 <td>display help and exit</td></tr>
2364 <tr><td></td>
2418 <tr><td></td>
2365 <td>--hidden</td>
2419 <td>--hidden</td>
2366 <td>consider hidden changesets</td></tr>
2420 <td>consider hidden changesets</td></tr>
2367 </table>
2421 </table>
2368
2422
2369 </div>
2423 </div>
2370 </div>
2424 </div>
2371 </div>
2425 </div>
2372
2426
2373 <script type="text/javascript">process_dates()</script>
2427 <script type="text/javascript">process_dates()</script>
2374
2428
2375
2429
2376 </body>
2430 </body>
2377 </html>
2431 </html>
2378
2432
2379
2433
2380 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
2434 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
2381 200 Script output follows
2435 200 Script output follows
2382
2436
2383 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2437 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2384 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2438 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2385 <head>
2439 <head>
2386 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2440 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2387 <meta name="robots" content="index, nofollow" />
2441 <meta name="robots" content="index, nofollow" />
2388 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2442 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2389 <script type="text/javascript" src="/static/mercurial.js"></script>
2443 <script type="text/javascript" src="/static/mercurial.js"></script>
2390
2444
2391 <title>Help: remove</title>
2445 <title>Help: remove</title>
2392 </head>
2446 </head>
2393 <body>
2447 <body>
2394
2448
2395 <div class="container">
2449 <div class="container">
2396 <div class="menu">
2450 <div class="menu">
2397 <div class="logo">
2451 <div class="logo">
2398 <a href="https://mercurial-scm.org/">
2452 <a href="https://mercurial-scm.org/">
2399 <img src="/static/hglogo.png" alt="mercurial" /></a>
2453 <img src="/static/hglogo.png" alt="mercurial" /></a>
2400 </div>
2454 </div>
2401 <ul>
2455 <ul>
2402 <li><a href="/shortlog">log</a></li>
2456 <li><a href="/shortlog">log</a></li>
2403 <li><a href="/graph">graph</a></li>
2457 <li><a href="/graph">graph</a></li>
2404 <li><a href="/tags">tags</a></li>
2458 <li><a href="/tags">tags</a></li>
2405 <li><a href="/bookmarks">bookmarks</a></li>
2459 <li><a href="/bookmarks">bookmarks</a></li>
2406 <li><a href="/branches">branches</a></li>
2460 <li><a href="/branches">branches</a></li>
2407 </ul>
2461 </ul>
2408 <ul>
2462 <ul>
2409 <li class="active"><a href="/help">help</a></li>
2463 <li class="active"><a href="/help">help</a></li>
2410 </ul>
2464 </ul>
2411 </div>
2465 </div>
2412
2466
2413 <div class="main">
2467 <div class="main">
2414 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2468 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2415 <h3>Help: remove</h3>
2469 <h3>Help: remove</h3>
2416
2470
2417 <form class="search" action="/log">
2471 <form class="search" action="/log">
2418
2472
2419 <p><input name="rev" id="search1" type="text" size="30" /></p>
2473 <p><input name="rev" id="search1" type="text" size="30" /></p>
2420 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2474 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2421 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2475 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2422 </form>
2476 </form>
2423 <div id="doc">
2477 <div id="doc">
2424 <p>
2478 <p>
2425 hg remove [OPTION]... FILE...
2479 hg remove [OPTION]... FILE...
2426 </p>
2480 </p>
2427 <p>
2481 <p>
2428 aliases: rm
2482 aliases: rm
2429 </p>
2483 </p>
2430 <p>
2484 <p>
2431 remove the specified files on the next commit
2485 remove the specified files on the next commit
2432 </p>
2486 </p>
2433 <p>
2487 <p>
2434 Schedule the indicated files for removal from the current branch.
2488 Schedule the indicated files for removal from the current branch.
2435 </p>
2489 </p>
2436 <p>
2490 <p>
2437 This command schedules the files to be removed at the next commit.
2491 This command schedules the files to be removed at the next commit.
2438 To undo a remove before that, see 'hg revert'. To undo added
2492 To undo a remove before that, see 'hg revert'. To undo added
2439 files, see 'hg forget'.
2493 files, see 'hg forget'.
2440 </p>
2494 </p>
2441 <p>
2495 <p>
2442 -A/--after can be used to remove only files that have already
2496 -A/--after can be used to remove only files that have already
2443 been deleted, -f/--force can be used to force deletion, and -Af
2497 been deleted, -f/--force can be used to force deletion, and -Af
2444 can be used to remove files from the next revision without
2498 can be used to remove files from the next revision without
2445 deleting them from the working directory.
2499 deleting them from the working directory.
2446 </p>
2500 </p>
2447 <p>
2501 <p>
2448 The following table details the behavior of remove for different
2502 The following table details the behavior of remove for different
2449 file states (columns) and option combinations (rows). The file
2503 file states (columns) and option combinations (rows). The file
2450 states are Added [A], Clean [C], Modified [M] and Missing [!]
2504 states are Added [A], Clean [C], Modified [M] and Missing [!]
2451 (as reported by 'hg status'). The actions are Warn, Remove
2505 (as reported by 'hg status'). The actions are Warn, Remove
2452 (from branch) and Delete (from disk):
2506 (from branch) and Delete (from disk):
2453 </p>
2507 </p>
2454 <table>
2508 <table>
2455 <tr><td>opt/state</td>
2509 <tr><td>opt/state</td>
2456 <td>A</td>
2510 <td>A</td>
2457 <td>C</td>
2511 <td>C</td>
2458 <td>M</td>
2512 <td>M</td>
2459 <td>!</td></tr>
2513 <td>!</td></tr>
2460 <tr><td>none</td>
2514 <tr><td>none</td>
2461 <td>W</td>
2515 <td>W</td>
2462 <td>RD</td>
2516 <td>RD</td>
2463 <td>W</td>
2517 <td>W</td>
2464 <td>R</td></tr>
2518 <td>R</td></tr>
2465 <tr><td>-f</td>
2519 <tr><td>-f</td>
2466 <td>R</td>
2520 <td>R</td>
2467 <td>RD</td>
2521 <td>RD</td>
2468 <td>RD</td>
2522 <td>RD</td>
2469 <td>R</td></tr>
2523 <td>R</td></tr>
2470 <tr><td>-A</td>
2524 <tr><td>-A</td>
2471 <td>W</td>
2525 <td>W</td>
2472 <td>W</td>
2526 <td>W</td>
2473 <td>W</td>
2527 <td>W</td>
2474 <td>R</td></tr>
2528 <td>R</td></tr>
2475 <tr><td>-Af</td>
2529 <tr><td>-Af</td>
2476 <td>R</td>
2530 <td>R</td>
2477 <td>R</td>
2531 <td>R</td>
2478 <td>R</td>
2532 <td>R</td>
2479 <td>R</td></tr>
2533 <td>R</td></tr>
2480 </table>
2534 </table>
2481 <p>
2535 <p>
2482 <b>Note:</b>
2536 <b>Note:</b>
2483 </p>
2537 </p>
2484 <p>
2538 <p>
2485 'hg remove' never deletes files in Added [A] state from the
2539 'hg remove' never deletes files in Added [A] state from the
2486 working directory, not even if &quot;--force&quot; is specified.
2540 working directory, not even if &quot;--force&quot; is specified.
2487 </p>
2541 </p>
2488 <p>
2542 <p>
2489 Returns 0 on success, 1 if any warnings encountered.
2543 Returns 0 on success, 1 if any warnings encountered.
2490 </p>
2544 </p>
2491 <p>
2545 <p>
2492 options ([+] can be repeated):
2546 options ([+] can be repeated):
2493 </p>
2547 </p>
2494 <table>
2548 <table>
2495 <tr><td>-A</td>
2549 <tr><td>-A</td>
2496 <td>--after</td>
2550 <td>--after</td>
2497 <td>record delete for missing files</td></tr>
2551 <td>record delete for missing files</td></tr>
2498 <tr><td>-f</td>
2552 <tr><td>-f</td>
2499 <td>--force</td>
2553 <td>--force</td>
2500 <td>remove (and delete) file even if added or modified</td></tr>
2554 <td>remove (and delete) file even if added or modified</td></tr>
2501 <tr><td>-S</td>
2555 <tr><td>-S</td>
2502 <td>--subrepos</td>
2556 <td>--subrepos</td>
2503 <td>recurse into subrepositories</td></tr>
2557 <td>recurse into subrepositories</td></tr>
2504 <tr><td>-I</td>
2558 <tr><td>-I</td>
2505 <td>--include PATTERN [+]</td>
2559 <td>--include PATTERN [+]</td>
2506 <td>include names matching the given patterns</td></tr>
2560 <td>include names matching the given patterns</td></tr>
2507 <tr><td>-X</td>
2561 <tr><td>-X</td>
2508 <td>--exclude PATTERN [+]</td>
2562 <td>--exclude PATTERN [+]</td>
2509 <td>exclude names matching the given patterns</td></tr>
2563 <td>exclude names matching the given patterns</td></tr>
2510 </table>
2564 </table>
2511 <p>
2565 <p>
2512 global options ([+] can be repeated):
2566 global options ([+] can be repeated):
2513 </p>
2567 </p>
2514 <table>
2568 <table>
2515 <tr><td>-R</td>
2569 <tr><td>-R</td>
2516 <td>--repository REPO</td>
2570 <td>--repository REPO</td>
2517 <td>repository root directory or name of overlay bundle file</td></tr>
2571 <td>repository root directory or name of overlay bundle file</td></tr>
2518 <tr><td></td>
2572 <tr><td></td>
2519 <td>--cwd DIR</td>
2573 <td>--cwd DIR</td>
2520 <td>change working directory</td></tr>
2574 <td>change working directory</td></tr>
2521 <tr><td>-y</td>
2575 <tr><td>-y</td>
2522 <td>--noninteractive</td>
2576 <td>--noninteractive</td>
2523 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2577 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2524 <tr><td>-q</td>
2578 <tr><td>-q</td>
2525 <td>--quiet</td>
2579 <td>--quiet</td>
2526 <td>suppress output</td></tr>
2580 <td>suppress output</td></tr>
2527 <tr><td>-v</td>
2581 <tr><td>-v</td>
2528 <td>--verbose</td>
2582 <td>--verbose</td>
2529 <td>enable additional output</td></tr>
2583 <td>enable additional output</td></tr>
2530 <tr><td></td>
2584 <tr><td></td>
2531 <td>--config CONFIG [+]</td>
2585 <td>--config CONFIG [+]</td>
2532 <td>set/override config option (use 'section.name=value')</td></tr>
2586 <td>set/override config option (use 'section.name=value')</td></tr>
2533 <tr><td></td>
2587 <tr><td></td>
2534 <td>--debug</td>
2588 <td>--debug</td>
2535 <td>enable debugging output</td></tr>
2589 <td>enable debugging output</td></tr>
2536 <tr><td></td>
2590 <tr><td></td>
2537 <td>--debugger</td>
2591 <td>--debugger</td>
2538 <td>start debugger</td></tr>
2592 <td>start debugger</td></tr>
2539 <tr><td></td>
2593 <tr><td></td>
2540 <td>--encoding ENCODE</td>
2594 <td>--encoding ENCODE</td>
2541 <td>set the charset encoding (default: ascii)</td></tr>
2595 <td>set the charset encoding (default: ascii)</td></tr>
2542 <tr><td></td>
2596 <tr><td></td>
2543 <td>--encodingmode MODE</td>
2597 <td>--encodingmode MODE</td>
2544 <td>set the charset encoding mode (default: strict)</td></tr>
2598 <td>set the charset encoding mode (default: strict)</td></tr>
2545 <tr><td></td>
2599 <tr><td></td>
2546 <td>--traceback</td>
2600 <td>--traceback</td>
2547 <td>always print a traceback on exception</td></tr>
2601 <td>always print a traceback on exception</td></tr>
2548 <tr><td></td>
2602 <tr><td></td>
2549 <td>--time</td>
2603 <td>--time</td>
2550 <td>time how long the command takes</td></tr>
2604 <td>time how long the command takes</td></tr>
2551 <tr><td></td>
2605 <tr><td></td>
2552 <td>--profile</td>
2606 <td>--profile</td>
2553 <td>print command execution profile</td></tr>
2607 <td>print command execution profile</td></tr>
2554 <tr><td></td>
2608 <tr><td></td>
2555 <td>--version</td>
2609 <td>--version</td>
2556 <td>output version information and exit</td></tr>
2610 <td>output version information and exit</td></tr>
2557 <tr><td>-h</td>
2611 <tr><td>-h</td>
2558 <td>--help</td>
2612 <td>--help</td>
2559 <td>display help and exit</td></tr>
2613 <td>display help and exit</td></tr>
2560 <tr><td></td>
2614 <tr><td></td>
2561 <td>--hidden</td>
2615 <td>--hidden</td>
2562 <td>consider hidden changesets</td></tr>
2616 <td>consider hidden changesets</td></tr>
2563 </table>
2617 </table>
2564
2618
2565 </div>
2619 </div>
2566 </div>
2620 </div>
2567 </div>
2621 </div>
2568
2622
2569 <script type="text/javascript">process_dates()</script>
2623 <script type="text/javascript">process_dates()</script>
2570
2624
2571
2625
2572 </body>
2626 </body>
2573 </html>
2627 </html>
2574
2628
2575
2629
2576 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2630 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2577 200 Script output follows
2631 200 Script output follows
2578
2632
2579 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2633 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2580 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2634 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2581 <head>
2635 <head>
2582 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2636 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2583 <meta name="robots" content="index, nofollow" />
2637 <meta name="robots" content="index, nofollow" />
2584 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2638 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2585 <script type="text/javascript" src="/static/mercurial.js"></script>
2639 <script type="text/javascript" src="/static/mercurial.js"></script>
2586
2640
2587 <title>Help: revisions</title>
2641 <title>Help: revisions</title>
2588 </head>
2642 </head>
2589 <body>
2643 <body>
2590
2644
2591 <div class="container">
2645 <div class="container">
2592 <div class="menu">
2646 <div class="menu">
2593 <div class="logo">
2647 <div class="logo">
2594 <a href="https://mercurial-scm.org/">
2648 <a href="https://mercurial-scm.org/">
2595 <img src="/static/hglogo.png" alt="mercurial" /></a>
2649 <img src="/static/hglogo.png" alt="mercurial" /></a>
2596 </div>
2650 </div>
2597 <ul>
2651 <ul>
2598 <li><a href="/shortlog">log</a></li>
2652 <li><a href="/shortlog">log</a></li>
2599 <li><a href="/graph">graph</a></li>
2653 <li><a href="/graph">graph</a></li>
2600 <li><a href="/tags">tags</a></li>
2654 <li><a href="/tags">tags</a></li>
2601 <li><a href="/bookmarks">bookmarks</a></li>
2655 <li><a href="/bookmarks">bookmarks</a></li>
2602 <li><a href="/branches">branches</a></li>
2656 <li><a href="/branches">branches</a></li>
2603 </ul>
2657 </ul>
2604 <ul>
2658 <ul>
2605 <li class="active"><a href="/help">help</a></li>
2659 <li class="active"><a href="/help">help</a></li>
2606 </ul>
2660 </ul>
2607 </div>
2661 </div>
2608
2662
2609 <div class="main">
2663 <div class="main">
2610 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2664 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2611 <h3>Help: revisions</h3>
2665 <h3>Help: revisions</h3>
2612
2666
2613 <form class="search" action="/log">
2667 <form class="search" action="/log">
2614
2668
2615 <p><input name="rev" id="search1" type="text" size="30" /></p>
2669 <p><input name="rev" id="search1" type="text" size="30" /></p>
2616 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2670 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2617 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2671 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2618 </form>
2672 </form>
2619 <div id="doc">
2673 <div id="doc">
2620 <h1>Specifying Single Revisions</h1>
2674 <h1>Specifying Single Revisions</h1>
2621 <p>
2675 <p>
2622 Mercurial supports several ways to specify individual revisions.
2676 Mercurial supports several ways to specify individual revisions.
2623 </p>
2677 </p>
2624 <p>
2678 <p>
2625 A plain integer is treated as a revision number. Negative integers are
2679 A plain integer is treated as a revision number. Negative integers are
2626 treated as sequential offsets from the tip, with -1 denoting the tip,
2680 treated as sequential offsets from the tip, with -1 denoting the tip,
2627 -2 denoting the revision prior to the tip, and so forth.
2681 -2 denoting the revision prior to the tip, and so forth.
2628 </p>
2682 </p>
2629 <p>
2683 <p>
2630 A 40-digit hexadecimal string is treated as a unique revision
2684 A 40-digit hexadecimal string is treated as a unique revision
2631 identifier.
2685 identifier.
2632 </p>
2686 </p>
2633 <p>
2687 <p>
2634 A hexadecimal string less than 40 characters long is treated as a
2688 A hexadecimal string less than 40 characters long is treated as a
2635 unique revision identifier and is referred to as a short-form
2689 unique revision identifier and is referred to as a short-form
2636 identifier. A short-form identifier is only valid if it is the prefix
2690 identifier. A short-form identifier is only valid if it is the prefix
2637 of exactly one full-length identifier.
2691 of exactly one full-length identifier.
2638 </p>
2692 </p>
2639 <p>
2693 <p>
2640 Any other string is treated as a bookmark, tag, or branch name. A
2694 Any other string is treated as a bookmark, tag, or branch name. A
2641 bookmark is a movable pointer to a revision. A tag is a permanent name
2695 bookmark is a movable pointer to a revision. A tag is a permanent name
2642 associated with a revision. A branch name denotes the tipmost open branch head
2696 associated with a revision. A branch name denotes the tipmost open branch head
2643 of that branch - or if they are all closed, the tipmost closed head of the
2697 of that branch - or if they are all closed, the tipmost closed head of the
2644 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2698 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2645 </p>
2699 </p>
2646 <p>
2700 <p>
2647 The reserved name &quot;tip&quot; always identifies the most recent revision.
2701 The reserved name &quot;tip&quot; always identifies the most recent revision.
2648 </p>
2702 </p>
2649 <p>
2703 <p>
2650 The reserved name &quot;null&quot; indicates the null revision. This is the
2704 The reserved name &quot;null&quot; indicates the null revision. This is the
2651 revision of an empty repository, and the parent of revision 0.
2705 revision of an empty repository, and the parent of revision 0.
2652 </p>
2706 </p>
2653 <p>
2707 <p>
2654 The reserved name &quot;.&quot; indicates the working directory parent. If no
2708 The reserved name &quot;.&quot; indicates the working directory parent. If no
2655 working directory is checked out, it is equivalent to null. If an
2709 working directory is checked out, it is equivalent to null. If an
2656 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2710 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2657 parent.
2711 parent.
2658 </p>
2712 </p>
2659
2713
2660 </div>
2714 </div>
2661 </div>
2715 </div>
2662 </div>
2716 </div>
2663
2717
2664 <script type="text/javascript">process_dates()</script>
2718 <script type="text/javascript">process_dates()</script>
2665
2719
2666
2720
2667 </body>
2721 </body>
2668 </html>
2722 </html>
2669
2723
2670
2724
2671 Sub-topic indexes rendered properly
2725 Sub-topic indexes rendered properly
2672
2726
2673 $ get-with-headers.py 127.0.0.1:$HGPORT "help/internals"
2727 $ get-with-headers.py 127.0.0.1:$HGPORT "help/internals"
2674 200 Script output follows
2728 200 Script output follows
2675
2729
2676 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2730 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2677 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2731 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2678 <head>
2732 <head>
2679 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2733 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2680 <meta name="robots" content="index, nofollow" />
2734 <meta name="robots" content="index, nofollow" />
2681 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2735 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2682 <script type="text/javascript" src="/static/mercurial.js"></script>
2736 <script type="text/javascript" src="/static/mercurial.js"></script>
2683
2737
2684 <title>Help: internals</title>
2738 <title>Help: internals</title>
2685 </head>
2739 </head>
2686 <body>
2740 <body>
2687
2741
2688 <div class="container">
2742 <div class="container">
2689 <div class="menu">
2743 <div class="menu">
2690 <div class="logo">
2744 <div class="logo">
2691 <a href="https://mercurial-scm.org/">
2745 <a href="https://mercurial-scm.org/">
2692 <img src="/static/hglogo.png" alt="mercurial" /></a>
2746 <img src="/static/hglogo.png" alt="mercurial" /></a>
2693 </div>
2747 </div>
2694 <ul>
2748 <ul>
2695 <li><a href="/shortlog">log</a></li>
2749 <li><a href="/shortlog">log</a></li>
2696 <li><a href="/graph">graph</a></li>
2750 <li><a href="/graph">graph</a></li>
2697 <li><a href="/tags">tags</a></li>
2751 <li><a href="/tags">tags</a></li>
2698 <li><a href="/bookmarks">bookmarks</a></li>
2752 <li><a href="/bookmarks">bookmarks</a></li>
2699 <li><a href="/branches">branches</a></li>
2753 <li><a href="/branches">branches</a></li>
2700 </ul>
2754 </ul>
2701 <ul>
2755 <ul>
2702 <li><a href="/help">help</a></li>
2756 <li><a href="/help">help</a></li>
2703 </ul>
2757 </ul>
2704 </div>
2758 </div>
2705
2759
2706 <div class="main">
2760 <div class="main">
2707 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2761 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2708 <form class="search" action="/log">
2762 <form class="search" action="/log">
2709
2763
2710 <p><input name="rev" id="search1" type="text" size="30" /></p>
2764 <p><input name="rev" id="search1" type="text" size="30" /></p>
2711 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2765 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2712 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2766 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2713 </form>
2767 </form>
2714 <table class="bigtable">
2768 <table class="bigtable">
2715 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
2769 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
2716
2770
2717 <tr><td>
2771 <tr><td>
2718 <a href="/help/internals.bundles">
2772 <a href="/help/internals.bundles">
2719 bundles
2773 bundles
2720 </a>
2774 </a>
2721 </td><td>
2775 </td><td>
2722 container for exchange of repository data
2776 container for exchange of repository data
2723 </td></tr>
2777 </td></tr>
2724 <tr><td>
2778 <tr><td>
2725 <a href="/help/internals.changegroups">
2779 <a href="/help/internals.changegroups">
2726 changegroups
2780 changegroups
2727 </a>
2781 </a>
2728 </td><td>
2782 </td><td>
2729 representation of revlog data
2783 representation of revlog data
2730 </td></tr>
2784 </td></tr>
2731 <tr><td>
2785 <tr><td>
2732 <a href="/help/internals.requirements">
2786 <a href="/help/internals.requirements">
2733 requirements
2787 requirements
2734 </a>
2788 </a>
2735 </td><td>
2789 </td><td>
2736 repository requirements
2790 repository requirements
2737 </td></tr>
2791 </td></tr>
2738 <tr><td>
2792 <tr><td>
2739 <a href="/help/internals.revlogs">
2793 <a href="/help/internals.revlogs">
2740 revlogs
2794 revlogs
2741 </a>
2795 </a>
2742 </td><td>
2796 </td><td>
2743 revision storage mechanism
2797 revision storage mechanism
2744 </td></tr>
2798 </td></tr>
2745
2799
2746
2800
2747
2801
2748
2802
2749
2803
2750 </table>
2804 </table>
2751 </div>
2805 </div>
2752 </div>
2806 </div>
2753
2807
2754 <script type="text/javascript">process_dates()</script>
2808 <script type="text/javascript">process_dates()</script>
2755
2809
2756
2810
2757 </body>
2811 </body>
2758 </html>
2812 </html>
2759
2813
2760
2814
2761 Sub-topic topics rendered properly
2815 Sub-topic topics rendered properly
2762
2816
2763 $ get-with-headers.py 127.0.0.1:$HGPORT "help/internals.changegroups"
2817 $ get-with-headers.py 127.0.0.1:$HGPORT "help/internals.changegroups"
2764 200 Script output follows
2818 200 Script output follows
2765
2819
2766 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2820 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2767 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2821 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2768 <head>
2822 <head>
2769 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2823 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2770 <meta name="robots" content="index, nofollow" />
2824 <meta name="robots" content="index, nofollow" />
2771 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2825 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2772 <script type="text/javascript" src="/static/mercurial.js"></script>
2826 <script type="text/javascript" src="/static/mercurial.js"></script>
2773
2827
2774 <title>Help: internals.changegroups</title>
2828 <title>Help: internals.changegroups</title>
2775 </head>
2829 </head>
2776 <body>
2830 <body>
2777
2831
2778 <div class="container">
2832 <div class="container">
2779 <div class="menu">
2833 <div class="menu">
2780 <div class="logo">
2834 <div class="logo">
2781 <a href="https://mercurial-scm.org/">
2835 <a href="https://mercurial-scm.org/">
2782 <img src="/static/hglogo.png" alt="mercurial" /></a>
2836 <img src="/static/hglogo.png" alt="mercurial" /></a>
2783 </div>
2837 </div>
2784 <ul>
2838 <ul>
2785 <li><a href="/shortlog">log</a></li>
2839 <li><a href="/shortlog">log</a></li>
2786 <li><a href="/graph">graph</a></li>
2840 <li><a href="/graph">graph</a></li>
2787 <li><a href="/tags">tags</a></li>
2841 <li><a href="/tags">tags</a></li>
2788 <li><a href="/bookmarks">bookmarks</a></li>
2842 <li><a href="/bookmarks">bookmarks</a></li>
2789 <li><a href="/branches">branches</a></li>
2843 <li><a href="/branches">branches</a></li>
2790 </ul>
2844 </ul>
2791 <ul>
2845 <ul>
2792 <li class="active"><a href="/help">help</a></li>
2846 <li class="active"><a href="/help">help</a></li>
2793 </ul>
2847 </ul>
2794 </div>
2848 </div>
2795
2849
2796 <div class="main">
2850 <div class="main">
2797 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2851 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2798 <h3>Help: internals.changegroups</h3>
2852 <h3>Help: internals.changegroups</h3>
2799
2853
2800 <form class="search" action="/log">
2854 <form class="search" action="/log">
2801
2855
2802 <p><input name="rev" id="search1" type="text" size="30" /></p>
2856 <p><input name="rev" id="search1" type="text" size="30" /></p>
2803 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2857 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2804 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2858 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2805 </form>
2859 </form>
2806 <div id="doc">
2860 <div id="doc">
2807 <h1>representation of revlog data</h1>
2861 <h1>representation of revlog data</h1>
2808 <h2>Changegroups</h2>
2862 <h2>Changegroups</h2>
2809 <p>
2863 <p>
2810 Changegroups are representations of repository revlog data, specifically
2864 Changegroups are representations of repository revlog data, specifically
2811 the changelog, manifest, and filelogs.
2865 the changelog, manifest, and filelogs.
2812 </p>
2866 </p>
2813 <p>
2867 <p>
2814 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
2868 There are 3 versions of changegroups: &quot;1&quot;, &quot;2&quot;, and &quot;3&quot;. From a
2815 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with
2869 high-level, versions &quot;1&quot; and &quot;2&quot; are almost exactly the same, with
2816 the only difference being a header on entries in the changeset
2870 the only difference being a header on entries in the changeset
2817 segment. Version &quot;3&quot; adds support for exchanging treemanifests and
2871 segment. Version &quot;3&quot; adds support for exchanging treemanifests and
2818 includes revlog flags in the delta header.
2872 includes revlog flags in the delta header.
2819 </p>
2873 </p>
2820 <p>
2874 <p>
2821 Changegroups consists of 3 logical segments:
2875 Changegroups consists of 3 logical segments:
2822 </p>
2876 </p>
2823 <pre>
2877 <pre>
2824 +---------------------------------+
2878 +---------------------------------+
2825 | | | |
2879 | | | |
2826 | changeset | manifest | filelogs |
2880 | changeset | manifest | filelogs |
2827 | | | |
2881 | | | |
2828 +---------------------------------+
2882 +---------------------------------+
2829 </pre>
2883 </pre>
2830 <p>
2884 <p>
2831 The principle building block of each segment is a *chunk*. A *chunk*
2885 The principle building block of each segment is a *chunk*. A *chunk*
2832 is a framed piece of data:
2886 is a framed piece of data:
2833 </p>
2887 </p>
2834 <pre>
2888 <pre>
2835 +---------------------------------------+
2889 +---------------------------------------+
2836 | | |
2890 | | |
2837 | length | data |
2891 | length | data |
2838 | (32 bits) | &lt;length&gt; bytes |
2892 | (32 bits) | &lt;length&gt; bytes |
2839 | | |
2893 | | |
2840 +---------------------------------------+
2894 +---------------------------------------+
2841 </pre>
2895 </pre>
2842 <p>
2896 <p>
2843 Each chunk starts with a 32-bit big-endian signed integer indicating
2897 Each chunk starts with a 32-bit big-endian signed integer indicating
2844 the length of the raw data that follows.
2898 the length of the raw data that follows.
2845 </p>
2899 </p>
2846 <p>
2900 <p>
2847 There is a special case chunk that has 0 length (&quot;0x00000000&quot;). We
2901 There is a special case chunk that has 0 length (&quot;0x00000000&quot;). We
2848 call this an *empty chunk*.
2902 call this an *empty chunk*.
2849 </p>
2903 </p>
2850 <h3>Delta Groups</h3>
2904 <h3>Delta Groups</h3>
2851 <p>
2905 <p>
2852 A *delta group* expresses the content of a revlog as a series of deltas,
2906 A *delta group* expresses the content of a revlog as a series of deltas,
2853 or patches against previous revisions.
2907 or patches against previous revisions.
2854 </p>
2908 </p>
2855 <p>
2909 <p>
2856 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
2910 Delta groups consist of 0 or more *chunks* followed by the *empty chunk*
2857 to signal the end of the delta group:
2911 to signal the end of the delta group:
2858 </p>
2912 </p>
2859 <pre>
2913 <pre>
2860 +------------------------------------------------------------------------+
2914 +------------------------------------------------------------------------+
2861 | | | | | |
2915 | | | | | |
2862 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
2916 | chunk0 length | chunk0 data | chunk1 length | chunk1 data | 0x0 |
2863 | (32 bits) | (various) | (32 bits) | (various) | (32 bits) |
2917 | (32 bits) | (various) | (32 bits) | (various) | (32 bits) |
2864 | | | | | |
2918 | | | | | |
2865 +------------------------------------------------------------+-----------+
2919 +------------------------------------------------------------+-----------+
2866 </pre>
2920 </pre>
2867 <p>
2921 <p>
2868 Each *chunk*'s data consists of the following:
2922 Each *chunk*'s data consists of the following:
2869 </p>
2923 </p>
2870 <pre>
2924 <pre>
2871 +-----------------------------------------+
2925 +-----------------------------------------+
2872 | | | |
2926 | | | |
2873 | delta header | mdiff header | delta |
2927 | delta header | mdiff header | delta |
2874 | (various) | (12 bytes) | (various) |
2928 | (various) | (12 bytes) | (various) |
2875 | | | |
2929 | | | |
2876 +-----------------------------------------+
2930 +-----------------------------------------+
2877 </pre>
2931 </pre>
2878 <p>
2932 <p>
2879 The *length* field is the byte length of the remaining 3 logical pieces
2933 The *length* field is the byte length of the remaining 3 logical pieces
2880 of data. The *delta* is a diff from an existing entry in the changelog.
2934 of data. The *delta* is a diff from an existing entry in the changelog.
2881 </p>
2935 </p>
2882 <p>
2936 <p>
2883 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
2937 The *delta header* is different between versions &quot;1&quot;, &quot;2&quot;, and
2884 &quot;3&quot; of the changegroup format.
2938 &quot;3&quot; of the changegroup format.
2885 </p>
2939 </p>
2886 <p>
2940 <p>
2887 Version 1:
2941 Version 1:
2888 </p>
2942 </p>
2889 <pre>
2943 <pre>
2890 +------------------------------------------------------+
2944 +------------------------------------------------------+
2891 | | | | |
2945 | | | | |
2892 | node | p1 node | p2 node | link node |
2946 | node | p1 node | p2 node | link node |
2893 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
2947 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
2894 | | | | |
2948 | | | | |
2895 +------------------------------------------------------+
2949 +------------------------------------------------------+
2896 </pre>
2950 </pre>
2897 <p>
2951 <p>
2898 Version 2:
2952 Version 2:
2899 </p>
2953 </p>
2900 <pre>
2954 <pre>
2901 +------------------------------------------------------------------+
2955 +------------------------------------------------------------------+
2902 | | | | | |
2956 | | | | | |
2903 | node | p1 node | p2 node | base node | link node |
2957 | node | p1 node | p2 node | base node | link node |
2904 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
2958 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) |
2905 | | | | | |
2959 | | | | | |
2906 +------------------------------------------------------------------+
2960 +------------------------------------------------------------------+
2907 </pre>
2961 </pre>
2908 <p>
2962 <p>
2909 Version 3:
2963 Version 3:
2910 </p>
2964 </p>
2911 <pre>
2965 <pre>
2912 +------------------------------------------------------------------------------+
2966 +------------------------------------------------------------------------------+
2913 | | | | | | |
2967 | | | | | | |
2914 | node | p1 node | p2 node | base node | link node | flags |
2968 | node | p1 node | p2 node | base node | link node | flags |
2915 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
2969 | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
2916 | | | | | | |
2970 | | | | | | |
2917 +------------------------------------------------------------------------------+
2971 +------------------------------------------------------------------------------+
2918 </pre>
2972 </pre>
2919 <p>
2973 <p>
2920 The *mdiff header* consists of 3 32-bit big-endian signed integers
2974 The *mdiff header* consists of 3 32-bit big-endian signed integers
2921 describing offsets at which to apply the following delta content:
2975 describing offsets at which to apply the following delta content:
2922 </p>
2976 </p>
2923 <pre>
2977 <pre>
2924 +-------------------------------------+
2978 +-------------------------------------+
2925 | | | |
2979 | | | |
2926 | offset | old length | new length |
2980 | offset | old length | new length |
2927 | (32 bits) | (32 bits) | (32 bits) |
2981 | (32 bits) | (32 bits) | (32 bits) |
2928 | | | |
2982 | | | |
2929 +-------------------------------------+
2983 +-------------------------------------+
2930 </pre>
2984 </pre>
2931 <p>
2985 <p>
2932 In version 1, the delta is always applied against the previous node from
2986 In version 1, the delta is always applied against the previous node from
2933 the changegroup or the first parent if this is the first entry in the
2987 the changegroup or the first parent if this is the first entry in the
2934 changegroup.
2988 changegroup.
2935 </p>
2989 </p>
2936 <p>
2990 <p>
2937 In version 2, the delta base node is encoded in the entry in the
2991 In version 2, the delta base node is encoded in the entry in the
2938 changegroup. This allows the delta to be expressed against any parent,
2992 changegroup. This allows the delta to be expressed against any parent,
2939 which can result in smaller deltas and more efficient encoding of data.
2993 which can result in smaller deltas and more efficient encoding of data.
2940 </p>
2994 </p>
2941 <h3>Changeset Segment</h3>
2995 <h3>Changeset Segment</h3>
2942 <p>
2996 <p>
2943 The *changeset segment* consists of a single *delta group* holding
2997 The *changeset segment* consists of a single *delta group* holding
2944 changelog data. It is followed by an *empty chunk* to denote the
2998 changelog data. It is followed by an *empty chunk* to denote the
2945 boundary to the *manifests segment*.
2999 boundary to the *manifests segment*.
2946 </p>
3000 </p>
2947 <h3>Manifest Segment</h3>
3001 <h3>Manifest Segment</h3>
2948 <p>
3002 <p>
2949 The *manifest segment* consists of a single *delta group* holding
3003 The *manifest segment* consists of a single *delta group* holding
2950 manifest data. It is followed by an *empty chunk* to denote the boundary
3004 manifest data. It is followed by an *empty chunk* to denote the boundary
2951 to the *filelogs segment*.
3005 to the *filelogs segment*.
2952 </p>
3006 </p>
2953 <h3>Filelogs Segment</h3>
3007 <h3>Filelogs Segment</h3>
2954 <p>
3008 <p>
2955 The *filelogs* segment consists of multiple sub-segments, each
3009 The *filelogs* segment consists of multiple sub-segments, each
2956 corresponding to an individual file whose data is being described:
3010 corresponding to an individual file whose data is being described:
2957 </p>
3011 </p>
2958 <pre>
3012 <pre>
2959 +--------------------------------------+
3013 +--------------------------------------+
2960 | | | | |
3014 | | | | |
2961 | filelog0 | filelog1 | filelog2 | ... |
3015 | filelog0 | filelog1 | filelog2 | ... |
2962 | | | | |
3016 | | | | |
2963 +--------------------------------------+
3017 +--------------------------------------+
2964 </pre>
3018 </pre>
2965 <p>
3019 <p>
2966 In version &quot;3&quot; of the changegroup format, filelogs may include
3020 In version &quot;3&quot; of the changegroup format, filelogs may include
2967 directory logs when treemanifests are in use. directory logs are
3021 directory logs when treemanifests are in use. directory logs are
2968 identified by having a trailing '/' on their filename (see below).
3022 identified by having a trailing '/' on their filename (see below).
2969 </p>
3023 </p>
2970 <p>
3024 <p>
2971 The final filelog sub-segment is followed by an *empty chunk* to denote
3025 The final filelog sub-segment is followed by an *empty chunk* to denote
2972 the end of the segment and the overall changegroup.
3026 the end of the segment and the overall changegroup.
2973 </p>
3027 </p>
2974 <p>
3028 <p>
2975 Each filelog sub-segment consists of the following:
3029 Each filelog sub-segment consists of the following:
2976 </p>
3030 </p>
2977 <pre>
3031 <pre>
2978 +------------------------------------------+
3032 +------------------------------------------+
2979 | | | |
3033 | | | |
2980 | filename size | filename | delta group |
3034 | filename size | filename | delta group |
2981 | (32 bits) | (various) | (various) |
3035 | (32 bits) | (various) | (various) |
2982 | | | |
3036 | | | |
2983 +------------------------------------------+
3037 +------------------------------------------+
2984 </pre>
3038 </pre>
2985 <p>
3039 <p>
2986 That is, a *chunk* consisting of the filename (not terminated or padded)
3040 That is, a *chunk* consisting of the filename (not terminated or padded)
2987 followed by N chunks constituting the *delta group* for this file.
3041 followed by N chunks constituting the *delta group* for this file.
2988 </p>
3042 </p>
2989
3043
2990 </div>
3044 </div>
2991 </div>
3045 </div>
2992 </div>
3046 </div>
2993
3047
2994 <script type="text/javascript">process_dates()</script>
3048 <script type="text/javascript">process_dates()</script>
2995
3049
2996
3050
2997 </body>
3051 </body>
2998 </html>
3052 </html>
2999
3053
3000
3054
3001 $ killdaemons.py
3055 $ killdaemons.py
3002
3056
3003 #endif
3057 #endif
General Comments 0
You need to be logged in to leave comments. Login now