Show More
@@ -1619,27 +1619,36 b' def diff(repo, node1=None, node2=None, m' | |||
|
1619 | 1619 | |
|
1620 | 1620 | def difflabel(func, *args, **kw): |
|
1621 | 1621 | '''yields 2-tuples of (output, label) based on the output of func()''' |
|
1622 | prefixes = [('diff', 'diff.diffline'), | |
|
1623 | ('copy', 'diff.extended'), | |
|
1624 | ('rename', 'diff.extended'), | |
|
1625 | ('old', 'diff.extended'), | |
|
1626 | ('new', 'diff.extended'), | |
|
1627 | ('deleted', 'diff.extended'), | |
|
1628 | ('---', 'diff.file_a'), | |
|
1629 |
('+++', 'diff.file_b') |
|
|
1630 |
|
|
|
1631 | ('-', 'diff.deleted'), | |
|
1632 | ('+', 'diff.inserted')] | |
|
1633 | ||
|
1622 | headprefixes = [('diff', 'diff.diffline'), | |
|
1623 | ('copy', 'diff.extended'), | |
|
1624 | ('rename', 'diff.extended'), | |
|
1625 | ('old', 'diff.extended'), | |
|
1626 | ('new', 'diff.extended'), | |
|
1627 | ('deleted', 'diff.extended'), | |
|
1628 | ('---', 'diff.file_a'), | |
|
1629 | ('+++', 'diff.file_b')] | |
|
1630 | textprefixes = [('@', 'diff.hunk'), | |
|
1631 | ('-', 'diff.deleted'), | |
|
1632 | ('+', 'diff.inserted')] | |
|
1633 | head = False | |
|
1634 | 1634 | for chunk in func(*args, **kw): |
|
1635 | 1635 | lines = chunk.split('\n') |
|
1636 | 1636 | for i, line in enumerate(lines): |
|
1637 | 1637 | if i != 0: |
|
1638 | 1638 | yield ('\n', '') |
|
1639 | if head: | |
|
1640 | if line.startswith('@'): | |
|
1641 | head = False | |
|
1642 | else: | |
|
1643 | if line and not line[0] in ' +-@': | |
|
1644 | head = True | |
|
1639 | 1645 | stripline = line |
|
1640 | if line and line[0] in '+-': | |
|
1646 | if not head and line and line[0] in '+-': | |
|
1641 | 1647 | # highlight trailing whitespace, but only in changed lines |
|
1642 | 1648 | stripline = line.rstrip() |
|
1649 | prefixes = textprefixes | |
|
1650 | if head: | |
|
1651 | prefixes = headprefixes | |
|
1643 | 1652 | for prefix, label in prefixes: |
|
1644 | 1653 | if stripline.startswith(prefix): |
|
1645 | 1654 | yield (stripline, label) |
General Comments 0
You need to be logged in to leave comments.
Login now