diff -r 890bdf0e33c8 -r da083d9fafab mercurial/templatefuncs.py --- a/mercurial/templatefuncs.py Wed May 02 22:56:10 2018 -0700 +++ b/mercurial/templatefuncs.py Sat May 05 00:16:43 2018 -0700 @@ -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):