Patchwork [7,of,8,V2] hgweb: buffer lines by block in annotate

login
register
mail settings
Submitter Denis Laxalde
Date Feb. 25, 2017, 9:06 a.m.
Message ID <073bd73b65afcb2acd47.1488013564@marimba>
Download mbox | patch
Permalink /patch/18775/
State Changes Requested
Headers show

Comments

Denis Laxalde - Feb. 25, 2017, 9:06 a.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1487769833 -3600
#      Wed Feb 22 14:23:53 2017 +0100
# Node ID 073bd73b65afcb2acd4783c14cb2983ef21fb5a6
# Parent  206b34cf11b768c4e74582ffb89e78feedbce7ef
# Available At https://hg.logilab.org/users/dlaxalde/hg
#              hg pull https://hg.logilab.org/users/dlaxalde/hg -r 073bd73b65af
# 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
@@ -912,30 +912,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,