Mercurial > diff-colorize
comparison diff-colorize.py @ 2:9eda9139d627
Added support for hunk start markers (@@…@@). For these, we set the whole line in reverse video, in the same color we use for index lines.
author | Peter Hosey |
---|---|
date | Sun, 10 Aug 2008 23:29:08 -0700 |
parents | 44f86539d245 |
children | 10948e4fd070 |
comparison
equal
deleted
inserted
replaced
1:44f86539d245 | 2:9eda9139d627 |
---|---|
6 END_REVERSE_FORMAT = '\033[27m' | 6 END_REVERSE_FORMAT = '\033[27m' |
7 | 7 |
8 INDEX_COLOR = 32 | 8 INDEX_COLOR = 32 |
9 REMOVED_COLOR = 203 | 9 REMOVED_COLOR = 203 |
10 ADDED_COLOR = 2 | 10 ADDED_COLOR = 2 |
11 HUNK_START_COLOR = 32 | |
11 | 12 |
12 class OrderedDict(dict): | 13 class OrderedDict(dict): |
13 def __init__(self, input=None): | 14 def __init__(self, input=None): |
14 if input is None: | 15 if input is None: |
15 self.keys = [] | 16 self.keys = [] |
55 + '+' | 56 + '+' |
56 + END_REVERSE_FORMAT | 57 + END_REVERSE_FORMAT |
57 ) | 58 ) |
58 prefixes['Index: '] = COLOR_FORMAT % (INDEX_COLOR,) + 'Index: ' | 59 prefixes['Index: '] = COLOR_FORMAT % (INDEX_COLOR,) + 'Index: ' |
59 prefixes['diff --git '] = COLOR_FORMAT % (INDEX_COLOR,) + 'diff --git ' | 60 prefixes['diff --git '] = COLOR_FORMAT % (INDEX_COLOR,) + 'diff --git ' |
61 prefixes['@@'] = ( | |
62 COLOR_FORMAT % (HUNK_START_COLOR,) | |
63 + BEGIN_REVERSE_FORMAT | |
64 + '@@' | |
65 ) | |
60 | 66 |
61 import sys | 67 import sys |
62 import fileinput | 68 import fileinput |
63 | 69 |
64 for line in fileinput.input(): | 70 for line in fileinput.input(): |