[PATCH] hgweb: prefix line id by ctx shortnode in filelog when patches are shown

Martin von Zweigbergk martinvonz at google.com
Mon Apr 3 19:42:01 UTC 2017


On Fri, Mar 31, 2017 at 1:55 AM, Denis Laxalde <denis at laxalde.org> wrote:
> # HG changeset patch
> # User Denis Laxalde <denis at laxalde.org>
> # Date 1490902810 -7200
> #      Thu Mar 30 21:40:10 2017 +0200
> # Node ID 7ae1cc7ae6c50a037525f27e203a2ce75fc3004f
> # Parent  dea2a17cbfd00bf08ee87b3e44b1c71499189f89
> # Available At http://hg.logilab.org/users/dlaxalde/hg
> #              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 7ae1cc7ae6c5
> hgweb: prefix line id by ctx shortnode in filelog when patches are shown
>
> When "patch" query parameter is present in requests to filelog view, line ids
> in patches diff are no longer unique in the page since several patches are
> shown on the same page. We now prefix line id by changeset shortnode when
> several patches are displayed in the same page to have unique line ids
> overall.
>
> diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
> --- a/mercurial/hgweb/webcommands.py
> +++ b/mercurial/hgweb/webcommands.py
> @@ -998,7 +998,8 @@ def filelog(web, req, tmpl):
>          basectx = ctx.p1()
>          path = fctx.path()
>          return webutil.diffs(web, tmpl, ctx, basectx, [path], diffstyle,
> -                             linerange=linerange)
> +                             linerange=linerange,
> +                             lineidprefix='%s-' % ctx.hex()[:12])

Nit: would "lineidprefix=short(ctx.node())" be better? That returns
bytes. I don't know if that's what you want on py3.


More information about the Mercurial-devel mailing list