##// END OF EJS Templates
dispatch: offer suggestions of similar-named commands...
Augie Fackler -
r24222:02d7b5cd default
parent child Browse files
Show More
@@ -34,8 +34,10 def findpossible(cmd, table, strict=Fals
34 34 else:
35 35 keys = table.keys()
36 36
37 allcmds = []
37 38 for e in keys:
38 39 aliases = parsealiases(e)
40 allcmds.extend(aliases)
39 41 found = None
40 42 if cmd in aliases:
41 43 found = cmd
@@ -53,11 +55,11 def findpossible(cmd, table, strict=Fals
53 55 if not choice and debugchoice:
54 56 choice = debugchoice
55 57
56 return choice
58 return choice, allcmds
57 59
58 60 def findcmd(cmd, table, strict=True):
59 61 """Return (aliases, command table entry) for command string."""
60 choice = findpossible(cmd, table, strict)
62 choice, allcmds = findpossible(cmd, table, strict)
61 63
62 64 if cmd in choice:
63 65 return choice[cmd]
@@ -70,7 +72,7 def findcmd(cmd, table, strict=True):
70 72 if choice:
71 73 return choice.values()[0]
72 74
73 raise error.UnknownCommand(cmd)
75 raise error.UnknownCommand(cmd, allcmds)
74 76
75 77 def findrepo(p):
76 78 while not os.path.isdir(os.path.join(p, ".hg")):
@@ -1946,7 +1946,7 def debugcomplete(ui, cmd='', **opts):
1946 1946 ui.write("%s\n" % "\n".join(options))
1947 1947 return
1948 1948
1949 cmdlist = cmdutil.findpossible(cmd, table)
1949 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
1950 1950 if ui.verbose:
1951 1951 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1952 1952 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
@@ -220,6 +220,14 def _runcatch(req):
220 220 # (but don't check for extensions themselves)
221 221 commands.help_(ui, inst.args[0], unknowncmd=True)
222 222 except error.UnknownCommand:
223 suggested = False
224 if len(inst.args) == 2:
225 sim = _getsimilar(inst.args[1], inst.args[0])
226 if sim:
227 ui.warn(_('(did you mean one of %s?)\n') %
228 ', '.join(sorted(sim)))
229 suggested = True
230 if not suggested:
223 231 commands.help_(ui, 'shortlist')
224 232 except error.InterventionRequired, inst:
225 233 ui.warn("%s\n" % inst)
@@ -360,9 +360,11 shell alias defined in current repo
360 360 sub
361 361 $ hg --cwd .. subalias > /dev/null
362 362 hg: unknown command 'subalias'
363 (did you mean one of idalias?)
363 364 [255]
364 365 $ hg -R .. subalias > /dev/null
365 366 hg: unknown command 'subalias'
367 (did you mean one of idalias?)
366 368 [255]
367 369
368 370
@@ -370,12 +372,18 shell alias defined in other repo
370 372
371 373 $ hg mainalias > /dev/null
372 374 hg: unknown command 'mainalias'
375 (did you mean one of idalias?)
373 376 [255]
374 377 $ hg -R .. mainalias
375 378 main
376 379 $ hg --cwd .. mainalias
377 380 main
378 381
382 typos get useful suggestions
383 $ hg --cwd .. manalias
384 hg: unknown command 'manalias'
385 (did you mean one of idalias, mainalias, manifest?)
386 [255]
379 387
380 388 shell aliases with escaped $ chars
381 389
@@ -890,19 +890,19 parentrevspec
890 890
891 891 Bogus function gets suggestions
892 892 $ log 'add()'
893 hg: parse error: not a function: add
893 hg: parse error: unknown identifier: add
894 894 (did you mean 'adds'?)
895 895 [255]
896 896 $ log 'added()'
897 hg: parse error: not a function: added
897 hg: parse error: unknown identifier: added
898 898 (did you mean 'adds'?)
899 899 [255]
900 900 $ log 'remo()'
901 hg: parse error: not a function: remo
901 hg: parse error: unknown identifier: remo
902 902 (did you mean one of remote, removes?)
903 903 [255]
904 904 $ log 'babar()'
905 hg: parse error: not a function: babar
905 hg: parse error: unknown identifier: babar
906 906 [255]
907 907
908 908 multiple revspecs
@@ -1056,12 +1056,12 far away.
1056 1056 (range
1057 1057 ('symbol', '2')
1058 1058 ('symbol', '5')))
1059 abort: failed to parse the definition of revset alias "injectparamasstring2": not a function: _aliasarg
1059 abort: failed to parse the definition of revset alias "injectparamasstring2": unknown identifier: _aliasarg
1060 1060 [255]
1061 1061 $ hg debugrevspec --debug --config revsetalias.anotherbadone='branch(' "tip"
1062 1062 ('symbol', 'tip')
1063 1063 warning: failed to parse the definition of revset alias "anotherbadone": at 7: not a prefix: end
1064 warning: failed to parse the definition of revset alias "injectparamasstring2": not a function: _aliasarg
1064 warning: failed to parse the definition of revset alias "injectparamasstring2": unknown identifier: _aliasarg
1065 1065 9
1066 1066 >>> data = file('.hg/hgrc', 'rb').read()
1067 1067 >>> file('.hg/hgrc', 'wb').write(data.replace('_aliasarg', ''))
General Comments 0
You need to be logged in to leave comments. Login now