D9343: errors: restructure formatparse() to clarify conditions a bit
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Sat Nov 21 00:26:05 UTC 2020
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
The `similar` list will be calculated only for
`error.UnknownIdentifier`. It was then printed only if `inst.location
is None`, which is true for that exception type, but it's an indirect
condition to rely on.
Also, it looked from the code like it could both report similarities
and print a hint. That would be a little awkward because the
similarity report looks similar to the hint (both are printed within
parentheses). I also added a `elif` to clarify that. I plan to
refactor this more coming patches so the similarity report actually is
a hint.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D9343
AFFECTED FILES
mercurial/scmutil.py
CHANGE DETAILS
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -159,10 +159,6 @@
def formatparse(write, inst):
- similar = []
- if isinstance(inst, error.UnknownIdentifier):
- # make sure to check fileset first, as revset can invoke fileset
- similar = getsimilar(inst.symbols, inst.function)
if inst.location is not None:
write(
_(b"hg: parse error at %s: %s\n")
@@ -170,8 +166,11 @@
)
else:
write(_(b"hg: parse error: %s\n") % inst.message)
+ if isinstance(inst, error.UnknownIdentifier):
+ # make sure to check fileset first, as revset can invoke fileset
+ similar = getsimilar(inst.symbols, inst.function)
reportsimilar(write, similar)
- if inst.hint:
+ elif inst.hint:
write(_(b"(%s)\n") % inst.hint)
To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list