changeset 29538:df7d8ea90695

hgweb: enumerate lines in loop header, not before Doing this will allow access to the lines in arbitrary order (because the result of enumerate() is an iterator), and that will help calculating rowspan for annotate blocks.
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 14 Jul 2016 12:33:44 +0800
parents 5f8b36d5a6ec
children 666832b9e154
files mercurial/hgweb/webcommands.py
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Wed Jul 13 19:33:52 2016 -0700
+++ b/mercurial/hgweb/webcommands.py	Thu Jul 14 12:33:44 2016 +0800
@@ -875,13 +875,12 @@
         if util.binary(fctx.data()):
             mt = (mimetypes.guess_type(fctx.path())[0]
                   or 'application/octet-stream')
-            lines = enumerate([((fctx.filectx(fctx.filerev()), 1),
-                                '(binary:%s)' % mt)])
+            lines = [((fctx.filectx(fctx.filerev()), 1), '(binary:%s)' % mt)]
         else:
-            lines = enumerate(fctx.annotate(follow=True, linenumber=True,
-                                            diffopts=diffopts))
+            lines = fctx.annotate(follow=True, linenumber=True,
+                                  diffopts=diffopts)
         previousrev = None
-        for lineno, ((f, targetline), l) in lines:
+        for lineno, ((f, targetline), l) in enumerate(lines):
             rev = f.rev()
             blockhead = rev != previousrev or None
             previousrev = rev