Patchwork D3580: py3: use .startswith() instead of bytes[0]

login
register
mail settings
Submitter phabricator
Date May 19, 2018, 2:37 a.m.
Message ID <e46e2055cd71e7b11fae5a060600c8d8@localhost.localdomain>
Download mbox | patch
Permalink /patch/31668/
State Not Applicable
Headers show

Comments

phabricator - May 19, 2018, 2:37 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb403e87df069: py3: use .startswith() instead of bytes[0] (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3580?vs=8741&id=8752

REVISION DETAIL
  https://phab.mercurial-scm.org/D3580

AFFECTED FILES
  mercurial/patch.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

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)