py3: stop using bytes[n] in patch.py
authorYuya Nishihara <yuya@tcha.org>
Sun, 17 Sep 2017 12:20:35 +0900
changeset 34252 c43d055ae405
parent 34251 61714510220d
child 34253 5ce32fe7df34
py3: stop using bytes[n] in patch.py
mercurial/patch.py
--- a/mercurial/patch.py	Sun Sep 03 16:45:33 2017 +0900
+++ b/mercurial/patch.py	Sun Sep 17 12:20:35 2017 +0900
@@ -960,8 +960,8 @@
 
     def countchanges(self, hunk):
         """hunk -> (n+,n-)"""
-        add = len([h for h in hunk if h[0] == '+'])
-        rem = len([h for h in hunk if h[0] == '-'])
+        add = len([h for h in hunk if h.startswith('+')])
+        rem = len([h for h in hunk if h.startswith('-')])
         return add, rem
 
     def reversehunk(self):
@@ -972,7 +972,7 @@
         unchanged.
         """
         m = {'+': '-', '-': '+', '\\': '\\'}
-        hunk = ['%s%s' % (m[l[0]], l[1:]) for l in self.hunk]
+        hunk = ['%s%s' % (m[l[0:1]], l[1:]) for l in self.hunk]
         return recordhunk(self.header, self.toline, self.fromline, self.proc,
                           self.before, hunk, self.after)