Show More
@@ -59,6 +59,13 b' def _getsimilar(symbols, value):' | |||||
59 | # probably be investigated and tweaked. |
|
59 | # probably be investigated and tweaked. | |
60 | return [s for s in symbols if sim(s) > 0.6] |
|
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 | def _formatparse(write, inst): |
|
69 | def _formatparse(write, inst): | |
63 | similar = [] |
|
70 | similar = [] | |
64 | if isinstance(inst, error.UnknownIdentifier): |
|
71 | if isinstance(inst, error.UnknownIdentifier): | |
@@ -71,12 +78,7 b' def _formatparse(write, inst):' | |||||
71 | write(_("unexpected leading whitespace\n")) |
|
78 | write(_("unexpected leading whitespace\n")) | |
72 | else: |
|
79 | else: | |
73 | write(_("hg: parse error: %s\n") % inst.args[0]) |
|
80 | write(_("hg: parse error: %s\n") % inst.args[0]) | |
74 | if similar: |
|
81 | _reportsimilar(write, 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) |
|
|||
80 |
|
82 | |||
81 | def dispatch(req): |
|
83 | def dispatch(req): | |
82 | "run the command specified in req.args" |
|
84 | "run the command specified in req.args" | |
@@ -262,8 +264,7 b' def _runcatch(req):' | |||||
262 | if len(inst.args) == 2: |
|
264 | if len(inst.args) == 2: | |
263 | sim = _getsimilar(inst.args[1], inst.args[0]) |
|
265 | sim = _getsimilar(inst.args[1], inst.args[0]) | |
264 | if sim: |
|
266 | if sim: | |
265 | ui.warn(_('(did you mean one of %s?)\n') % |
|
267 | _reportsimilar(ui.warn, sim) | |
266 | ', '.join(sorted(sim))) |
|
|||
267 | suggested = True |
|
268 | suggested = True | |
268 | if not suggested: |
|
269 | if not suggested: | |
269 | commands.help_(ui, 'shortlist') |
|
270 | commands.help_(ui, 'shortlist') |
@@ -360,11 +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 |
|
363 | (did you mean idalias?) | |
364 | [255] |
|
364 | [255] | |
365 | $ hg -R .. subalias > /dev/null |
|
365 | $ hg -R .. subalias > /dev/null | |
366 | hg: unknown command 'subalias' |
|
366 | hg: unknown command 'subalias' | |
367 |
(did you mean |
|
367 | (did you mean idalias?) | |
368 | [255] |
|
368 | [255] | |
369 |
|
369 | |||
370 |
|
370 | |||
@@ -372,7 +372,7 b' shell alias defined in other repo' | |||||
372 |
|
372 | |||
373 | $ hg mainalias > /dev/null |
|
373 | $ hg mainalias > /dev/null | |
374 | hg: unknown command 'mainalias' |
|
374 | hg: unknown command 'mainalias' | |
375 |
(did you mean |
|
375 | (did you mean idalias?) | |
376 | [255] |
|
376 | [255] | |
377 | $ hg -R .. mainalias |
|
377 | $ hg -R .. mainalias | |
378 | main |
|
378 | main |
@@ -645,12 +645,12 b' this is a section and erroring out weird' | |||||
645 |
|
645 | |||
646 | $ hg .log |
|
646 | $ hg .log | |
647 | hg: unknown command '.log' |
|
647 | hg: unknown command '.log' | |
648 |
(did you mean |
|
648 | (did you mean log?) | |
649 | [255] |
|
649 | [255] | |
650 |
|
650 | |||
651 | $ hg log. |
|
651 | $ hg log. | |
652 | hg: unknown command 'log.' |
|
652 | hg: unknown command 'log.' | |
653 |
(did you mean |
|
653 | (did you mean log?) | |
654 | [255] |
|
654 | [255] | |
655 | $ hg pu.lh |
|
655 | $ hg pu.lh | |
656 | hg: unknown command 'pu.lh' |
|
656 | hg: unknown command 'pu.lh' |
@@ -1482,11 +1482,11 b' parentrevspec' | |||||
1482 | Bogus function gets suggestions |
|
1482 | Bogus function gets suggestions | |
1483 | $ log 'add()' |
|
1483 | $ log 'add()' | |
1484 | hg: parse error: unknown identifier: add |
|
1484 | hg: parse error: unknown identifier: add | |
1485 |
(did you mean |
|
1485 | (did you mean adds?) | |
1486 | [255] |
|
1486 | [255] | |
1487 | $ log 'added()' |
|
1487 | $ log 'added()' | |
1488 | hg: parse error: unknown identifier: added |
|
1488 | hg: parse error: unknown identifier: added | |
1489 |
(did you mean |
|
1489 | (did you mean adds?) | |
1490 | [255] |
|
1490 | [255] | |
1491 | $ log 'remo()' |
|
1491 | $ log 'remo()' | |
1492 | hg: parse error: unknown identifier: remo |
|
1492 | hg: parse error: unknown identifier: remo | |
@@ -1499,7 +1499,7 b' Bogus function gets suggestions' | |||||
1499 | Bogus function with a similar internal name doesn't suggest the internal name |
|
1499 | Bogus function with a similar internal name doesn't suggest the internal name | |
1500 | $ log 'matches()' |
|
1500 | $ log 'matches()' | |
1501 | hg: parse error: unknown identifier: matches |
|
1501 | hg: parse error: unknown identifier: matches | |
1502 |
(did you mean |
|
1502 | (did you mean matching?) | |
1503 | [255] |
|
1503 | [255] | |
1504 |
|
1504 | |||
1505 | Undocumented functions aren't suggested as similar either |
|
1505 | Undocumented functions aren't suggested as similar either |
General Comments 0
You need to be logged in to leave comments.
Login now