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

login
register
mail settings
Submitter Denis Laxalde
Date March 1, 2017, 3:48 p.m.
Message ID <28520940-7545-4377-090f-11e9513e4da0@laxalde.org>
Download mbox | patch
Permalink /patch/18854/
State Deferred, archived
Headers show

Comments

Denis Laxalde - March 1, 2017, 3:48 p.m.
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:


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

Patch

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