<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 29, 2017 at 6:10 AM, Denis Laxalde <span dir="ltr"><<a href="mailto:denis@laxalde.org" target="_blank">denis@laxalde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"># HG changeset patch<br>
# User Denis Laxalde <<a href="mailto:denis.laxalde@logilab.fr">denis.laxalde@logilab.fr</a>><br>
# Date 1490782027 -7200<br>
#      Wed Mar 29 12:07:07 2017 +0200<br>
# Node ID 28297d6c3ae842f4c26f878bf5b107<wbr>619366fbd5<br>
# Parent  e540846c67e0f838bcdb1db567a57d<wbr>f28d92491c<br>
# Available At <a href="http://hg.logilab.org/users/dlaxalde/hg" rel="noreferrer" target="_blank">http://hg.logilab.org/users/<wbr>dlaxalde/hg</a><br>
#              hg pull <a href="http://hg.logilab.org/users/dlaxalde/hg" rel="noreferrer" target="_blank">http://hg.logilab.org/users/<wbr>dlaxalde/hg</a> -r 28297d6c3ae8<br>
# EXP-Topic linerange-log/hgweb-filelog<br>
hgweb: fix diff hunks filtering by line range in webutil.diffs()<br>
<br>
The previous clause for filter out a diff hunk was too restrictive. We need to<br>
consider the following cases (assuming linerange=(lb, ub) and the @s2,l2<br>
hunkrange):<br>
<br>
            <-(s2)--------(s2+l2)-><br>
      <-(lb)---(ub)-><br>
               <-(lb)---(ub)-><br>
                           <-(lb)---(ub)-><br>
<br>
previously on the first and last situations were considered.<br>
<br>
In test-hgweb-filelog.t, add a couple of lines at the beginning of file "b" so<br>
that the line range we will follow does not start at the beginning of file.<br>
This covers the change in aforementioned diff hunk filter clause.<br></blockquote><div><br></div><div>I think this is better. But there's still some oddity here. Specifically, a number of diffs render extra lines that don't appear to be relevant to the initial line range. For example, on mozilla-central, the request for /log/60d7a0496a36/layout/base/nsCSSFrameConstructor.cpp?patch=&linerange=519:534 has an initial diff covering 13,000+ lines (the entire file). It seems we went from showing too little diff (no diff) to too much diff (all diff).<br><br></div><div>I'm not sure what's going on with this code, so I can't offer any technical suggestions for how to fix things :/<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py<br>
--- a/mercurial/hgweb/webutil.py<br>
+++ b/mercurial/hgweb/webutil.py<br>
@@ -473,7 +473,7 @@ def diffs(web, tmpl, ctx, basectx, files<br>
             if linerange is not None and hunkrange is not None:<br>
                 s1, l1, s2, l2 = hunkrange<br>
                 lb, ub = linerange<br>
-                if not (lb <= s2 < ub or lb < s2 + l2 <= ub):<br>
+                if not (lb < s2 +l2 and ub > s2):<br>
                     continue<br>
             lines.extend(hunklines)<br>
         if lines:<br>
diff --git a/tests/test-hgweb-filelog.t b/tests/test-hgweb-filelog.t<br>
--- a/tests/test-hgweb-filelog.t<br>
+++ b/tests/test-hgweb-filelog.t<br>
@@ -1165,6 +1165,8 @@ filelog with 'linerange' and 'patch'<br>
   b<br>
   c<br>
   $ cat <<EOF > c<br>
+  > 0<br>
+  > 0<br>
   > b<br>
   > c+<br>
   ><br>
@@ -1177,6 +1179,8 @@ filelog with 'linerange' and 'patch'<br>
   > EOF<br>
   $ hg ci -m 'make c bigger and touch its beginning' c<br>
   $ cat <<EOF > c<br>
+  > 0<br>
+  > 0<br>
   > b<br>
   > c+<br>
   ><br>
@@ -1189,6 +1193,8 @@ filelog with 'linerange' and 'patch'<br>
   > EOF<br>
   $ hg ci -m 'just touch end of c' c<br>
   $ cat <<EOF > c<br>
+  > 0<br>
+  > 0<br>
   > b<br>
   > c++<br>
   ><br>
@@ -1201,6 +1207,8 @@ filelog with 'linerange' and 'patch'<br>
   > EOF<br>
   $ hg ci -m 'touch beginning of c' c<br>
   $ cat <<EOF > c<br>
+  > 0<br>
+  > 0<br>
   > b-<br>
   > c++<br>
   ><br>
@@ -1212,7 +1220,7 @@ filelog with 'linerange' and 'patch'<br>
   > f+<br>
   > EOF<br>
   $ hg ci -m 'touching beginning and end of c' c<br>
-  $ hg log -r 'followlines(c, 1:2, startrev=tip) and follow(c)' -p<br>
+  $ hg log -r 'followlines(c, 3:4, startrev=tip) and follow(c)' -p<br>
   changeset:   0:6563da9dcf87<br>
   user:        test<br>
   date:        Thu Jan 01 00:00:00 1970 +0000<br>
@@ -1237,16 +1245,18 @@ filelog with 'linerange' and 'patch'<br>
    b<br>
   +c<br>
<br>
-  changeset:   8:c40702dbfc57<br>
+  changeset:   8:5c6574614c37<br>
   branch:      a-branch<br>
   user:        test<br>
   date:        Thu Jan 01 00:00:00 1970 +0000<br>
   summary:     make c bigger and touch its beginning<br>
<br>
-  diff -r 46c1a66bd8fc -r c40702dbfc57 c<br>
+  diff -r 46c1a66bd8fc -r 5c6574614c37 c<br>
   --- a/c      Thu Jan 01 00:00:00 1970 +0000<br>
   +++ b/c      Thu Jan 01 00:00:00 1970 +0000<br>
-  @@ -1,2 +1,9 @@<br>
+  @@ -1,2 +1,11 @@<br>
+  +0<br>
+  +0<br>
    b<br>
   -c<br>
   +c+<br>
@@ -1258,16 +1268,18 @@ filelog with 'linerange' and 'patch'<br>
   +e<br>
   +f<br>
<br>
-  changeset:   10:f94018eca295<br>
+  changeset:   10:e95928d60479<br>
   branch:      a-branch<br>
   user:        test<br>
   date:        Thu Jan 01 00:00:00 1970 +0000<br>
   summary:     touch beginning of c<br>
<br>
-  diff -r 07faa31d6d1c -r f94018eca295 c<br>
+  diff -r e1d3e9c5a23f -r e95928d60479 c<br>
   --- a/c      Thu Jan 01 00:00:00 1970 +0000<br>
   +++ b/c      Thu Jan 01 00:00:00 1970 +0000<br>
-  @@ -1,5 +1,5 @@<br>
+  @@ -1,7 +1,7 @@<br>
+   0<br>
+   0<br>
    b<br>
   -c+<br>
   +c++<br>
@@ -1275,30 +1287,32 @@ filelog with 'linerange' and 'patch'<br>
    a<br>
    a<br>
<br>
-  changeset:   11:ea4193bdd9bf<br>
+  changeset:   11:fb9bc322513a<br>
   branch:      a-branch<br>
   tag:         tip<br>
   user:        test<br>
   date:        Thu Jan 01 00:00:00 1970 +0000<br>
   summary:     touching beginning and end of c<br>
<br>
-  diff -r f94018eca295 -r ea4193bdd9bf c<br>
+  diff -r e95928d60479 -r fb9bc322513a c<br>
   --- a/c      Thu Jan 01 00:00:00 1970 +0000<br>
   +++ b/c      Thu Jan 01 00:00:00 1970 +0000<br>
-  @@ -1,4 +1,4 @@<br>
+  @@ -1,6 +1,6 @@<br>
+   0<br>
+   0<br>
   -b<br>
   +b-<br>
    c++<br>
<br>
    a<br>
-  @@ -6,4 +6,4 @@<br>
+  @@ -8,4 +8,4 @@<br>
<br>
    d<br>
    e+<br>
   -f<br>
   +f+<br>
<br>
-  $ (get-with-headers.py localhost:$HGPORT 'log/tip/c?linerange=1:2&<wbr>patch=')<br>
+  $ (get-with-headers.py localhost:$HGPORT 'log/tip/c?linerange=3:4&<wbr>patch=')<br>
   200 Script output follows<br>
<br>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "<a href="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" rel="noreferrer" target="_blank">http://www.w3.org/TR/xhtml11/<wbr>DTD/xhtml11.dtd</a>"><br>
@@ -1355,9 +1369,9 @@ filelog with 'linerange' and 'patch'<br>
   <div class="main"><br>
   <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2><br>
   <h3><br>
-   log c @ 11:<a href="/rev/ea4193bdd9bf"><wbr>ea4193bdd9bf</a><br>
+   log c @ 11:<a href="/rev/fb9bc322513a"><wbr>fb9bc322513a</a><br>
    <span class="branchname">a-branch</<wbr>span> <span class="tag">tip</span><br>
-    (following lines 1:2 <a href="/log/tip/c">back to filelog</a>)<br>
+    (following lines 3:4 <a href="/log/tip/c">back to filelog</a>)<br>
   </h3><br>
<br>
   <form class="search" action="/log"><br>
@@ -1368,8 +1382,8 @@ filelog with 'linerange' and 'patch'<br>
   </form><br>
<br>
   <div class="navigate"><br>
-  <a href="/log/tip/c?linerange=1%<wbr>3A2&patch=&revcount=30">less</<wbr>a><br>
-  <a href="/log/tip/c?linerange=1%<wbr>3A2&patch=&revcount=120">more<<wbr>/a><br>
+  <a href="/log/tip/c?linerange=3%<wbr>3A4&patch=&revcount=30">less</<wbr>a><br>
+  <a href="/log/tip/c?linerange=3%<wbr>3A4&patch=&revcount=120">more<<wbr>/a><br>
   |  </div><br>
<br>
   <table class="bigtable"><br>
@@ -1385,59 +1399,65 @@ filelog with 'linerange' and 'patch'<br>
     <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td><br>
     <td class="author">test</td><br>
     <td class="description"><br>
-     <a href="/rev/ea4193bdd9bf"><wbr>touching beginning and end of c</a><br>
+     <a href="/rev/fb9bc322513a"><wbr>touching beginning and end of c</a><br>
      <span class="branchhead">a-branch</<wbr>span> <span class="tag">tip</span><br>
     </td><br>
    </tr><br>
    <tr><td colspan="3"><div class="bottomline inc-lineno"><pre class="sourcelines wrap"><br>
   <span id="l1.1" class="minusline">--- a/c    Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.1"></a><br>
   <span id="l1.2" class="plusline">+++ b/c     Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.2"></a><br>
-  <span id="l1.3" class="atline">@@ -1,4 +1,4 @@</span><a href="#l1.3"></a><br>
-  <span id="l1.4" class="minusline">-b</span><a href="#l1.4"></a><br>
-  <span id="l1.5" class="plusline">+b-</span><a href="#l1.5"></a><br>
-  <span id="l1.6"> c++</span><a href="#l1.6"></a><br>
-  <span id="l1.7"> </span><a href="#l1.7"></a><br>
-  <span id="l1.8"> a</span><a href="#l1.8"></a></pre></div><<wbr>/td></tr><br>
+  <span id="l1.3" class="atline">@@ -1,6 +1,6 @@</span><a href="#l1.3"></a><br>
+  <span id="l1.4"> 0</span><a href="#l1.4"></a><br>
+  <span id="l1.5"> 0</span><a href="#l1.5"></a><br>
+  <span id="l1.6" class="minusline">-b</span><a href="#l1.6"></a><br>
+  <span id="l1.7" class="plusline">+b-</span><a href="#l1.7"></a><br>
+  <span id="l1.8"> c++</span><a href="#l1.8"></a><br>
+  <span id="l1.9"> </span><a href="#l1.9"></a><br>
+  <span id="l1.10"> a</span><a href="#l1.10"></a></pre></div><wbr></td></tr><br>
    <tr><br>
     <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td><br>
     <td class="author">test</td><br>
     <td class="description"><br>
-     <a href="/rev/f94018eca295">touch beginning of c</a><br>
+     <a href="/rev/e95928d60479">touch beginning of c</a><br>
      <span class="branchname">a-branch</<wbr>span><br>
     </td><br>
    </tr><br>
    <tr><td colspan="3"><div class="bottomline inc-lineno"><pre class="sourcelines wrap"><br>
   <span id="l1.1" class="minusline">--- a/c    Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.1"></a><br>
   <span id="l1.2" class="plusline">+++ b/c     Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.2"></a><br>
-  <span id="l1.3" class="atline">@@ -1,5 +1,5 @@</span><a href="#l1.3"></a><br>
-  <span id="l1.4"> b</span><a href="#l1.4"></a><br>
-  <span id="l1.5" class="minusline">-c+</span><a href="#l1.5"></a><br>
-  <span id="l1.6" class="plusline">+c++</span><a href="#l1.6"></a><br>
-  <span id="l1.7"> </span><a href="#l1.7"></a><br>
-  <span id="l1.8"> a</span><a href="#l1.8"></a><br>
-  <span id="l1.9"> a</span><a href="#l1.9"></a></pre></div><<wbr>/td></tr><br>
+  <span id="l1.3" class="atline">@@ -1,7 +1,7 @@</span><a href="#l1.3"></a><br>
+  <span id="l1.4"> 0</span><a href="#l1.4"></a><br>
+  <span id="l1.5"> 0</span><a href="#l1.5"></a><br>
+  <span id="l1.6"> b</span><a href="#l1.6"></a><br>
+  <span id="l1.7" class="minusline">-c+</span><a href="#l1.7"></a><br>
+  <span id="l1.8" class="plusline">+c++</span><a href="#l1.8"></a><br>
+  <span id="l1.9"> </span><a href="#l1.9"></a><br>
+  <span id="l1.10"> a</span><a href="#l1.10"></a><br>
+  <span id="l1.11"> a</span><a href="#l1.11"></a></pre></div><wbr></td></tr><br>
    <tr><br>
     <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td><br>
     <td class="author">test</td><br>
     <td class="description"><br>
-     <a href="/rev/c40702dbfc57">make c bigger and touch its beginning</a><br>
+     <a href="/rev/5c6574614c37">make c bigger and touch its beginning</a><br>
      <span class="branchname">a-branch</<wbr>span><br>
     </td><br>
    </tr><br>
    <tr><td colspan="3"><div class="bottomline inc-lineno"><pre class="sourcelines wrap"><br>
   <span id="l1.1" class="minusline">--- a/c    Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.1"></a><br>
   <span id="l1.2" class="plusline">+++ b/c     Thu Jan 01 00:00:00 1970 +0000</span><a href="#l1.2"></a><br>
-  <span id="l1.3" class="atline">@@ -1,2 +1,9 @@</span><a href="#l1.3"></a><br>
-  <span id="l1.4"> b</span><a href="#l1.4"></a><br>
-  <span id="l1.5" class="minusline">-c</span><a href="#l1.5"></a><br>
-  <span id="l1.6" class="plusline">+c+</span><a href="#l1.6"></a><br>
-  <span id="l1.7" class="plusline">+</span><a href="#l1.7"></a><br>
-  <span id="l1.8" class="plusline">+a</span><a href="#l1.8"></a><br>
-  <span id="l1.9" class="plusline">+a</span><a href="#l1.9"></a><br>
-  <span id="l1.10" class="plusline">+</span><a href="#l1.10"></a><br>
-  <span id="l1.11" class="plusline">+d</span><a href="#l1.11"></a><br>
-  <span id="l1.12" class="plusline">+e</span><a href="#l1.12"></a><br>
-  <span id="l1.13" class="plusline">+f</span><a href="#l1.13"></a></pre></div><wbr></td></tr><br>
+  <span id="l1.3" class="atline">@@ -1,2 +1,11 @@</span><a href="#l1.3"></a><br>
+  <span id="l1.4" class="plusline">+0</span><a href="#l1.4"></a><br>
+  <span id="l1.5" class="plusline">+0</span><a href="#l1.5"></a><br>
+  <span id="l1.6"> b</span><a href="#l1.6"></a><br>
+  <span id="l1.7" class="minusline">-c</span><a href="#l1.7"></a><br>
+  <span id="l1.8" class="plusline">+c+</span><a href="#l1.8"></a><br>
+  <span id="l1.9" class="plusline">+</span><a href="#l1.9"></a><br>
+  <span id="l1.10" class="plusline">+a</span><a href="#l1.10"></a><br>
+  <span id="l1.11" class="plusline">+a</span><a href="#l1.11"></a><br>
+  <span id="l1.12" class="plusline">+</span><a href="#l1.12"></a><br>
+  <span id="l1.13" class="plusline">+d</span><a href="#l1.13"></a><br>
+  <span id="l1.14" class="plusline">+e</span><a href="#l1.14"></a><br>
+  <span id="l1.15" class="plusline">+f</span><a href="#l1.15"></a></pre></div><wbr></td></tr><br>
    <tr><br>
     <td class="age">Thu, 01 Jan 1970 00:00:00 +0000</td><br>
     <td class="author">test</td><br>
@@ -1468,8 +1488,8 @@ filelog with 'linerange' and 'patch'<br>
   </table><br>
<br>
   <div class="navigate"><br>
-  <a href="/log/tip/c?linerange=1%<wbr>3A2&patch=&revcount=30">less</<wbr>a><br>
-  <a href="/log/tip/c?linerange=1%<wbr>3A2&patch=&revcount=120">more<<wbr>/a><br>
+  <a href="/log/tip/c?linerange=3%<wbr>3A4&patch=&revcount=30">less</<wbr>a><br>
+  <a href="/log/tip/c?linerange=3%<wbr>3A4&patch=&revcount=120">more<<wbr>/a><br>
   |<br>
   </div><br>
<br>
______________________________<wbr>_________________<br>
Mercurial-devel mailing list<br>
<a href="mailto:Mercurial-devel@mercurial-scm.org">Mercurial-devel@mercurial-scm.<wbr>org</a><br>
<a href="https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel" rel="noreferrer" target="_blank">https://www.mercurial-scm.org/<wbr>mailman/listinfo/mercurial-<wbr>devel</a><br>
</blockquote></div><br></div></div>