[PATCH] show: use revlog function to compute length of the longest shortest node
Augie Fackler
raf at durin42.com
Wed Dec 27 00:48:55 EST 2017
queued, thanks
> On Dec 25, 2017, at 9:29 AM, Yuya Nishihara <yuya at tcha.org> wrote:
>
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1514210219 -32400
> # Mon Dec 25 22:56:59 2017 +0900
> # Node ID 9ace27eb22d921b9ceb741bd341959c67a7865dd
> # Parent 784a85c87c22b70958f119abcbec138fa8019161
> show: use revlog function to compute length of the longest shortest node
>
> As the core part of shortest() was extracted at 448725a2ef73, we no logner
> need a templater.
>
> 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list