# HG changeset patch # User Denis Laxalde # Date 1490782027 -7200 # Node ID cbe0bea82c790140c70652b7e93487af6305890a # Parent cda83a1bfb3ac3a23cfa158c407be93755c1018e hgweb: fix diff hunks filtering by line range in webutil.diffs() The previous clause for filter out a diff hunk was too restrictive. We need to consider the following cases (assuming linerange=(lb, ub) and the @s2,l2 hunkrange): <-(s2)--------(s2+l2)-> <-(lb)---(ub)-> <-(lb)---(ub)-> <-(lb)---(ub)-> previously on the first and last situations were considered. In test-hgweb-filelog.t, add a couple of lines at the beginning of file "b" so that the line range we will follow does not start at the beginning of file. This covers the change in aforementioned diff hunk filter clause. diff -r cda83a1bfb3a -r cbe0bea82c79 mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py Sat Mar 25 11:30:08 2017 +0100 +++ b/mercurial/hgweb/webutil.py Wed Mar 29 12:07:07 2017 +0200 @@ -473,7 +473,7 @@ if linerange is not None and hunkrange is not None: s1, l1, s2, l2 = hunkrange lb, ub = linerange - if not (lb <= s2 < ub or lb < s2 + l2 <= ub): + if not (lb < s2 + l2 and ub > s2): continue lines.extend(hunklines) if lines: diff -r cda83a1bfb3a -r cbe0bea82c79 tests/test-hgweb-filelog.t --- a/tests/test-hgweb-filelog.t Sat Mar 25 11:30:08 2017 +0100 +++ b/tests/test-hgweb-filelog.t Wed Mar 29 12:07:07 2017 +0200 @@ -1165,6 +1165,8 @@ b c $ cat < c + > 0 + > 0 > b > c+ > @@ -1177,6 +1179,8 @@ > EOF $ hg ci -m 'make c bigger and touch its beginning' c $ cat < c + > 0 + > 0 > b > c+ > @@ -1189,6 +1193,8 @@ > EOF $ hg ci -m 'just touch end of c' c $ cat < c + > 0 + > 0 > b > c++ > @@ -1201,6 +1207,8 @@ > EOF $ hg ci -m 'touch beginning of c' c $ cat < c + > 0 + > 0 > b- > c++ > @@ -1212,7 +1220,7 @@ > f+ > EOF $ hg ci -m 'touching beginning and end of c' c - $ hg log -r 'followlines(c, 1:2, startrev=tip) and follow(c)' -p + $ hg log -r 'followlines(c, 3:4, startrev=tip) and follow(c)' -p changeset: 0:6563da9dcf87 user: test date: Thu Jan 01 00:00:00 1970 +0000 @@ -1237,16 +1245,18 @@ b +c - changeset: 8:c40702dbfc57 + changeset: 8:5c6574614c37 branch: a-branch user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: make c bigger and touch its beginning - diff -r 46c1a66bd8fc -r c40702dbfc57 c + diff -r 46c1a66bd8fc -r 5c6574614c37 c --- a/c Thu Jan 01 00:00:00 1970 +0000 +++ b/c Thu Jan 01 00:00:00 1970 +0000 - @@ -1,2 +1,9 @@ + @@ -1,2 +1,11 @@ + +0 + +0 b -c +c+ @@ -1258,16 +1268,18 @@ +e +f - changeset: 10:f94018eca295 + changeset: 10:e95928d60479 branch: a-branch user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: touch beginning of c - diff -r 07faa31d6d1c -r f94018eca295 c + diff -r e1d3e9c5a23f -r e95928d60479 c --- a/c Thu Jan 01 00:00:00 1970 +0000 +++ b/c Thu Jan 01 00:00:00 1970 +0000 - @@ -1,5 +1,5 @@ + @@ -1,7 +1,7 @@ + 0 + 0 b -c+ +c++ @@ -1275,30 +1287,32 @@ a a - changeset: 11:ea4193bdd9bf + changeset: 11:fb9bc322513a branch: a-branch tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: touching beginning and end of c - diff -r f94018eca295 -r ea4193bdd9bf c + diff -r e95928d60479 -r fb9bc322513a c --- a/c Thu Jan 01 00:00:00 1970 +0000 +++ b/c Thu Jan 01 00:00:00 1970 +0000 - @@ -1,4 +1,4 @@ + @@ -1,6 +1,6 @@ + 0 + 0 -b +b- c++ a - @@ -6,4 +6,4 @@ + @@ -8,4 +8,4 @@ d e+ -f +f+ - $ (get-with-headers.py localhost:$HGPORT 'log/tip/c?linerange=1:2&patch=') + $ (get-with-headers.py localhost:$HGPORT 'log/tip/c?linerange=3:4&patch=') 200 Script output follows @@ -1355,9 +1369,9 @@

- log c @ 11:ea4193bdd9bf + log c @ 11:fb9bc322513a a-branch tip - (following lines 1:2 back to filelog) + (following lines 3:4 back to filelog)

@@ -1385,59 +1399,65 @@ + @@ -1,6 +1,6 @@ + 0 + 0 + -b + +b- + c++ + + a + @@ -1,7 +1,7 @@ + 0 + 0 + b + -c+ + +c++ + + a + a + @@ -1,2 +1,11 @@ + +0 + +0 + b + -c + +c+ + + + +a + +a + + + +d + +e + +f @@ -1468,8 +1488,8 @@
Thu, 01 Jan 1970 00:00:00 +0000 test - touching beginning and end of c + touching beginning and end of c a-branch tip
   --- a/c	Thu Jan 01 00:00:00 1970 +0000
   +++ b/c	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,4 +1,4 @@
-  -b
-  +b-
-   c++
-   
-   a
Thu, 01 Jan 1970 00:00:00 +0000 test - touch beginning of c + touch beginning of c a-branch
   --- a/c	Thu Jan 01 00:00:00 1970 +0000
   +++ b/c	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,5 +1,5 @@
-   b
-  -c+
-  +c++
-   
-   a
-   a
Thu, 01 Jan 1970 00:00:00 +0000 test - make c bigger and touch its beginning + make c bigger and touch its beginning a-branch
   --- a/c	Thu Jan 01 00:00:00 1970 +0000
   +++ b/c	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,2 +1,9 @@
-   b
-  -c
-  +c+
-  +
-  +a
-  +a
-  +
-  +d
-  +e
-  +f
Thu, 01 Jan 1970 00:00:00 +0000 test