Patchwork [1,of,4] py3: fix slicing of bytes in patch.iterhunks()

login
register
mail settings
Submitter Yuya Nishihara
Date March 3, 2018, 7:38 p.m.
Message ID <fd2dba485a2af4f3de5c.1520105892@mimosa>
Download mbox | patch
Permalink /patch/28810/
State Accepted
Headers show

Comments

Yuya Nishihara - March 3, 2018, 7:38 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1520104907 18000
#      Sat Mar 03 14:21:47 2018 -0500
# Node ID fd2dba485a2af4f3de5ce0c3b7d8c9690115c4bd
# Parent  e2b87e19c6efa87f12da17350207ea6d97062cfd
py3: fix slicing of bytes in patch.iterhunks()
Pulkit Goyal - March 3, 2018, 7:46 p.m.
Looks good to me. Queued the series. Many thanks.

On Sun, Mar 4, 2018 at 1:08 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1520104907 18000
> #      Sat Mar 03 14:21:47 2018 -0500
> # Node ID fd2dba485a2af4f3de5ce0c3b7d8c9690115c4bd
> # Parent  e2b87e19c6efa87f12da17350207ea6d97062cfd
> py3: fix slicing of bytes in patch.iterhunks()
>
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -1852,7 +1852,7 @@ def iterhunks(fp):
>
>      for x in iter(lr.readline, ''):
>          if state == BFILE and (
> -            (not context and x[0] == '@')
> +            (not context and x.startswith('@'))
>              or (context is not False and x.startswith('***************'))
>              or x.startswith('GIT binary patch')):
>              gp = None
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1852,7 +1852,7 @@  def iterhunks(fp):
 
     for x in iter(lr.readline, ''):
         if state == BFILE and (
-            (not context and x[0] == '@')
+            (not context and x.startswith('@'))
             or (context is not False and x.startswith('***************'))
             or x.startswith('GIT binary patch')):
             gp = None