[PATCH 2 of 6 py3] py3: stop using bytes[n] in patch.py
Yuya Nishihara
yuya at tcha.org
Sun Sep 17 04:19:01 UTC 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1505618435 -32400
# Sun Sep 17 12:20:35 2017 +0900
# Node ID 32586281847e0c04512b3ace89315b69f0ac5b80
# Parent 2a70a351319def181dfc102f8577a1f006abf970
py3: stop using bytes[n] in patch.py
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -960,8 +960,8 @@ class recordhunk(object):
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 @@ class recordhunk(object):
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)
More information about the Mercurial-devel
mailing list