[PATCH 2 of 6 py3] diff: slice over bytes to make sure conditions work normally

Yuya Nishihara yuya at tcha.org
Mon Mar 27 08:25:43 EDT 2017


On Sun, 26 Mar 2017 21:16:41 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit at gmail.com>
> # Date 1490541771 -19800
> #      Sun Mar 26 20:52:51 2017 +0530
> # Node ID 989c6385adcc3385ab984a718e09fa5d694563c4
> # Parent  2632df096fc0ac7582382b1f94ea4b9ad0bce8f2
> diff: slice over bytes to make sure conditions work normally
> 
> Both of this are part of generating `hg diff` on python 3.
> 
> diff -r 2632df096fc0 -r 989c6385adcc mercurial/mdiff.py
> --- a/mercurial/mdiff.py	Sun Mar 26 20:49:18 2017 +0530
> +++ b/mercurial/mdiff.py	Sun Mar 26 20:52:51 2017 +0530
> @@ -227,7 +227,7 @@
>  
>      def checknonewline(lines):
>          for text in lines:
> -            if text[-1] != '\n':
> +            if text[-1:len(text)] != '\n':
>                  text += "\n\ No newline at end of file\n"
>              yield text
>  
> diff -r 2632df096fc0 -r 989c6385adcc mercurial/patch.py
> --- a/mercurial/patch.py	Sun Mar 26 20:49:18 2017 +0530
> +++ b/mercurial/patch.py	Sun Mar 26 20:52:51 2017 +0530
> @@ -737,7 +737,7 @@
>          for x in self.rej:
>              for l in x.hunk:
>                  lines.append(l)
> -                if l[-1] != '\n':
> +                if l[-1:len(l)] != '\n':

len(l) isn't needed: l[-1:]


More information about the Mercurial-devel mailing list