D3580: py3: use .startswith() instead of bytes[0]
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Fri May 18 19:07:08 UTC 2018
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
bytes[0] returns the ascii value of character at 0 index.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D3580
AFFECTED FILES
mercurial/patch.py
CHANGE DETAILS
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2492,14 +2492,14 @@
chompline = line.rstrip('\n')
# highlight tabs and trailing whitespace
stripline = chompline.rstrip()
- if line[0] == '-':
+ if line.startswith('-'):
label = 'diff.deleted'
- elif line[0] == '+':
+ elif line.startswith('+'):
label = 'diff.inserted'
else:
raise error.ProgrammingError('unexpected hunk line: %s' % line)
for token in tabsplitter.findall(stripline):
- if '\t' == token[0]:
+ if token.startswith('\t'):
yield (token, 'diff.tab')
else:
yield (token, label)
To: pulkit, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list