[PATCH 8 of 9] hgweb: start enumerate at 1 in webutil.diffs's inner function prettyprintlines

Denis Laxalde denis at laxalde.org
Mon Mar 6 04:38:26 EST 2017


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1488789879 -3600
#      Mon Mar 06 09:44:39 2017 +0100
# Node ID b895b2b1a592730ba3add0733de73d34c4ff090c
# Parent  2b3bbcb8cca52db9e0dae20dbf028b67a39abc7c
# Available At http://hg.logilab.org/users/dlaxalde/hg
#              hg pull http://hg.logilab.org/users/dlaxalde/hg -r b895b2b1a592
# EXP-Topic diffhunks
hgweb: start enumerate at 1 in webutil.diffs's inner function prettyprintlines

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -420,8 +420,8 @@ def diffs(repo, tmpl, ctx, basectx, file
 
     blockcount = countgen()
     def prettyprintlines(diff, blockno):
-        for lineno, l in enumerate(diff.splitlines(True)):
-            difflineno = "%d.%d" % (blockno, lineno + 1)
+        for lineno, l in enumerate(diff.splitlines(True), 1):
+            difflineno = "%d.%d" % (blockno, lineno)
             if l.startswith('+'):
                 ltype = "difflineplus"
             elif l.startswith('-'):
@@ -432,7 +432,7 @@ def diffs(repo, tmpl, ctx, basectx, file
                 ltype = "diffline"
             yield tmpl(ltype,
                        line=l,
-                       lineno=lineno + 1,
+                       lineno=lineno,
                        lineid="l%s" % difflineno,
                        linenumber="% 8s" % difflineno)
 


More information about the Mercurial-devel mailing list