[PATCH 01 of 10] py3: get rid of character access from pure.diffhelpers

Pulkit Goyal 7895pulkit at gmail.com
Wed Apr 11 13:08:06 EDT 2018


On Wed, Apr 11, 2018 at 9:03 PM, Yuya Nishihara <yuya at tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1523274281 -32400
> #      Mon Apr 09 20:44:41 2018 +0900
> # Node ID da53a21e2b96040ca2005d627b6c69a91e83f938
> # Parent  8475c9bf096d5f67b3a82de73b27a61ef53018f1
> py3: get rid of character access from pure.diffhelpers
>
> 's' is a result of readline(), so 'c == "\n"' means 's == "\n"'.
>
> diff --git a/mercurial/pure/diffhelpers.py b/mercurial/pure/diffhelpers.py
> --- a/mercurial/pure/diffhelpers.py
> +++ b/mercurial/pure/diffhelpers.py
> @@ -16,18 +16,17 @@ def addlines(fp, hunk, lena, lenb, a, b)
>              break
>          for i in xrange(num):
>              s = fp.readline()
> -            c = s[0]
>              if s == "\\ No newline at end of file\n":
>                  fix_newline(hunk, a, b)
>                  continue
> -            if c == "\n":
> +            if s == "\n":
>

​Shouldn't this be `s.startswith("\n")​`?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20180411/c1888c82/attachment.html>


More information about the Mercurial-devel mailing list