diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -473,7 +473,7 @@ def diffs(web, tmpl, ctx, basectx, files 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 --git a/tests/test-hgweb-filelog.t b/tests/test-hgweb-filelog.t --- a/tests/test-hgweb-filelog.t +++ b/tests/test-hgweb-filelog.t @@ -1165,6 +1165,8 @@ filelog with 'linerange' and 'patch' b c $ cat < c + > 0 + > 0 > b > c+ > @@ -1177,6 +1179,8 @@ filelog with 'linerange' and 'patch' > EOF $ hg ci -m 'make c bigger and touch its beginning' c $ cat < c + > 0 + > 0 > b > c+ > @@ -1189,6 +1193,8 @@ filelog with 'linerange' and 'patch' > EOF $ hg ci -m 'just touch end of c' c $ cat < c + > 0 + > 0 > b > c++ > @@ -1201,6 +1207,8 @@ filelog with 'linerange' and 'patch' > EOF $ hg ci -m 'touch beginning of c' c $ cat < c + > 0 + > 0 > b- > c++ > @@ -1212,7 +1220,7 @@ filelog with 'linerange' and 'patch' > 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 @@ filelog with 'linerange' and 'patch' 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 @@ filelog with 'linerange' and 'patch' +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 @@ filelog with 'linerange' and 'patch' 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 @@ filelog with 'linerange' and 'patch'

- 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 @@ filelog with 'linerange' and 'patch' + @@ -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 @@ filelog with 'linerange' and 'patch'
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