# HG changeset patch # User Denis Laxalde # Date 1490902810 -7200 # Node ID 6be6e4becaafd1bf24f01a2d0464df9cea67588d # Parent bdb72dd3957eb4ab1e956cf278f85c8de06e2925 hgweb: prefix line id by ctx shortnode in filelog when patches are shown When "patch" query parameter is present in requests to filelog view, line ids in patches diff are no longer unique in the page since several patches are shown on the same page. We now prefix line id by changeset shortnode when several patches are displayed in the same page to have unique line ids overall. diff -r bdb72dd3957e -r 6be6e4becaaf mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Wed Mar 29 12:14:20 2017 -0700 +++ b/mercurial/hgweb/webcommands.py Thu Mar 30 21:40:10 2017 +0200 @@ -998,7 +998,8 @@ 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 -r bdb72dd3957e -r 6be6e4becaaf mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py Wed Mar 29 12:14:20 2017 -0700 +++ b/mercurial/hgweb/webutil.py Thu Mar 30 21:40:10 2017 +0200 @@ -434,7 +434,8 @@ 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 @@ yield tmpl(ltype, line=l, lineno=lineno, - lineid="l%s" % difflineno, + lineid=lineidprefix + "l%s" % difflineno, linenumber="% 8s" % difflineno) repo = web.repo diff -r bdb72dd3957e -r 6be6e4becaaf tests/test-hgweb-filelog.t --- a/tests/test-hgweb-filelog.t Wed Mar 29 12:14:20 2017 -0700 +++ b/tests/test-hgweb-filelog.t Thu Mar 30 21:40:10 2017 +0200 @@ -1124,10 +1124,10 @@
-  --- /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 @@
-  --- /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 @@
-  --- 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 @@
-  --- 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 @@
-  --- 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 @@
-  --- 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 @@
-  --- /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