##// END OF EJS Templates
help: provide help of bad alias without executing aliascmd()...
Yuya Nishihara -
r22162:7ada3467 default
parent child Browse files
Show More
@@ -1,508 +1,510 b''
1 1 # help.py - help data for mercurial
2 2 #
3 3 # Copyright 2006 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from i18n import gettext, _
9 9 import itertools, sys, os
10 10 import error
11 11 import extensions, revset, fileset, templatekw, templatefilters, filemerge
12 12 import encoding, util, minirst
13 13 import cmdutil
14 14
15 15 def listexts(header, exts, indent=1, showdeprecated=False):
16 16 '''return a text listing of the given extensions'''
17 17 rst = []
18 18 if exts:
19 19 rst.append('\n%s\n\n' % header)
20 20 for name, desc in sorted(exts.iteritems()):
21 21 if '(DEPRECATED)' in desc and not showdeprecated:
22 22 continue
23 23 rst.append('%s:%s: %s\n' % (' ' * indent, name, desc))
24 24 return rst
25 25
26 26 def extshelp():
27 27 rst = loaddoc('extensions')().splitlines(True)
28 28 rst.extend(listexts(
29 29 _('enabled extensions:'), extensions.enabled(), showdeprecated=True))
30 30 rst.extend(listexts(_('disabled extensions:'), extensions.disabled()))
31 31 doc = ''.join(rst)
32 32 return doc
33 33
34 34 def optrst(header, options, verbose):
35 35 data = []
36 36 multioccur = False
37 37 for option in options:
38 38 if len(option) == 5:
39 39 shortopt, longopt, default, desc, optlabel = option
40 40 else:
41 41 shortopt, longopt, default, desc = option
42 42 optlabel = _("VALUE") # default label
43 43
44 44 if not verbose and ("DEPRECATED" in desc or _("DEPRECATED") in desc):
45 45 continue
46 46
47 47 so = ''
48 48 if shortopt:
49 49 so = '-' + shortopt
50 50 lo = '--' + longopt
51 51 if default:
52 52 desc += _(" (default: %s)") % default
53 53
54 54 if isinstance(default, list):
55 55 lo += " %s [+]" % optlabel
56 56 multioccur = True
57 57 elif (default is not None) and not isinstance(default, bool):
58 58 lo += " %s" % optlabel
59 59
60 60 data.append((so, lo, desc))
61 61
62 62 if multioccur:
63 63 header += (_(" ([+] can be repeated)"))
64 64
65 65 rst = ['\n%s:\n\n' % header]
66 66 rst.extend(minirst.maketable(data, 1))
67 67
68 68 return ''.join(rst)
69 69
70 70 def indicateomitted(rst, omitted, notomitted=None):
71 71 rst.append('\n\n.. container:: omitted\n\n %s\n\n' % omitted)
72 72 if notomitted:
73 73 rst.append('\n\n.. container:: notomitted\n\n %s\n\n' % notomitted)
74 74
75 75 def topicmatch(kw):
76 76 """Return help topics matching kw.
77 77
78 78 Returns {'section': [(name, summary), ...], ...} where section is
79 79 one of topics, commands, extensions, or extensioncommands.
80 80 """
81 81 kw = encoding.lower(kw)
82 82 def lowercontains(container):
83 83 return kw in encoding.lower(container) # translated in helptable
84 84 results = {'topics': [],
85 85 'commands': [],
86 86 'extensions': [],
87 87 'extensioncommands': [],
88 88 }
89 89 for names, header, doc in helptable:
90 90 if (sum(map(lowercontains, names))
91 91 or lowercontains(header)
92 92 or lowercontains(doc())):
93 93 results['topics'].append((names[0], header))
94 94 import commands # avoid cycle
95 95 for cmd, entry in commands.table.iteritems():
96 96 if len(entry) == 3:
97 97 summary = entry[2]
98 98 else:
99 99 summary = ''
100 100 # translate docs *before* searching there
101 101 docs = _(getattr(entry[0], '__doc__', None)) or ''
102 102 if kw in cmd or lowercontains(summary) or lowercontains(docs):
103 103 doclines = docs.splitlines()
104 104 if doclines:
105 105 summary = doclines[0]
106 106 cmdname = cmd.split('|')[0].lstrip('^')
107 107 results['commands'].append((cmdname, summary))
108 108 for name, docs in itertools.chain(
109 109 extensions.enabled(False).iteritems(),
110 110 extensions.disabled().iteritems()):
111 111 # extensions.load ignores the UI argument
112 112 mod = extensions.load(None, name, '')
113 113 name = name.split('.')[-1]
114 114 if lowercontains(name) or lowercontains(docs):
115 115 # extension docs are already translated
116 116 results['extensions'].append((name, docs.splitlines()[0]))
117 117 for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
118 118 if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
119 119 cmdname = cmd.split('|')[0].lstrip('^')
120 120 if entry[0].__doc__:
121 121 cmddoc = gettext(entry[0].__doc__).splitlines()[0]
122 122 else:
123 123 cmddoc = _('(no help text available)')
124 124 results['extensioncommands'].append((cmdname, cmddoc))
125 125 return results
126 126
127 127 def loaddoc(topic):
128 128 """Return a delayed loader for help/topic.txt."""
129 129
130 130 def loader():
131 131 if util.mainfrozen():
132 132 module = sys.executable
133 133 else:
134 134 module = __file__
135 135 base = os.path.dirname(module)
136 136
137 137 for dir in ('.', '..'):
138 138 docdir = os.path.join(base, dir, 'help')
139 139 if os.path.isdir(docdir):
140 140 break
141 141
142 142 path = os.path.join(docdir, topic + ".txt")
143 143 doc = gettext(util.readfile(path))
144 144 for rewriter in helphooks.get(topic, []):
145 145 doc = rewriter(topic, doc)
146 146 return doc
147 147
148 148 return loader
149 149
150 150 helptable = sorted([
151 151 (["config", "hgrc"], _("Configuration Files"), loaddoc('config')),
152 152 (["dates"], _("Date Formats"), loaddoc('dates')),
153 153 (["patterns"], _("File Name Patterns"), loaddoc('patterns')),
154 154 (['environment', 'env'], _('Environment Variables'),
155 155 loaddoc('environment')),
156 156 (['revisions', 'revs'], _('Specifying Single Revisions'),
157 157 loaddoc('revisions')),
158 158 (['multirevs', 'mrevs'], _('Specifying Multiple Revisions'),
159 159 loaddoc('multirevs')),
160 160 (['revsets', 'revset'], _("Specifying Revision Sets"), loaddoc('revsets')),
161 161 (['filesets', 'fileset'], _("Specifying File Sets"), loaddoc('filesets')),
162 162 (['diffs'], _('Diff Formats'), loaddoc('diffs')),
163 163 (['merge-tools', 'mergetools'], _('Merge Tools'), loaddoc('merge-tools')),
164 164 (['templating', 'templates', 'template', 'style'], _('Template Usage'),
165 165 loaddoc('templates')),
166 166 (['urls'], _('URL Paths'), loaddoc('urls')),
167 167 (["extensions"], _("Using Additional Features"), extshelp),
168 168 (["subrepos", "subrepo"], _("Subrepositories"), loaddoc('subrepos')),
169 169 (["hgweb"], _("Configuring hgweb"), loaddoc('hgweb')),
170 170 (["glossary"], _("Glossary"), loaddoc('glossary')),
171 171 (["hgignore", "ignore"], _("Syntax for Mercurial Ignore Files"),
172 172 loaddoc('hgignore')),
173 173 (["phases"], _("Working with Phases"), loaddoc('phases')),
174 174 ])
175 175
176 176 # Map topics to lists of callable taking the current topic help and
177 177 # returning the updated version
178 178 helphooks = {}
179 179
180 180 def addtopichook(topic, rewriter):
181 181 helphooks.setdefault(topic, []).append(rewriter)
182 182
183 183 def makeitemsdoc(topic, doc, marker, items):
184 184 """Extract docstring from the items key to function mapping, build a
185 185 .single documentation block and use it to overwrite the marker in doc
186 186 """
187 187 entries = []
188 188 for name in sorted(items):
189 189 text = (items[name].__doc__ or '').rstrip()
190 190 if not text:
191 191 continue
192 192 text = gettext(text)
193 193 lines = text.splitlines()
194 194 doclines = [(lines[0])]
195 195 for l in lines[1:]:
196 196 # Stop once we find some Python doctest
197 197 if l.strip().startswith('>>>'):
198 198 break
199 199 doclines.append(' ' + l.strip())
200 200 entries.append('\n'.join(doclines))
201 201 entries = '\n\n'.join(entries)
202 202 return doc.replace(marker, entries)
203 203
204 204 def addtopicsymbols(topic, marker, symbols):
205 205 def add(topic, doc):
206 206 return makeitemsdoc(topic, doc, marker, symbols)
207 207 addtopichook(topic, add)
208 208
209 209 addtopicsymbols('filesets', '.. predicatesmarker', fileset.symbols)
210 210 addtopicsymbols('merge-tools', '.. internaltoolsmarker', filemerge.internals)
211 211 addtopicsymbols('revsets', '.. predicatesmarker', revset.symbols)
212 212 addtopicsymbols('templates', '.. keywordsmarker', templatekw.dockeywords)
213 213 addtopicsymbols('templates', '.. filtersmarker', templatefilters.filters)
214 214
215 215 def help_(ui, name, unknowncmd=False, full=True, **opts):
216 216 '''
217 217 Generate the help for 'name' as unformatted restructured text. If
218 218 'name' is None, describe the commands available.
219 219 '''
220 220
221 221 import commands # avoid cycle
222 222
223 223 def helpcmd(name):
224 224 try:
225 225 aliases, entry = cmdutil.findcmd(name, commands.table,
226 226 strict=unknowncmd)
227 227 except error.AmbiguousCommand, inst:
228 228 # py3k fix: except vars can't be used outside the scope of the
229 229 # except block, nor can be used inside a lambda. python issue4617
230 230 prefix = inst.args[0]
231 231 select = lambda c: c.lstrip('^').startswith(prefix)
232 232 rst = helplist(select)
233 233 return rst
234 234
235 235 rst = []
236 236
237 237 # check if it's an invalid alias and display its error if it is
238 238 if getattr(entry[0], 'badalias', None):
239 if not unknowncmd:
240 ui.pushbuffer()
241 entry[0](ui)
242 rst.append(ui.popbuffer())
239 rst.append(entry[0].badalias + '\n')
240 if entry[0].unknowncmd:
241 try:
242 rst.extend(helpextcmd(entry[0].cmdname))
243 except error.UnknownCommand:
244 pass
243 245 return rst
244 246
245 247 # synopsis
246 248 if len(entry) > 2:
247 249 if entry[2].startswith('hg'):
248 250 rst.append("%s\n" % entry[2])
249 251 else:
250 252 rst.append('hg %s %s\n' % (aliases[0], entry[2]))
251 253 else:
252 254 rst.append('hg %s\n' % aliases[0])
253 255 # aliases
254 256 if full and not ui.quiet and len(aliases) > 1:
255 257 rst.append(_("\naliases: %s\n") % ', '.join(aliases[1:]))
256 258 rst.append('\n')
257 259
258 260 # description
259 261 doc = gettext(entry[0].__doc__)
260 262 if not doc:
261 263 doc = _("(no help text available)")
262 264 if util.safehasattr(entry[0], 'definition'): # aliased command
263 265 if entry[0].definition.startswith('!'): # shell alias
264 266 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:]
265 267 else:
266 268 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
267 269 doc = doc.splitlines(True)
268 270 if ui.quiet or not full:
269 271 rst.append(doc[0])
270 272 else:
271 273 rst.extend(doc)
272 274 rst.append('\n')
273 275
274 276 # check if this command shadows a non-trivial (multi-line)
275 277 # extension help text
276 278 try:
277 279 mod = extensions.find(name)
278 280 doc = gettext(mod.__doc__) or ''
279 281 if '\n' in doc.strip():
280 282 msg = _('(use "hg help -e %s" to show help for '
281 283 'the %s extension)') % (name, name)
282 284 rst.append('\n%s\n' % msg)
283 285 except KeyError:
284 286 pass
285 287
286 288 # options
287 289 if not ui.quiet and entry[1]:
288 290 rst.append(optrst(_("options"), entry[1], ui.verbose))
289 291
290 292 if ui.verbose:
291 293 rst.append(optrst(_("global options"),
292 294 commands.globalopts, ui.verbose))
293 295
294 296 if not ui.verbose:
295 297 if not full:
296 298 rst.append(_('\n(use "hg %s -h" to show more help)\n')
297 299 % name)
298 300 elif not ui.quiet:
299 301 rst.append(_('\n(some details hidden, use --verbose '
300 302 'to show complete help)'))
301 303
302 304 return rst
303 305
304 306
305 307 def helplist(select=None):
306 308 # list of commands
307 309 if name == "shortlist":
308 310 header = _('basic commands:\n\n')
309 311 elif name == "debug":
310 312 header = _('debug commands (internal and unsupported):\n\n')
311 313 else:
312 314 header = _('list of commands:\n\n')
313 315
314 316 h = {}
315 317 cmds = {}
316 318 for c, e in commands.table.iteritems():
317 319 f = c.split("|", 1)[0]
318 320 if select and not select(f):
319 321 continue
320 322 if (not select and name != 'shortlist' and
321 323 e[0].__module__ != commands.__name__):
322 324 continue
323 325 if name == "shortlist" and not f.startswith("^"):
324 326 continue
325 327 f = f.lstrip("^")
326 328 if not ui.debugflag and f.startswith("debug") and name != "debug":
327 329 continue
328 330 doc = e[0].__doc__
329 331 if doc and 'DEPRECATED' in doc and not ui.verbose:
330 332 continue
331 333 doc = gettext(doc)
332 334 if not doc:
333 335 doc = _("(no help text available)")
334 336 h[f] = doc.splitlines()[0].rstrip()
335 337 cmds[f] = c.lstrip("^")
336 338
337 339 rst = []
338 340 if not h:
339 341 if not ui.quiet:
340 342 rst.append(_('no commands defined\n'))
341 343 return rst
342 344
343 345 if not ui.quiet:
344 346 rst.append(header)
345 347 fns = sorted(h)
346 348 for f in fns:
347 349 if ui.verbose:
348 350 commacmds = cmds[f].replace("|",", ")
349 351 rst.append(" :%s: %s\n" % (commacmds, h[f]))
350 352 else:
351 353 rst.append(' :%s: %s\n' % (f, h[f]))
352 354
353 355 if not name:
354 356 exts = listexts(_('enabled extensions:'), extensions.enabled())
355 357 if exts:
356 358 rst.append('\n')
357 359 rst.extend(exts)
358 360
359 361 rst.append(_("\nadditional help topics:\n\n"))
360 362 topics = []
361 363 for names, header, doc in helptable:
362 364 topics.append((names[0], header))
363 365 for t, desc in topics:
364 366 rst.append(" :%s: %s\n" % (t, desc))
365 367
366 368 if ui.quiet:
367 369 pass
368 370 elif ui.verbose:
369 371 rst.append('\n%s\n' % optrst(_("global options"),
370 372 commands.globalopts, ui.verbose))
371 373 if name == 'shortlist':
372 374 rst.append(_('\n(use "hg help" for the full list '
373 375 'of commands)\n'))
374 376 else:
375 377 if name == 'shortlist':
376 378 rst.append(_('\n(use "hg help" for the full list of commands '
377 379 'or "hg -v" for details)\n'))
378 380 elif name and not full:
379 381 rst.append(_('\n(use "hg help %s" to show the full help '
380 382 'text)\n') % name)
381 383 else:
382 384 rst.append(_('\n(use "hg help -v%s" to show built-in aliases '
383 385 'and global options)\n')
384 386 % (name and " " + name or ""))
385 387 return rst
386 388
387 389 def helptopic(name):
388 390 for names, header, doc in helptable:
389 391 if name in names:
390 392 break
391 393 else:
392 394 raise error.UnknownCommand(name)
393 395
394 396 rst = [minirst.section(header)]
395 397
396 398 # description
397 399 if not doc:
398 400 rst.append(" %s\n" % _("(no help text available)"))
399 401 if callable(doc):
400 402 rst += [" %s\n" % l for l in doc().splitlines()]
401 403
402 404 if not ui.verbose:
403 405 omitted = _('(some details hidden, use --verbose'
404 406 ' to show complete help)')
405 407 indicateomitted(rst, omitted)
406 408
407 409 try:
408 410 cmdutil.findcmd(name, commands.table)
409 411 rst.append(_('\nuse "hg help -c %s" to see help for '
410 412 'the %s command\n') % (name, name))
411 413 except error.UnknownCommand:
412 414 pass
413 415 return rst
414 416
415 417 def helpext(name):
416 418 try:
417 419 mod = extensions.find(name)
418 420 doc = gettext(mod.__doc__) or _('no help text available')
419 421 except KeyError:
420 422 mod = None
421 423 doc = extensions.disabledext(name)
422 424 if not doc:
423 425 raise error.UnknownCommand(name)
424 426
425 427 if '\n' not in doc:
426 428 head, tail = doc, ""
427 429 else:
428 430 head, tail = doc.split('\n', 1)
429 431 rst = [_('%s extension - %s\n\n') % (name.split('.')[-1], head)]
430 432 if tail:
431 433 rst.extend(tail.splitlines(True))
432 434 rst.append('\n')
433 435
434 436 if not ui.verbose:
435 437 omitted = _('(some details hidden, use --verbose'
436 438 ' to show complete help)')
437 439 indicateomitted(rst, omitted)
438 440
439 441 if mod:
440 442 try:
441 443 ct = mod.cmdtable
442 444 except AttributeError:
443 445 ct = {}
444 446 modcmds = set([c.split('|', 1)[0] for c in ct])
445 447 rst.extend(helplist(modcmds.__contains__))
446 448 else:
447 449 rst.append(_('(use "hg help extensions" for information on enabling'
448 450 ' extensions)\n'))
449 451 return rst
450 452
451 453 def helpextcmd(name):
452 454 cmd, ext, mod = extensions.disabledcmd(ui, name,
453 455 ui.configbool('ui', 'strict'))
454 456 doc = gettext(mod.__doc__).splitlines()[0]
455 457
456 458 rst = listexts(_("'%s' is provided by the following "
457 459 "extension:") % cmd, {ext: doc}, indent=4)
458 460 rst.append('\n')
459 461 rst.append(_('(use "hg help extensions" for information on enabling '
460 462 'extensions)\n'))
461 463 return rst
462 464
463 465
464 466 rst = []
465 467 kw = opts.get('keyword')
466 468 if kw:
467 469 matches = topicmatch(kw)
468 470 for t, title in (('topics', _('Topics')),
469 471 ('commands', _('Commands')),
470 472 ('extensions', _('Extensions')),
471 473 ('extensioncommands', _('Extension Commands'))):
472 474 if matches[t]:
473 475 rst.append('%s:\n\n' % title)
474 476 rst.extend(minirst.maketable(sorted(matches[t]), 1))
475 477 rst.append('\n')
476 478 if not rst:
477 479 msg = _('no matches')
478 480 hint = _('try "hg help" for a list of topics')
479 481 raise util.Abort(msg, hint=hint)
480 482 elif name and name != 'shortlist':
481 483 if unknowncmd:
482 484 queries = (helpextcmd,)
483 485 elif opts.get('extension'):
484 486 queries = (helpext,)
485 487 elif opts.get('command'):
486 488 queries = (helpcmd,)
487 489 else:
488 490 queries = (helptopic, helpcmd, helpext, helpextcmd)
489 491 for f in queries:
490 492 try:
491 493 rst = f(name)
492 494 break
493 495 except error.UnknownCommand:
494 496 pass
495 497 else:
496 498 if unknowncmd:
497 499 raise error.UnknownCommand(name)
498 500 else:
499 501 msg = _('no such help topic: %s') % name
500 502 hint = _('try "hg help --keyword %s"') % name
501 503 raise util.Abort(msg, hint=hint)
502 504 else:
503 505 # program name
504 506 if not ui.quiet:
505 507 rst = [_("Mercurial Distributed SCM\n"), '\n']
506 508 rst.extend(helplist())
507 509
508 510 return ''.join(rst)
@@ -1,515 +1,519 b''
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 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 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 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 alias 'disabled' resolves to unknown command 'email'
93 93 'email' is provided by the following extension:
94 94
95 95 patchbomb command to send changesets as (a series of) patch emails
96 96
97 97 (use "hg help extensions" for information on enabling extensions)
98 98 [255]
99 99 $ hg help disabled
100 100 alias 'disabled' resolves to unknown command 'email'
101
101 102 'email' is provided by the following extension:
102 103
103 104 patchbomb command to send changesets as (a series of) patch emails
104 105
105 106 (use "hg help extensions" for information on enabling extensions)
106 107
107 108
108 109 no definition
109 110
110 111 $ hg nodef
111 112 no definition for alias 'nodefinition'
112 113 [255]
113 114 $ hg help nodef
114 115 no definition for alias 'nodefinition'
115 116
116 117
117 118 no closing quotation
118 119
119 120 $ hg noclosing
120 121 error in definition for alias 'noclosingquotation': No closing quotation
121 122 [255]
122 123 $ hg help noclosing
123 124 error in definition for alias 'noclosingquotation': No closing quotation
124 125
125 126
126 127 invalid options
127 128
128 129 $ hg no--cwd
129 130 error in definition for alias 'no--cwd': --cwd may only be given on the command line
130 131 [255]
131 132 $ hg help no--cwd
132 error in definition for alias 'no--cwd': --cwd may only be given on the command line
133 error in definition for alias 'no--cwd': --cwd may only be given on the
134 command line
133 135 $ hg no-R
134 136 error in definition for alias 'no-R': -R may only be given on the command line
135 137 [255]
136 138 $ hg help no-R
137 139 error in definition for alias 'no-R': -R may only be given on the command line
138 140 $ hg no--repo
139 141 error in definition for alias 'no--repo': --repo may only be given on the command line
140 142 [255]
141 143 $ hg help no--repo
142 error in definition for alias 'no--repo': --repo may only be given on the command line
144 error in definition for alias 'no--repo': --repo may only be given on the
145 command line
143 146 $ hg no--repository
144 147 error in definition for alias 'no--repository': --repository may only be given on the command line
145 148 [255]
146 149 $ hg help no--repository
147 error in definition for alias 'no--repository': --repository may only be given on the command line
150 error in definition for alias 'no--repository': --repository may only be given
151 on the command line
148 152 $ hg no--config
149 153 error in definition for alias 'no--config': --config may only be given on the command line
150 154 [255]
151 155
152 156 optional repository
153 157
154 158 #if no-outer-repo
155 159 $ hg optionalrepo
156 160 init
157 161 #endif
158 162 $ cd alias
159 163 $ cat > .hg/hgrc <<EOF
160 164 > [alias]
161 165 > myinit = init -q
162 166 > EOF
163 167 $ hg optionalrepo
164 168 init -q
165 169
166 170 no usage
167 171
168 172 $ hg nousage
169 173 no rollback information available
170 174 [1]
171 175
172 176 $ echo foo > foo
173 177 $ hg commit -Amfoo
174 178 adding foo
175 179
176 180
177 181 with opts
178 182
179 183 $ hg cleanst
180 184 C foo
181 185
182 186
183 187 with opts and whitespace
184 188
185 189 $ hg shortlog
186 190 0 e63c23eaa88a | 1970-01-01 00:00 +0000
187 191
188 192 positional arguments
189 193
190 194 $ hg positional
191 195 abort: too few arguments for command alias
192 196 [255]
193 197 $ hg positional a
194 198 abort: too few arguments for command alias
195 199 [255]
196 200 $ hg positional 'node|short' rev
197 201 0 e63c23eaa88a | 1970-01-01 00:00 +0000
198 202
199 203 interaction with defaults
200 204
201 205 $ hg mylog
202 206 0:e63c23eaa88a
203 207 $ hg lognull
204 208 -1:000000000000
205 209
206 210
207 211 properly recursive
208 212
209 213 $ hg dln
210 214 changeset: -1:0000000000000000000000000000000000000000
211 215 parent: -1:0000000000000000000000000000000000000000
212 216 parent: -1:0000000000000000000000000000000000000000
213 217 manifest: -1:0000000000000000000000000000000000000000
214 218 user:
215 219 date: Thu Jan 01 00:00:00 1970 +0000
216 220 extra: branch=default
217 221
218 222
219 223
220 224 path expanding
221 225
222 226 $ FOO=`pwd` hg put
223 227 $ cat 0.diff
224 228 # HG changeset patch
225 229 # User test
226 230 # Date 0 0
227 231 # Thu Jan 01 00:00:00 1970 +0000
228 232 # Node ID e63c23eaa88ae77967edcf4ea194d31167c478b0
229 233 # Parent 0000000000000000000000000000000000000000
230 234 foo
231 235
232 236 diff -r 000000000000 -r e63c23eaa88a foo
233 237 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
234 238 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
235 239 @@ -0,0 +1,1 @@
236 240 +foo
237 241
238 242
239 243 simple shell aliases
240 244
241 245 $ hg blank
242 246
243 247 $ hg blank foo
244 248
245 249 $ hg self
246 250 self
247 251 $ hg echoall
248 252
249 253 $ hg echoall foo
250 254 foo
251 255 $ hg echoall 'test $2' foo
252 256 test $2 foo
253 257 $ hg echoall 'test $@' foo '$@'
254 258 test $@ foo $@
255 259 $ hg echoall 'test "$@"' foo '"$@"'
256 260 test "$@" foo "$@"
257 261 $ hg echo1 foo bar baz
258 262 foo
259 263 $ hg echo2 foo bar baz
260 264 bar
261 265 $ hg echo13 foo bar baz test
262 266 foo baz
263 267 $ hg echo2 foo
264 268
265 269 $ hg echotokens
266 270
267 271 $ hg echotokens foo 'bar $1 baz'
268 272 foo
269 273 bar $1 baz
270 274 $ hg echotokens 'test $2' foo
271 275 test $2
272 276 foo
273 277 $ hg echotokens 'test $@' foo '$@'
274 278 test $@
275 279 foo
276 280 $@
277 281 $ hg echotokens 'test "$@"' foo '"$@"'
278 282 test "$@"
279 283 foo
280 284 "$@"
281 285 $ echo bar > bar
282 286 $ hg commit -qA -m bar
283 287 $ hg count .
284 288 1
285 289 $ hg count 'branch(default)'
286 290 2
287 291 $ hg mcount -r '"branch(default)"'
288 292 2
289 293
290 294 $ hg tglog
291 295 @ 1:042423737847: 'bar'
292 296 |
293 297 o 0:e63c23eaa88a: 'foo'
294 298
295 299
296 300
297 301 shadowing
298 302
299 303 $ hg i
300 304 hg: command 'i' is ambiguous:
301 305 idalias idaliaslong idaliasshell identify import incoming init
302 306 [255]
303 307 $ hg id
304 308 042423737847 tip
305 309 $ hg ida
306 310 hg: command 'ida' is ambiguous:
307 311 idalias idaliaslong idaliasshell
308 312 [255]
309 313 $ hg idalias
310 314 042423737847 tip
311 315 $ hg idaliasl
312 316 042423737847 tip
313 317 $ hg idaliass
314 318 test
315 319 $ hg parentsshell
316 320 hg: command 'parentsshell' is ambiguous:
317 321 parentsshell1 parentsshell2
318 322 [255]
319 323 $ hg parentsshell1
320 324 one
321 325 $ hg parentsshell2
322 326 two
323 327
324 328
325 329 shell aliases with global options
326 330
327 331 $ hg init sub
328 332 $ cd sub
329 333 $ hg count 'branch(default)'
330 334 abort: unknown revision 'default'!
331 335 0
332 336 $ hg -v count 'branch(default)'
333 337 abort: unknown revision 'default'!
334 338 0
335 339 $ hg -R .. count 'branch(default)'
336 340 abort: unknown revision 'default'!
337 341 0
338 342 $ hg --cwd .. count 'branch(default)'
339 343 2
340 344 $ hg echoall --cwd ..
341 345
342 346
343 347
344 348 repo specific shell aliases
345 349
346 350 $ cat >> .hg/hgrc <<EOF
347 351 > [alias]
348 352 > subalias = !echo sub
349 353 > EOF
350 354 $ cat >> ../.hg/hgrc <<EOF
351 355 > [alias]
352 356 > mainalias = !echo main
353 357 > EOF
354 358
355 359
356 360 shell alias defined in current repo
357 361
358 362 $ hg subalias
359 363 sub
360 364 $ hg --cwd .. subalias > /dev/null
361 365 hg: unknown command 'subalias'
362 366 [255]
363 367 $ hg -R .. subalias > /dev/null
364 368 hg: unknown command 'subalias'
365 369 [255]
366 370
367 371
368 372 shell alias defined in other repo
369 373
370 374 $ hg mainalias > /dev/null
371 375 hg: unknown command 'mainalias'
372 376 [255]
373 377 $ hg -R .. mainalias
374 378 main
375 379 $ hg --cwd .. mainalias
376 380 main
377 381
378 382
379 383 shell aliases with escaped $ chars
380 384
381 385 $ hg escaped1
382 386 test$test
383 387 $ hg escaped2
384 388 HGFOO is BAR
385 389 $ hg escaped3 HGFOO
386 390 HGFOO is BAR
387 391 $ hg escaped4 test
388 392 $0 $@
389 393
390 394 abbreviated name, which matches against both shell alias and the
391 395 command provided extension, should be aborted.
392 396
393 397 $ cat >> .hg/hgrc <<EOF
394 398 > [extensions]
395 399 > hgext.rebase =
396 400 > [alias]
397 401 > rebate = !echo this is rebate
398 402 > EOF
399 403 $ hg reba
400 404 hg: command 'reba' is ambiguous:
401 405 rebase rebate
402 406 [255]
403 407 $ hg rebat
404 408 this is rebate
405 409
406 410 invalid arguments
407 411
408 412 $ hg rt foo
409 413 hg rt: invalid arguments
410 414 hg rt
411 415
412 416 alias for: hg root
413 417
414 418 (use "hg rt -h" to show more help)
415 419 [255]
416 420
417 421 invalid global arguments for normal commands, aliases, and shell aliases
418 422
419 423 $ hg --invalid root
420 424 hg: option --invalid not recognized
421 425 Mercurial Distributed SCM
422 426
423 427 basic commands:
424 428
425 429 add add the specified files on the next commit
426 430 annotate show changeset information by line for each file
427 431 clone make a copy of an existing repository
428 432 commit commit the specified files or all outstanding changes
429 433 diff diff repository (or selected files)
430 434 export dump the header and diffs for one or more changesets
431 435 forget forget the specified files on the next commit
432 436 init create a new repository in the given directory
433 437 log show revision history of entire repository or files
434 438 merge merge working directory with another revision
435 439 pull pull changes from the specified source
436 440 push push changes to the specified destination
437 441 remove remove the specified files on the next commit
438 442 serve start stand-alone webserver
439 443 status show changed files in the working directory
440 444 summary summarize working directory state
441 445 update update working directory (or switch revisions)
442 446
443 447 (use "hg help" for the full list of commands or "hg -v" for details)
444 448 [255]
445 449 $ hg --invalid mylog
446 450 hg: option --invalid not recognized
447 451 Mercurial Distributed SCM
448 452
449 453 basic commands:
450 454
451 455 add add the specified files on the next commit
452 456 annotate show changeset information by line for each file
453 457 clone make a copy of an existing repository
454 458 commit commit the specified files or all outstanding changes
455 459 diff diff repository (or selected files)
456 460 export dump the header and diffs for one or more changesets
457 461 forget forget the specified files on the next commit
458 462 init create a new repository in the given directory
459 463 log show revision history of entire repository or files
460 464 merge merge working directory with another revision
461 465 pull pull changes from the specified source
462 466 push push changes to the specified destination
463 467 remove remove the specified files on the next commit
464 468 serve start stand-alone webserver
465 469 status show changed files in the working directory
466 470 summary summarize working directory state
467 471 update update working directory (or switch revisions)
468 472
469 473 (use "hg help" for the full list of commands or "hg -v" for details)
470 474 [255]
471 475 $ hg --invalid blank
472 476 hg: option --invalid not recognized
473 477 Mercurial Distributed SCM
474 478
475 479 basic commands:
476 480
477 481 add add the specified files on the next commit
478 482 annotate show changeset information by line for each file
479 483 clone make a copy of an existing repository
480 484 commit commit the specified files or all outstanding changes
481 485 diff diff repository (or selected files)
482 486 export dump the header and diffs for one or more changesets
483 487 forget forget the specified files on the next commit
484 488 init create a new repository in the given directory
485 489 log show revision history of entire repository or files
486 490 merge merge working directory with another revision
487 491 pull pull changes from the specified source
488 492 push push changes to the specified destination
489 493 remove remove the specified files on the next commit
490 494 serve start stand-alone webserver
491 495 status show changed files in the working directory
492 496 summary summarize working directory state
493 497 update update working directory (or switch revisions)
494 498
495 499 (use "hg help" for the full list of commands or "hg -v" for details)
496 500 [255]
497 501
498 502 This should show id:
499 503
500 504 $ hg --config alias.log='id' log
501 505 000000000000 tip
502 506
503 507 This shouldn't:
504 508
505 509 $ hg --config alias.log='id' history
506 510
507 511 $ cd ../..
508 512
509 513 return code of command and shell aliases:
510 514
511 515 $ hg mycommit -R alias
512 516 nothing changed
513 517 [1]
514 518 $ hg exit1
515 519 [1]
General Comments 0
You need to be logged in to leave comments. Login now