[PATCH 5 of 8 V2] hgweb: handle "linerange" request parameter in filediff command

Yuya Nishihara yuya at tcha.org
Wed Mar 1 14:50:22 UTC 2017


On Sat, 25 Feb 2017 10:06:02 +0100, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde at logilab.fr>
> # Date 1484922599 -3600
> #      Fri Jan 20 15:29:59 2017 +0100
> # Node ID 7fbe70c91d65683ab3984f7c80edc85f5c02860c
> # Parent  6625dfbecf264f51748a96aa7203fc09bee597e9
> # Available At https://hg.logilab.org/users/dlaxalde/hg
> #              hg pull https://hg.logilab.org/users/dlaxalde/hg -r 7fbe70c91d65
> # EXP-Topic linerange-log/hgweb-filelog
> hgweb: handle "linerange" request parameter in filediff command

> diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
> --- a/mercurial/hgweb/webcommands.py
> +++ b/mercurial/hgweb/webcommands.py
> @@ -762,7 +762,24 @@ def filediff(web, req, tmpl):
>      if 'style' in req.form:
>          style = req.form['style'][0]
>  
> -    diffs = webutil.diffs(web.repo, tmpl, ctx, basectx, [path], parity, style)
> +    lineranges = {}
> +    linerange = webutil.linerange(req)
> +    if linerange is not None:
> +        assert fctx is not None
> +        lineranges = {fctx: linerange}
> +        ancestors = context.blockancestors(fctx, *linerange, followfirst=True)
> +        try:
> +            next(ancestors)  # first iteration returns fctx
> +            p, plinerange = next(ancestors)
> +        except StopIteration:
> +            pass
> +        else:
> +            lineranges[p] = plinerange
> +            basectx = p.changectx()
> +        linerange = webutil.formatlinerange(*linerange)
> +
> +    diffs = webutil.diffs(web.repo, tmpl, ctx, basectx, [path], parity, style,
> +                          lineranges)
>      if fctx is not None:
>          rename = webutil.renamelink(fctx)
>          ctx = fctx
> @@ -774,6 +791,7 @@ def filediff(web, req, tmpl):
>                  symrev=webutil.symrevorshortnode(req, ctx),
>                  rename=rename,
>                  diff=diffs,
> +                linerange=linerange,
>                  **webutil.commonentry(web.repo, ctx))

I got a strange error. Can you take a look?

 1. run "hg serve" in mercurial repo
 2. open http://localhost:8000/annotate/tip/mercurial/cmdutil.py
 3. scroll down to the bottom
 4. click "follow lines" link of the last chunk
    http://localhost:8000/log/ed4d06f180b8/mercurial/cmdutil.py?linerange=3439:3475

We might use a wrong fctx/linerange pair.


More information about the Mercurial-devel mailing list