This fixes some regressed Python 3 tests, though I'm not sure when
they regressed.
Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| hg-reviewers |
This fixes some regressed Python 3 tests, though I'm not sure when
they regressed.
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/patch.py (8 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Augie Fackler | May 18 2018, 8:22 PM |
| def diffsinglehunk(hunklines): | def diffsinglehunk(hunklines): | ||||
| """yield tokens for a list of lines in a single hunk""" | """yield tokens for a list of lines in a single hunk""" | ||||
| for line in hunklines: | for line in hunklines: | ||||
| # chomp | # chomp | ||||
| chompline = line.rstrip('\n') | chompline = line.rstrip('\n') | ||||
| # highlight tabs and trailing whitespace | # highlight tabs and trailing whitespace | ||||
| stripline = chompline.rstrip() | stripline = chompline.rstrip() | ||||
| if line[0] == '-': | if line[0:1] == '-': | ||||
| label = 'diff.deleted' | label = 'diff.deleted' | ||||
| elif line[0] == '+': | elif line[0:1] == '+': | ||||
| label = 'diff.inserted' | label = 'diff.inserted' | ||||
| else: | else: | ||||
| raise error.ProgrammingError('unexpected hunk line: %s' % line) | raise error.ProgrammingError('unexpected hunk line: %s' % line) | ||||
| for token in tabsplitter.findall(stripline): | for token in tabsplitter.findall(stripline): | ||||
| if '\t' == token[0]: | if '\t' == token[0]: | ||||
| yield (token, 'diff.tab') | yield (token, 'diff.tab') | ||||
| else: | else: | ||||
| yield (token, label) | yield (token, label) | ||||
| if chompline != stripline: | if chompline != stripline: | ||||
| yield (chompline[len(stripline):], 'diff.trailingwhitespace') | yield (chompline[len(stripline):], 'diff.trailingwhitespace') | ||||
| if chompline != line: | if chompline != line: | ||||
| yield (line[len(chompline):], '') | yield (line[len(chompline):], '') | ||||
| def diffsinglehunkinline(hunklines): | def diffsinglehunkinline(hunklines): | ||||
| """yield tokens for a list of lines in a single hunk, with inline colors""" | """yield tokens for a list of lines in a single hunk, with inline colors""" | ||||
| # prepare deleted, and inserted content | # prepare deleted, and inserted content | ||||
| a = '' | a = '' | ||||
| b = '' | b = '' | ||||
| for line in hunklines: | for line in hunklines: | ||||
| if line[0] == '-': | if line[0:1] == '-': | ||||
| a += line[1:] | a += line[1:] | ||||
| elif line[0] == '+': | elif line[0:1] == '+': | ||||
| b += line[1:] | b += line[1:] | ||||
| else: | else: | ||||
| raise error.ProgrammingError('unexpected hunk line: %s' % line) | raise error.ProgrammingError('unexpected hunk line: %s' % line) | ||||
| # fast path: if either side is empty, use diffsinglehunk | # fast path: if either side is empty, use diffsinglehunk | ||||
| if not a or not b: | if not a or not b: | ||||
| for t in diffsinglehunk(hunklines): | for t in diffsinglehunk(hunklines): | ||||
| yield t | yield t | ||||
| return | return | ||||