diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -998,7 +998,8 @@ def filelog(web, req, tmpl): basectx = ctx.p1() path = fctx.path() return webutil.diffs(web, tmpl, ctx, basectx, [path], diffstyle, - linerange=linerange) + linerange=linerange, + lineidprefix='%s-' % ctx.hex()[:12]) linerange = None if lrange is not None: diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -434,7 +434,8 @@ def listfilediffs(tmpl, files, node, max if len(files) > max: yield tmpl('fileellipses') -def diffs(web, tmpl, ctx, basectx, files, style, linerange=None): +def diffs(web, tmpl, ctx, basectx, files, style, linerange=None, + lineidprefix=''): def prettyprintlines(lines, blockno): for lineno, l in enumerate(lines, 1): @@ -450,7 +451,7 @@ def diffs(web, tmpl, ctx, basectx, files yield tmpl(ltype, line=l, lineno=lineno, - lineid="l%s" % difflineno, + lineid=lineidprefix + "l%s" % difflineno, linenumber="% 8s" % difflineno) repo = web.repo 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 @@ -1124,10 +1124,10 @@ filelog with patch
-  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
-  @@ -0,0 +1,1 @@
-  +b
+ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/a Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +b Thu, 01 Jan 1970 00:00:00 +0000 test @@ -1137,10 +1137,10 @@ filelog with patch
-  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
-  @@ -0,0 +1,1 @@
-  +a
+ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/a Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +a @@ -1404,16 +1404,16 @@ filelog with 'linerange' and 'patch'
-  --- a/c	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,6 +1,6 @@
-   0
-   0
-  -b
-  +b-
-   c++
-   
-   a
+ --- a/c Thu Jan 01 00:00:00 1970 +0000 + +++ b/c Thu Jan 01 00:00:00 1970 +0000 + @@ -1,6 +1,6 @@ + 0 + 0 + -b + +b- + c++ + + a Thu, 01 Jan 1970 00:00:00 +0000 test @@ -1423,17 +1423,17 @@ filelog with 'linerange' and 'patch'
-  --- a/c	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,7 +1,7 @@
-   0
-   0
-   b
-  -c+
-  +c++
-   
-   a
-   a
+ --- a/c Thu Jan 01 00:00:00 1970 +0000 + +++ b/c Thu Jan 01 00:00:00 1970 +0000 + @@ -1,7 +1,7 @@ + 0 + 0 + b + -c+ + +c++ + + a + a Thu, 01 Jan 1970 00:00:00 +0000 test @@ -1443,21 +1443,21 @@ filelog with 'linerange' and 'patch'
-  --- a/c	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/c	Thu Jan 01 00:00:00 1970 +0000
-  @@ -1,2 +1,11 @@
-  +0
-  +0
-   b
-  -c
-  +c+
-  +
-  +a
-  +a
-  +
-  +d
-  +e
-  +f
+ --- a/c Thu Jan 01 00:00:00 1970 +0000 + +++ b/c Thu Jan 01 00:00:00 1970 +0000 + @@ -1,2 +1,11 @@ + +0 + +0 + b + -c + +c+ + + + +a + +a + + + +d + +e + +f Thu, 01 Jan 1970 00:00:00 +0000 test @@ -1467,11 +1467,11 @@ filelog with 'linerange' and 'patch'
-  --- 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
+ --- 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 +0000 test @@ -1481,8 +1481,8 @@ filelog with 'linerange' and 'patch'
-  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-  +++ b/b	Thu Jan 01 00:00:00 1970 +0000
+ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/b Thu Jan 01 00:00:00 1970 +0000