diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -1516,13 +1516,14 @@ def isvalid(prefix): try: - if self._partialmatch(prefix) is None: - return False + node = self._partialmatch(prefix) except error.RevlogError: return False except error.WdirUnsupported: # single 'ff...' match return True + if node is None: + raise LookupError(node, self.indexfile, _('no node')) return not isrev(prefix) hexnode = hex(node) diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -448,7 +448,10 @@ # _partialmatch() of filtered changelog could take O(len(repo)) time, # which would be unacceptably slow. so we look for hash collision in # unfiltered space, which means some hashes may be slightly longer. - return repo.unfiltered().changelog.shortest(node, minlength) + try: + return repo.unfiltered().changelog.shortest(node, minlength) + except error.LookupError: + raise error.RepoLookupError() def isrevsymbol(repo, symbol): """Checks if a symbol exists in the repo. diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py --- a/mercurial/templatefuncs.py +++ b/mercurial/templatefuncs.py @@ -608,7 +608,10 @@ return hexnode if not node: return hexnode - return scmutil.shortesthexnodeidprefix(repo, node, minlength) + try: + return scmutil.shortesthexnodeidprefix(repo, node, minlength) + except error.RepoLookupError: + return hexnode @templatefunc('strip(text[, chars])') def strip(context, mapping, args):