diff mercurial/hgweb/webcommands.py @ 29388:f694e20193f2

hgweb: display blamed revision once per block in annotate view I.e. when a revision blames a block of source lines, only display the revision link on the first line of the block (this is identified by the "blockhead" key in annotate context). This addresses item "Visual grouping of changesets" of the blame improvements plan (https://www.mercurial-scm.org/wiki/BlamePlan) which states: "Typically there are block of lines all attributed to the same revision. Instead of rendering the revision/changeset for every line, we could only render it once per block."
author Denis Laxalde <denis.laxalde@logilab.fr>
date Tue, 07 Jun 2016 12:10:01 +0200
parents e4b777fe1576
children c4fc33c477da
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Thu Jun 02 16:26:50 2016 +0200
+++ b/mercurial/hgweb/webcommands.py	Tue Jun 07 12:10:01 2016 +0200
@@ -872,14 +872,19 @@
         else:
             lines = enumerate(fctx.annotate(follow=True, linenumber=True,
                                             diffopts=diffopts))
+        previousrev = None
         for lineno, ((f, targetline), l) in lines:
+            rev = f.rev()
+            blockhead = rev != previousrev or None
+            previousrev = rev
             yield {"parity": next(parity),
                    "node": f.hex(),
-                   "rev": f.rev(),
+                   "rev": rev,
                    "author": f.user(),
                    "desc": f.description(),
                    "extra": f.extra(),
                    "file": f.path(),
+                   "blockhead": blockhead,
                    "targetline": targetline,
                    "line": l,
                    "lineno": lineno + 1,