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