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