diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -993,11 +993,12 @@ def filelog(web, req, tmpl): if 'style' in req.form: diffstyle = req.form['style'][0] - def diff(fctx): + def diff(fctx, linerange=None): ctx = fctx.changectx() basectx = ctx.p1() path = fctx.path() - return webutil.diffs(web, tmpl, ctx, basectx, [path], diffstyle) + return webutil.diffs(web, tmpl, ctx, basectx, [path], diffstyle, + linerange=linerange) linerange = None if lrange is not None: @@ -1009,7 +1010,7 @@ def filelog(web, req, tmpl): for i, (c, lr) in enumerate(ancestors, 1): diffs = None if patch: - diffs = diff(c) + diffs = diff(c, linerange=lr) # follow renames accross filtered (not in range) revisions path = c.path() entries.append(dict( 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 @@ -1159,6 +1159,328 @@ filelog with patch +filelog with 'linerange' and 'patch' + + $ cat c + b + c + $ cat < c + > b + > c+ + > + > a + > a + > + > d + > e + > f + > EOF + $ hg ci -m 'make c bigger and touch its beginning' c + $ cat < c + > b + > c+ + > + > a + > a + > + > d + > e+ + > f + > EOF + $ hg ci -m 'just touch end of c' c + $ cat < c + > b + > c++ + > + > a + > a + > + > d + > e+ + > f + > EOF + $ hg ci -m 'touch beginning of c' c + $ cat < c + > b- + > c++ + > + > a + > a + > + > d + > e+ + > 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 + changeset: 0:6563da9dcf87 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: b + + diff -r 000000000000 -r 6563da9dcf87 b + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/b Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +b + + changeset: 7:46c1a66bd8fc + branch: a-branch + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: change c + + diff -r c9637d3cc8ef -r 46c1a66bd8fc c + --- a/c Thu Jan 01 00:00:00 1970 +0000 + +++ b/c Thu Jan 01 00:00:00 1970 +0000 + @@ -1,1 +1,2 @@ + b + +c + + changeset: 8:c40702dbfc57 + 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 + --- 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 + + changeset: 10:f94018eca295 + 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 + --- 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 + + changeset: 11:ea4193bdd9bf + 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 + --- 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 + @@ -6,4 +6,4 @@ + + d + e+ + -f + +f+ + + $ (get-with-headers.py localhost:$HGPORT 'log/tip/c?linerange=1:2&patch=') + 200 Script output follows + + + + + + + + + + test: c history + + + + + +
+ + +
+ +

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

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ageauthordescription
Thu, 01 Jan 1970 00:00:00 +0000test + 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 +0000test + 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 +0000test + 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 +0000test + change c + a-branch +
+  --- a/c	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,2 @@
+   b
+  +c
Thu, 01 Jan 1970 00:00:00 +0000test + b + +
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+ + + +
+
+ + + + + + rss log