diff --git a/hgext/show.py b/hgext/show.py --- a/hgext/show.py +++ b/hgext/show.py @@ -28,7 +28,10 @@ The following config options can influen from __future__ import absolute_import from mercurial.i18n import _ -from mercurial.node import nullrev +from mercurial.node import ( + hex, + nullrev, +) from mercurial import ( cmdutil, commands, @@ -440,17 +443,11 @@ def longestshortest(repo, revs, minlen=4 If we fail to do this, a value of e.g. ``10023`` could mean either revision 10023 or node ``10023abc...``. """ - tres = formatter.templateresources(repo.ui, repo) - tmpl = formatter.maketemplater(repo.ui, '{shortest(node, %d)}' % minlen, - resources=tres) - - lens = [minlen] - for rev in revs: - ctx = repo[rev] - shortest = tmpl.render({'ctx': ctx, 'node': ctx.hex()}) - lens.append(len(shortest)) - - return max(lens) + if not revs: + return minlen + # don't use filtered repo because it's slow. see templater.shortest(). + cl = repo.unfiltered().changelog + return max(len(cl.shortest(hex(cl.node(r)), minlen)) for r in revs) # Adjust the docstring of the show command so it shows all registered views. # This is a bit hacky because it runs at the end of module load. When moved