comparison mercurial/patch.py @ 38048:b403e87df069

py3: use .startswith() instead of bytes[0] bytes[0] returns the ascii value of character at 0 index. Differential Revision: https://phab.mercurial-scm.org/D3580
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 19 May 2018 00:19:56 +0530
parents 72f6498c040b
children 468797392cc6
comparison
equal deleted inserted replaced
38047:dabc2237963c 38048:b403e87df069
2490 for line in hunklines: 2490 for line in hunklines:
2491 # chomp 2491 # chomp
2492 chompline = line.rstrip('\n') 2492 chompline = line.rstrip('\n')
2493 # highlight tabs and trailing whitespace 2493 # highlight tabs and trailing whitespace
2494 stripline = chompline.rstrip() 2494 stripline = chompline.rstrip()
2495 if line[0] == '-': 2495 if line.startswith('-'):
2496 label = 'diff.deleted' 2496 label = 'diff.deleted'
2497 elif line[0] == '+': 2497 elif line.startswith('+'):
2498 label = 'diff.inserted' 2498 label = 'diff.inserted'
2499 else: 2499 else:
2500 raise error.ProgrammingError('unexpected hunk line: %s' % line) 2500 raise error.ProgrammingError('unexpected hunk line: %s' % line)
2501 for token in tabsplitter.findall(stripline): 2501 for token in tabsplitter.findall(stripline):
2502 if '\t' == token[0]: 2502 if token.startswith('\t'):
2503 yield (token, 'diff.tab') 2503 yield (token, 'diff.tab')
2504 else: 2504 else:
2505 yield (token, label) 2505 yield (token, label)
2506 2506
2507 if chompline != stripline: 2507 if chompline != stripline: