##// END OF EJS Templates
dispatch: report similar names consistently
Bryan O'Sullivan -
r27623:b3376fba default
parent child Browse files
Show More
@@ -59,6 +59,13 b' def _getsimilar(symbols, value):'
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):
@@ -71,12 +78,7 b' def _formatparse(write, inst):'
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"
@@ -262,8 +264,7 b' def _runcatch(req):'
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')
@@ -360,11 +360,11 b' 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 (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
@@ -372,7 +372,7 b' 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
@@ -645,12 +645,12 b' this is a section and erroring out weird'
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'
@@ -1482,11 +1482,11 b' parentrevspec'
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
@@ -1499,7 +1499,7 b' Bogus function gets suggestions'
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
General Comments 0
You need to be logged in to leave comments. Login now