|
@@ -1,114 +0,0 @@
|
1
|
|
-diff --git a/src/cdiff.py b/src/cdiff.py
|
2
|
|
-index 1db7807..c17032f 100755
|
3
|
|
---- a/src/cdiff.py
|
4
|
|
-+++ b/src/cdiff.py
|
5
|
|
-@@ -17,7 +17,7 @@ COLORS = {
|
6
|
|
- 'lightred' : '\x1b[1;31m',
|
7
|
|
- 'lightgreen' : '\x1b[1;32m',
|
8
|
|
- 'lightyellow' : '\x1b[1;33m',
|
9
|
|
-- 'lightblue ' : '\x1b[1;34m',
|
10
|
|
-+ 'lightblue' : '\x1b[1;34m',
|
11
|
|
- 'lightmagenta' : '\x1b[1;35m',
|
12
|
|
- 'lightcyan' : '\x1b[1;36m',
|
13
|
|
- }
|
14
|
|
-@@ -31,23 +31,13 @@ def colorize(text, start_color, end_color='reset'):
|
15
|
|
-
|
16
|
|
- class Hunk(object):
|
17
|
|
-
|
18
|
|
-- def __init__(self, hunk_header, old_addr, old_offset, new_addr, new_offset):
|
19
|
|
-+ def __init__(self, hunk_header):
|
20
|
|
- self._hunk_header = hunk_header
|
21
|
|
-- self._old_addr = old_addr
|
22
|
|
-- self._old_offset = old_offset
|
23
|
|
-- self._new_addr = new_addr
|
24
|
|
-- self._new_offset = new_offset
|
25
|
|
- self._hunk_list = [] # 2-element group (attr, line)
|
26
|
|
-
|
27
|
|
- def get_header(self):
|
28
|
|
- return self._hunk_header
|
29
|
|
-
|
30
|
|
-- def get_old_addr(self):
|
31
|
|
-- return (self._old_addr, self._old_offset)
|
32
|
|
--
|
33
|
|
-- def get_new_addr(self):
|
34
|
|
-- return (self._new_addr, self._new_offset)
|
35
|
|
--
|
36
|
|
- def append(self, attr, line):
|
37
|
|
- """attr: '-': old, '+': new, ' ': common"""
|
38
|
|
- self._hunk_list.append((attr, line))
|
39
|
|
-@@ -117,10 +107,10 @@ class Diff(object):
|
40
|
|
- line = from_info[1].strip('\x00\x01')
|
41
|
|
- out.append(self._markup_old(line))
|
42
|
|
- else:
|
43
|
|
-- out.append(self._markup_old('-' +
|
44
|
|
-- self._markup_old_mix(from_info[1])))
|
45
|
|
-- out.append(self._markup_new('+' +
|
46
|
|
-- self._markup_new_mix(to_info[1])))
|
47
|
|
-+ out.append(self._markup_old('-') +
|
48
|
|
-+ self._markup_old_mix(from_info[1]))
|
49
|
|
-+ out.append(self._markup_new('+') +
|
50
|
|
-+ self._markup_new_mix(to_info[1]))
|
51
|
|
- else:
|
52
|
|
- out.append(self._markup_common(' ' + from_info[1]))
|
53
|
|
- return ''.join(out)
|
54
|
|
-@@ -139,7 +129,7 @@ class Diff(object):
|
55
|
|
- return colorize(line, 'yellow')
|
56
|
|
-
|
57
|
|
- def _markup_hunk_header(self, line):
|
58
|
|
-- return colorize(line, 'blue')
|
59
|
|
-+ return colorize(line, 'lightblue')
|
60
|
|
-
|
61
|
|
- def _markup_common(self, line):
|
62
|
|
- return colorize(line, 'reset')
|
63
|
|
-@@ -150,18 +140,20 @@ class Diff(object):
|
64
|
|
- def _markup_new(self, line):
|
65
|
|
- return colorize(line, 'lightgreen')
|
66
|
|
-
|
67
|
|
-- def _markup_mix(self, line, end_color):
|
68
|
|
-- line = line.replace('\x00-', ansi_code('red'))
|
69
|
|
-- line = line.replace('\x00+', ansi_code('green'))
|
70
|
|
-- line = line.replace('\x00^', ansi_code('lightyellow'))
|
71
|
|
-- line = line.replace('\x01', ansi_code(end_color))
|
72
|
|
-- return colorize(line, end_color)
|
73
|
|
-+ def _markup_mix(self, line, base_color, del_color, add_color, chg_color):
|
74
|
|
-+ line = line.replace('\x00-', ansi_code(del_color))
|
75
|
|
-+ line = line.replace('\x00+', ansi_code(add_color))
|
76
|
|
-+ line = line.replace('\x00^', ansi_code(chg_color))
|
77
|
|
-+ line = line.replace('\x01', ansi_code(base_color))
|
78
|
|
-+ return colorize(line, base_color)
|
79
|
|
-
|
80
|
|
- def _markup_old_mix(self, line):
|
81
|
|
-- return self._markup_mix(line, 'red')
|
82
|
|
-+ return self._markup_mix(line, 'cyan', 'lightred', 'lightgreen',
|
83
|
|
-+ 'yellow')
|
84
|
|
-
|
85
|
|
- def _markup_new_mix(self, line):
|
86
|
|
-- return self._markup_mix(line, 'green')
|
87
|
|
-+ return self._markup_mix(line, 'lightcyan', 'lightred', 'lightgreen',
|
88
|
|
-+ 'lightyellow')
|
89
|
|
-
|
90
|
|
-
|
91
|
|
- class Udiff(Diff):
|
92
|
|
-@@ -278,21 +270,7 @@ class DiffParser(object):
|
93
|
|
- hunks.append(hunk)
|
94
|
|
- hunk = None
|
95
|
|
- else:
|
96
|
|
-- # @@ -3,7 +3,6 @@
|
97
|
|
-- hunk_header = stream.pop(0)
|
98
|
|
--
|
99
|
|
-- addr_info = hunk_header.split()[1]
|
100
|
|
-- assert addr_info.startswith('-')
|
101
|
|
-- old_addr = addr_info.split(',')[0]
|
102
|
|
-- old_offset = addr_info.split(',')[1]
|
103
|
|
--
|
104
|
|
-- addr_info = hunk_header.split()[2]
|
105
|
|
-- assert addr_info.startswith('+')
|
106
|
|
-- new_addr = addr_info.split(',')[0]
|
107
|
|
-- new_offset = addr_info.split(',')[1]
|
108
|
|
--
|
109
|
|
-- hunk = Hunk(hunk_header, old_addr, old_offset, new_addr,
|
110
|
|
-- new_offset)
|
111
|
|
-+ hunk = Hunk(stream.pop(0))
|
112
|
|
-
|
113
|
|
- elif Udiff.is_old(stream[0]) or Udiff.is_new(stream[0]) or \
|
114
|
|
- Udiff.is_common(stream[0]):
|