--- a/hgext/show.py Tue Dec 19 11:20:35 2017 +0530
+++ b/hgext/show.py Mon Dec 25 22:56:59 2017 +0900
@@ -28,7 +28,10 @@
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 @@
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