comparison mercurial/dispatch.py @ 45882:8cc9e7f762d6

errors: move similarity_hint() to error module I want to be able to reuse it from `UnknownIdentifier`'s constructor. Moving it results in a new import of `difflib` in the `error` module. There was a comment at the top of `error.py` saying "Do not import anything but pycompat here, please", which was added (except for the "pycompat" bit) in 08cabecfa8a8 (errors: move revlog errors, 2009-01-11). I don't know the reason for the comment. I'm guessing the point was to not make the module depend on other Mercurial modules. If that was it, then importing `difflib` should be fine. Sorry about the churn (I moved this code from the `dispatch` module to the `scmutil` module very recently). Differential Revision: https://phab.mercurial-scm.org/D9345
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 19 Nov 2020 12:20:26 -0800
parents bb1b7a5bc96b
children 98399dd1b96c
comparison
equal deleted inserted replaced
45881:bb1b7a5bc96b 45882:8cc9e7f762d6
482 ui.warn(nocmdmsg) 482 ui.warn(nocmdmsg)
483 ui.write(formatted) 483 ui.write(formatted)
484 except (error.UnknownCommand, error.Abort): 484 except (error.UnknownCommand, error.Abort):
485 suggested = False 485 suggested = False
486 if inst.all_commands: 486 if inst.all_commands:
487 sim = scmutil.getsimilar(inst.all_commands, inst.command) 487 sim = error.getsimilar(inst.all_commands, inst.command)
488 if sim: 488 if sim:
489 ui.warn(nocmdmsg) 489 ui.warn(nocmdmsg)
490 ui.warn(b"(%s)\n" % scmutil.similarity_hint(sim)) 490 ui.warn(b"(%s)\n" % error.similarity_hint(sim))
491 suggested = True 491 suggested = True
492 if not suggested: 492 if not suggested:
493 ui.warn(nocmdmsg) 493 ui.warn(nocmdmsg)
494 ui.warn(_(b"(use 'hg help' for a list of commands)\n")) 494 ui.warn(_(b"(use 'hg help' for a list of commands)\n"))
495 except IOError: 495 except IOError: