##// END OF EJS Templates
show: use revlog function to compute length of the longest shortest node...
Yuya Nishihara -
r35514:dfaf9f10 default
parent child Browse files
Show More
@@ -28,7 +28,10 b' The following config options can influen'
28 from __future__ import absolute_import
28 from __future__ import absolute_import
29
29
30 from mercurial.i18n import _
30 from mercurial.i18n import _
31 from mercurial.node import nullrev
31 from mercurial.node import (
32 hex,
33 nullrev,
34 )
32 from mercurial import (
35 from mercurial import (
33 cmdutil,
36 cmdutil,
34 commands,
37 commands,
@@ -440,17 +443,11 b' def longestshortest(repo, revs, minlen=4'
440 If we fail to do this, a value of e.g. ``10023`` could mean either
443 If we fail to do this, a value of e.g. ``10023`` could mean either
441 revision 10023 or node ``10023abc...``.
444 revision 10023 or node ``10023abc...``.
442 """
445 """
443 tres = formatter.templateresources(repo.ui, repo)
446 if not revs:
444 tmpl = formatter.maketemplater(repo.ui, '{shortest(node, %d)}' % minlen,
447 return minlen
445 resources=tres)
448 # don't use filtered repo because it's slow. see templater.shortest().
446
449 cl = repo.unfiltered().changelog
447 lens = [minlen]
450 return max(len(cl.shortest(hex(cl.node(r)), minlen)) for r in revs)
448 for rev in revs:
449 ctx = repo[rev]
450 shortest = tmpl.render({'ctx': ctx, 'node': ctx.hex()})
451 lens.append(len(shortest))
452
453 return max(lens)
454
451
455 # Adjust the docstring of the show command so it shows all registered views.
452 # Adjust the docstring of the show command so it shows all registered views.
456 # This is a bit hacky because it runs at the end of module load. When moved
453 # This is a bit hacky because it runs at the end of module load. When moved
General Comments 0
You need to be logged in to leave comments. Login now