Show More
@@ -49,7 +49,7 b' qseries.unapplied = black bold' | |||||
49 | qseries.missing = red bold |
|
49 | qseries.missing = red bold | |
50 | ''' |
|
50 | ''' | |
51 |
|
51 | |||
52 | import re, sys |
|
52 | import os, re, sys | |
53 |
|
53 | |||
54 | from mercurial import commands, extensions |
|
54 | from mercurial import commands, extensions | |
55 | from mercurial.i18n import _ |
|
55 | from mercurial.i18n import _ | |
@@ -113,7 +113,7 b' def colorstatus(orig, ui, repo, *pats, *' | |||||
113 | effects = _status_effects[status] |
|
113 | effects = _status_effects[status] | |
114 | if effects: |
|
114 | if effects: | |
115 | lines[i] = render_effects(lines[i], *effects) |
|
115 | lines[i] = render_effects(lines[i], *effects) | |
116 |
|
|
116 | ui.write(lines[i] + delimiter) | |
117 | return retval |
|
117 | return retval | |
118 |
|
118 | |||
119 | _status_abbreviations = { 'M': 'modified', |
|
119 | _status_abbreviations = { 'M': 'modified', | |
@@ -154,7 +154,7 b' def colorqseries(orig, ui, repo, *dummy,' | |||||
154 | effects = _patch_effects['applied'] |
|
154 | effects = _patch_effects['applied'] | |
155 | else: |
|
155 | else: | |
156 | effects = _patch_effects['unapplied'] |
|
156 | effects = _patch_effects['unapplied'] | |
157 |
|
|
157 | ui.write(render_effects(patch, *effects) + '\n') | |
158 | return retval |
|
158 | return retval | |
159 |
|
159 | |||
160 | _patch_effects = { 'applied': ('blue', 'bold', 'underline'), |
|
160 | _patch_effects = { 'applied': ('blue', 'bold', 'underline'), | |
@@ -171,13 +171,22 b' def uisetup(ui):' | |||||
171 |
|
171 | |||
172 | def _setupcmd(ui, cmd, table, func, effectsmap): |
|
172 | def _setupcmd(ui, cmd, table, func, effectsmap): | |
173 | '''patch in command to command table and load effect map''' |
|
173 | '''patch in command to command table and load effect map''' | |
174 |
def nocolor(orig, *args, ** |
|
174 | def nocolor(orig, *args, **opts): | |
175 | if kwargs['no_color']: |
|
175 | ||
176 | return orig(*args, **kwargs) |
|
176 | if (opts['no_color'] or opts['color'] == 'never' or | |
177 | return func(orig, *args, **kwargs) |
|
177 | (opts['color'] == 'auto' and (os.environ.get('TERM') == 'dumb' | |
|
178 | or not sys.__stdout__.isatty()))): | |||
|
179 | return orig(*args, **opts) | |||
|
180 | ||||
|
181 | if func is not None: | |||
|
182 | return func(orig, *args, **opts) | |||
|
183 | return orig(*args, **opts) | |||
178 |
|
184 | |||
179 | entry = extensions.wrapcommand(table, cmd, nocolor) |
|
185 | entry = extensions.wrapcommand(table, cmd, nocolor) | |
180 | entry[1].append(('', 'no-color', None, _("don't colorize output"))) |
|
186 | entry[1].extend([ | |
|
187 | ('', 'color', 'auto', _("when to colorize (always, auto, or never)")), | |||
|
188 | ('', 'no-color', None, _("don't colorize output")), | |||
|
189 | ]) | |||
181 |
|
190 | |||
182 | for status in effectsmap: |
|
191 | for status in effectsmap: | |
183 | effects = ui.config('color', cmd + '.' + status) |
|
192 | effects = ui.config('color', cmd + '.' + status) |
General Comments 0
You need to be logged in to leave comments.
Login now