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