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

login
register
mail settings
Submitter Denis Laxalde
Date March 9, 2017, 8:08 a.m.
Message ID <48a6d7717d8cde08abd4.1489046886@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/19061/
State Accepted
Headers show

Comments

Denis Laxalde - March 9, 2017, 8:08 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 48a6d7717d8cde08abd448c392724cf8cb4b5282
# Parent  c907c7574d72f9d82eb590057ecc19133920ad00
# Available At http://hg.logilab.org/users/dlaxalde/hg
#              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 48a6d7717d8c
# EXP-Topic diffhunks
hgweb: start enumerate at 1 in webutil.diffs's inner function prettyprintlines
Augie Fackler - March 9, 2017, 11:55 p.m.
On Thu, Mar 09, 2017 at 09:08:06AM +0100, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1488789879 -3600
> #      Mon Mar 06 09:44:39 2017 +0100
> # Node ID 48a6d7717d8cde08abd448c392724cf8cb4b5282
> # Parent  c907c7574d72f9d82eb590057ecc19133920ad00
> # Available At http://hg.logilab.org/users/dlaxalde/hg
> #              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 48a6d7717d8c
> # EXP-Topic diffhunks
> hgweb: start enumerate at 1 in webutil.diffs's inner function prettyprintlines

I've taken patches 1-9. Looking at patch 10 soon, but I suspect I'll
want others to lay eyes on it as well. Thanks!

>
> 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)
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

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)