Patchwork [10,of,11] hgweb: buffer lines by block in annotate

login
register
mail settings
Submitter Denis Laxalde
Date Feb. 22, 2017, 3:10 p.m.
Message ID <2029f766a989dc8739bd.1487776204@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/18705/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Denis Laxalde - Feb. 22, 2017, 3:10 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1487769833 -3600
#      Wed Feb 22 14:23:53 2017 +0100
# Node ID 2029f766a989dc8739bd2e640f3511c441f4abc9
# Parent  2a5126051c337f38bd15862c3c5d96a83ab47acc
# EXP-Topic linerange-log/hgweb-filelog
hgweb: buffer lines by block in annotate

This will allow inserting the line range information on each line in following
patch.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -913,30 +913,39 @@  def annotate(web, req, tmpl):
 
         previousrev = None
         blockparitygen = paritygen(1)
+        block = []
         for lineno, ((f, targetline), l) in enumerate(lines):
             rev = f.rev()
             if rev != previousrev:
+                # new block, yield lines from previous one
+                for linectx in block:
+                    yield linectx
+                block = []
                 blockhead = True
                 blockparity = next(blockparitygen)
             else:
                 blockhead = None
             previousrev = rev
-            yield {"parity": next(parity),
-                   "node": f.hex(),
-                   "rev": rev,
-                   "author": f.user(),
-                   "parents": parents(f),
-                   "desc": f.description(),
-                   "extra": f.extra(),
-                   "file": f.path(),
-                   "blockhead": blockhead,
-                   "blockparity": blockparity,
-                   "targetline": targetline,
-                   "line": l,
-                   "lineno": lineno + 1,
-                   "lineid": "l%d" % (lineno + 1),
-                   "linenumber": "% 6d" % (lineno + 1),
-                   "revdate": f.date()}
+            block.append({
+                "parity": next(parity),
+                "node": f.hex(),
+                "rev": rev,
+                "author": f.user(),
+                "parents": parents(f),
+                "desc": f.description(),
+                "extra": f.extra(),
+                "file": f.path(),
+                "blockhead": blockhead,
+                "blockparity": blockparity,
+                "targetline": targetline,
+                "line": l,
+                "lineno": lineno + 1,
+                "lineid": "l%d" % (lineno + 1),
+                "linenumber": "% 6d" % (lineno + 1),
+                "revdate": f.date(),
+            })
+        for linectx in block:
+            yield linectx
 
     return tmpl("fileannotate",
                 file=f,