##// END OF EJS Templates
errors: morph reportsimilar() into similarity_hint()...
Martin von Zweigbergk -
r46493:bb1b7a5b default
parent child Browse files
Show More
@@ -487,7 +487,7 b' def _callcatch(ui, func):'
487 sim = scmutil.getsimilar(inst.all_commands, inst.command)
487 sim = scmutil.getsimilar(inst.all_commands, inst.command)
488 if sim:
488 if sim:
489 ui.warn(nocmdmsg)
489 ui.warn(nocmdmsg)
490 scmutil.reportsimilar(ui.warn, sim)
490 ui.warn(b"(%s)\n" % scmutil.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)
@@ -150,12 +150,14 b' def getsimilar(symbols, value):'
150 return [s for s in symbols if sim(s) > 0.6]
150 return [s for s in symbols if sim(s) > 0.6]
151
151
152
152
153 def reportsimilar(write, similar):
153 def similarity_hint(similar):
154 if len(similar) == 1:
154 if len(similar) == 1:
155 write(_(b"(did you mean %s?)\n") % similar[0])
155 return _(b"did you mean %s?") % similar[0]
156 elif similar:
156 elif similar:
157 ss = b", ".join(sorted(similar))
157 ss = b", ".join(sorted(similar))
158 write(_(b"(did you mean one of %s?)\n") % ss)
158 return _(b"did you mean one of %s?") % ss
159 else:
160 return None
159
161
160
162
161 def formatparse(write, inst):
163 def formatparse(write, inst):
@@ -169,7 +171,9 b' def formatparse(write, inst):'
169 if isinstance(inst, error.UnknownIdentifier):
171 if isinstance(inst, error.UnknownIdentifier):
170 # make sure to check fileset first, as revset can invoke fileset
172 # make sure to check fileset first, as revset can invoke fileset
171 similar = getsimilar(inst.symbols, inst.function)
173 similar = getsimilar(inst.symbols, inst.function)
172 reportsimilar(write, similar)
174 hint = similarity_hint(similar)
175 if hint:
176 write(b"(%s)\n" % hint)
173 elif inst.hint:
177 elif inst.hint:
174 write(_(b"(%s)\n") % inst.hint)
178 write(_(b"(%s)\n") % inst.hint)
175
179
General Comments 0
You need to be logged in to leave comments. Login now