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

login
register
mail settings
Submitter Denis Laxalde
Date March 6, 2017, 9:38 a.m.
Message ID <b895b2b1a592730ba3ad.1488793106@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/18929/
State Accepted
Headers show

Comments

Denis Laxalde - March 6, 2017, 9:38 a.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@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

Patch

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)