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

Yuya Nishihara yuya at tcha.org
Thu Apr 12 07:01:16 EDT 2018


On Wed, 11 Apr 2018 22:38:06 +0530, Pulkit Goyal wrote:
> 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")​`?

No. Here we're testing if s is an empty line.


More information about the Mercurial-devel mailing list