py3: get rid of character access from pure.diffhelpers
authorYuya Nishihara <yuya@tcha.org>
Mon, 09 Apr 2018 20:44:41 +0900
changeset 37566 f53b55b162f4
parent 37565 9c7a25ef5b49
child 37567 53021c4ef0b2
py3: get rid of character access from pure.diffhelpers 's' is a result of readline(), so 'c == "\n"' means 's == "\n"'.
mercurial/pure/diffhelpers.py
--- 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