|
@@ -7,6 +7,14 @@ workspace or from stdin, with *side by side* and *auto pager* support. Requires
|
7
|
7
|
python (>= 2.5.0) and ``less``.
|
8
|
8
|
"""
|
9
|
9
|
|
|
10
|
+import sys
|
|
11
|
+import os
|
|
12
|
+import re
|
|
13
|
+import signal
|
|
14
|
+import subprocess
|
|
15
|
+import select
|
|
16
|
+import difflib
|
|
17
|
+
|
10
|
18
|
META_INFO = {
|
11
|
19
|
'version' : '0.9.8',
|
12
|
20
|
'license' : 'BSD-3',
|
|
@@ -18,8 +26,6 @@ META_INFO = {
|
18
|
26
|
'stdin, with side by side and auto pager support')
|
19
|
27
|
}
|
20
|
28
|
|
21
|
|
-import sys
|
22
|
|
-
|
23
|
29
|
if sys.hexversion < 0x02050000:
|
24
|
30
|
raise SystemExit("*** Requires python >= 2.5.0") # pragma: no cover
|
25
|
31
|
|
|
@@ -27,22 +33,14 @@ if sys.hexversion < 0x02050000:
|
27
|
33
|
try:
|
28
|
34
|
next
|
29
|
35
|
except NameError:
|
30
|
|
- def next(obj): return obj.next()
|
31
|
|
-
|
32
|
|
-import os
|
33
|
|
-import re
|
34
|
|
-import signal
|
35
|
|
-import subprocess
|
36
|
|
-import select
|
37
|
|
-import difflib
|
38
|
|
-
|
|
36
|
+ def next(obj):
|
|
37
|
+ return obj.next()
|
39
|
38
|
|
40
|
39
|
try:
|
41
|
40
|
unicode
|
42
|
41
|
except NameError:
|
43
|
42
|
unicode = str
|
44
|
43
|
|
45
|
|
-
|
46
|
44
|
COLORS = {
|
47
|
45
|
'reset' : '\x1b[0m',
|
48
|
46
|
'underline' : '\x1b[4m',
|
|
@@ -65,19 +63,19 @@ COLORS = {
|
65
|
63
|
# Keys for revision control probe, diff and log with diff
|
66
|
64
|
VCS_INFO = {
|
67
|
65
|
'Git': {
|
68
|
|
- 'probe' : ['git', 'rev-parse'],
|
69
|
|
- 'diff' : ['git', 'diff', '--no-ext-diff'],
|
70
|
|
- 'log' : ['git', 'log', '--patch'],
|
|
66
|
+ 'probe': ['git', 'rev-parse'],
|
|
67
|
+ 'diff': ['git', 'diff', '--no-ext-diff'],
|
|
68
|
+ 'log': ['git', 'log', '--patch'],
|
71
|
69
|
},
|
72
|
70
|
'Mercurial': {
|
73
|
|
- 'probe' : ['hg', 'summary'],
|
74
|
|
- 'diff' : ['hg', 'diff'],
|
75
|
|
- 'log' : ['hg', 'log', '--patch'],
|
|
71
|
+ 'probe': ['hg', 'summary'],
|
|
72
|
+ 'diff': ['hg', 'diff'],
|
|
73
|
+ 'log': ['hg', 'log', '--patch'],
|
76
|
74
|
},
|
77
|
75
|
'Svn': {
|
78
|
|
- 'probe' : ['svn', 'info'],
|
79
|
|
- 'diff' : ['svn', 'diff'],
|
80
|
|
- 'log' : ['svn', 'log', '--diff', '--use-merge-history'],
|
|
76
|
+ 'probe': ['svn', 'info'],
|
|
77
|
+ 'diff': ['svn', 'diff'],
|
|
78
|
+ 'log': ['svn', 'log', '--diff', '--use-merge-history'],
|
81
|
79
|
},
|
82
|
80
|
}
|
83
|
81
|
|
|
@@ -304,8 +302,8 @@ class DiffParser(object):
|
304
|
302
|
return
|
305
|
303
|
|
306
|
304
|
for n in range(size):
|
307
|
|
- if header[n].startswith('--- ') and (n < size - 1) and \
|
308
|
|
- header[n+1].startswith('+++ '):
|
|
305
|
+ if (header[n].startswith('--- ') and (n < size - 1) and
|
|
306
|
+ header[n + 1].startswith('+++ ')):
|
309
|
307
|
self._type = 'unified'
|
310
|
308
|
self._stream = stream
|
311
|
309
|
break
|
|
@@ -698,7 +696,9 @@ def terminal_size():
|
698
|
696
|
"""
|
699
|
697
|
width, height = None, None
|
700
|
698
|
try:
|
701
|
|
- import struct, fcntl, termios
|
|
699
|
+ import struct
|
|
700
|
+ import fcntl
|
|
701
|
+ import termios
|
702
|
702
|
s = struct.pack('HHHH', 0, 0, 0, 0)
|
703
|
703
|
x = fcntl.ioctl(1, termios.TIOCGWINSZ, s)
|
704
|
704
|
height, width = struct.unpack('HHHH', x)[0:2]
|