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

Denis Laxalde denis at laxalde.org
Wed Mar 1 10:48:48 EST 2017


Yuya Nishihara a écrit :
> 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.

Indeed, there's a problem in patch 8.

This works better:

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -905,7 +905,7 @@ def annotate(web, req, tmpl):
      def addlinerange(lines):
          if lines:
              linerange = webutil.formatlinerange(
-                lines[0]['lineno'] - 1, lines[-1]['lineno'])
+                lines[0]['targetline'] - 1, lines[-1]['targetline'])
              for l in lines:
                  l['linerange'] = linerange
                  yield l

("lineno" refers to the currently viewed fctx and "targetline" refers to
the one we link to)


More information about the Mercurial-devel mailing list