# HG changeset patch # User Pulkit Goyal # Date 2019-02-07 13:44:43 # Node ID 7c4e205f71caf34d111aebfdbbfa19b67d2c59d9 # Parent 635a12c53ea6cc142de741e897d8fe3fbe4eede5 py3: use bytes.startswith() instead of comparing with bytes[0] This is because bytes[0] will return the ascii value and comparison will fail. This makes test-commit-interactive-curses.t pass on Python 3. Differential Revision: https://phab.mercurial-scm.org/D5879 diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -89,6 +89,7 @@ test-clonebundles.t test-close-head.t test-commandserver.t test-commit-amend.t +test-commit-interactive-curses.t test-commit-interactive.t test-commit-multiple.t test-commit-unresolved.t diff --git a/mercurial/crecord.py b/mercurial/crecord.py --- a/mercurial/crecord.py +++ b/mercurial/crecord.py @@ -377,9 +377,9 @@ class uihunk(patchnode): def countchanges(self): """changedlines -> (n+,n-)""" add = len([l for l in self.changedlines if l.applied - and l.prettystr()[0] == '+']) + and l.prettystr().startswith('+')]) rem = len([l for l in self.changedlines if l.applied - and l.prettystr()[0] == '-']) + and l.prettystr().startswith('-')]) return add, rem def getfromtoline(self): @@ -423,7 +423,7 @@ class uihunk(patchnode): changedlinestr = changedline.prettystr() if changedline.applied: hunklinelist.append(changedlinestr) - elif changedlinestr[0] == "-": + elif changedlinestr.startswith("-"): hunklinelist.append(" " + changedlinestr[1:]) fp.write(''.join(self.before + hunklinelist + self.after)) @@ -471,11 +471,11 @@ class uihunk(patchnode): for line in self.changedlines: text = line.linetext if line.applied: - if text[0] == '+': + if text.startswith('+'): dels.append(text[1:]) - elif text[0] == '-': + elif text.startswith('-'): adds.append(text[1:]) - elif text[0] == '+': + elif text.startswith('+'): dels.append(text[1:]) adds.append(text[1:]) hunk = ['-%s' % l for l in dels] + ['+%s' % l for l in adds]