Show More
@@ -90,9 +90,9 b' from mercurial.i18n import _' | |||||
90 | 'cyan_background': 46, |
|
90 | 'cyan_background': 46, | |
91 | 'white_background': 47} |
|
91 | 'white_background': 47} | |
92 |
|
92 | |||
93 |
def render_effects(text, |
|
93 | def render_effects(text, effects): | |
94 | 'Wrap text in commands to turn on each effect.' |
|
94 | 'Wrap text in commands to turn on each effect.' | |
95 |
start = [str(_effect_params[e]) for e in |
|
95 | start = [str(_effect_params[e]) for e in ['none'] + effects] | |
96 | start = '\033[' + ';'.join(start) + 'm' |
|
96 | start = '\033[' + ';'.join(start) + 'm' | |
97 | stop = '\033[' + str(_effect_params['none']) + 'm' |
|
97 | stop = '\033[' + str(_effect_params['none']) + 'm' | |
98 | return ''.join([start, text, stop]) |
|
98 | return ''.join([start, text, stop]) | |
@@ -120,7 +120,7 b' def colorstatus(orig, ui, repo, *pats, *' | |||||
120 | status = _status_abbreviations[lines_with_status[i][0]] |
|
120 | status = _status_abbreviations[lines_with_status[i][0]] | |
121 | effects = _status_effects[status] |
|
121 | effects = _status_effects[status] | |
122 | if effects: |
|
122 | if effects: | |
123 |
lines[i] = render_effects(lines[i], |
|
123 | lines[i] = render_effects(lines[i], effects) | |
124 | ui.write(lines[i] + delimiter) |
|
124 | ui.write(lines[i] + delimiter) | |
125 | return retval |
|
125 | return retval | |
126 |
|
126 | |||
@@ -133,14 +133,14 b' def colorstatus(orig, ui, repo, *pats, *' | |||||
133 | 'C': 'clean', |
|
133 | 'C': 'clean', | |
134 | ' ': 'copied', } |
|
134 | ' ': 'copied', } | |
135 |
|
135 | |||
136 |
_status_effects = { 'modified': |
|
136 | _status_effects = { 'modified': ['blue', 'bold'], | |
137 |
'added': |
|
137 | 'added': ['green', 'bold'], | |
138 |
'removed': |
|
138 | 'removed': ['red', 'bold'], | |
139 |
'deleted': |
|
139 | 'deleted': ['cyan', 'bold', 'underline'], | |
140 |
'unknown': |
|
140 | 'unknown': ['magenta', 'bold', 'underline'], | |
141 |
'ignored': |
|
141 | 'ignored': ['black', 'bold'], | |
142 |
'clean': |
|
142 | 'clean': ['none'], | |
143 |
'copied': |
|
143 | 'copied': ['none'], } | |
144 |
|
144 | |||
145 | def colorqseries(orig, ui, repo, *dummy, **opts): |
|
145 | def colorqseries(orig, ui, repo, *dummy, **opts): | |
146 | '''run the qseries command with colored output''' |
|
146 | '''run the qseries command with colored output''' | |
@@ -162,12 +162,12 b' def colorqseries(orig, ui, repo, *dummy,' | |||||
162 | effects = _patch_effects['applied'] |
|
162 | effects = _patch_effects['applied'] | |
163 | else: |
|
163 | else: | |
164 | effects = _patch_effects['unapplied'] |
|
164 | effects = _patch_effects['unapplied'] | |
165 |
ui.write(render_effects(patch, |
|
165 | ui.write(render_effects(patch, effects) + '\n') | |
166 | return retval |
|
166 | return retval | |
167 |
|
167 | |||
168 |
_patch_effects = { 'applied': |
|
168 | _patch_effects = { 'applied': ['blue', 'bold', 'underline'], | |
169 |
'missing': |
|
169 | 'missing': ['red', 'bold'], | |
170 |
'unapplied': |
|
170 | 'unapplied': ['black', 'bold'], } | |
171 |
|
171 | |||
172 | def colorwrap(orig, s): |
|
172 | def colorwrap(orig, s): | |
173 | '''wrap ui.write for colored diff output''' |
|
173 | '''wrap ui.write for colored diff output''' | |
@@ -179,11 +179,11 b' def colorwrap(orig, s):' | |||||
179 | stripline = line.rstrip() |
|
179 | stripline = line.rstrip() | |
180 | for prefix, style in _diff_prefixes: |
|
180 | for prefix, style in _diff_prefixes: | |
181 | if stripline.startswith(prefix): |
|
181 | if stripline.startswith(prefix): | |
182 |
lines[i] = render_effects(stripline, |
|
182 | lines[i] = render_effects(stripline, _diff_effects[style]) | |
183 | break |
|
183 | break | |
184 | if line != stripline: |
|
184 | if line != stripline: | |
185 | lines[i] += render_effects( |
|
185 | lines[i] += render_effects( | |
186 |
line[len(stripline):], |
|
186 | line[len(stripline):], _diff_effects['trailingwhitespace']) | |
187 | orig('\n'.join(lines)) |
|
187 | orig('\n'.join(lines)) | |
188 |
|
188 | |||
189 | def colorshowpatch(orig, self, node): |
|
189 | def colorshowpatch(orig, self, node): | |
@@ -214,15 +214,15 b' def colordiff(orig, ui, repo, *pats, **o' | |||||
214 | ('-', 'deleted'), |
|
214 | ('-', 'deleted'), | |
215 | ('+', 'inserted')] |
|
215 | ('+', 'inserted')] | |
216 |
|
216 | |||
217 |
_diff_effects = {'diffline': |
|
217 | _diff_effects = {'diffline': ['bold',], | |
218 |
'extended': |
|
218 | 'extended': ['cyan', 'bold'], | |
219 |
'file_a': |
|
219 | 'file_a': ['red', 'bold'], | |
220 |
'file_b': |
|
220 | 'file_b': ['green', 'bold'], | |
221 |
'hunk': |
|
221 | 'hunk': ['magenta',], | |
222 |
'deleted': |
|
222 | 'deleted': ['red',], | |
223 |
'inserted': |
|
223 | 'inserted': ['green',], | |
224 |
'changed': |
|
224 | 'changed': ['white',], | |
225 |
'trailingwhitespace': |
|
225 | 'trailingwhitespace': ['bold', 'red_background'],} | |
226 |
|
226 | |||
227 | def uisetup(ui): |
|
227 | def uisetup(ui): | |
228 | '''Initialize the extension.''' |
|
228 | '''Initialize the extension.''' |
General Comments 0
You need to be logged in to leave comments.
Login now