changeset 37566:f53b55b162f4

py3: get rid of character access from pure.diffhelpers 's' is a result of readline(), so 'c == "\n"' means 's == "\n"'.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 09 Apr 2018 20:44:41 +0900
parents 9c7a25ef5b49
children 53021c4ef0b2
files mercurial/pure/diffhelpers.py
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/pure/diffhelpers.py	Wed Apr 11 18:23:29 2018 -0400
+++ b/mercurial/pure/diffhelpers.py	Mon Apr 09 20:44:41 2018 +0900
@@ -16,18 +16,17 @@
             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":
                 # Some patches may be missing the control char
                 # on empty lines. Supply a leading space.
                 s = " \n"
             hunk.append(s)
-            if c == "+":
+            if s.startswith('+'):
                 b.append(s[1:])
-            elif c == "-":
+            elif s.startswith('-'):
                 a.append(s)
             else:
                 b.append(s[1:])
@@ -41,11 +40,10 @@
         hline = l[:-2]
     else:
         hline = l[:-1]
-    c = hline[0]
 
-    if c in " +":
+    if hline.startswith((' ', '+')):
         b[-1] = hline[1:]
-    if c in " -":
+    if hline.startswith((' ', '-')):
         a[-1] = hline
     hunk[-1] = hline
     return 0