##// END OF EJS Templates
color: labeled text should be passed to ui.write() as ui.labeled...
Steve Borho -
r11302:e1dde736 default
parent child Browse files
Show More
@@ -150,8 +150,10 b' def churn(ui, repo, *pats, **opts):'
150 if opts.get('diffstat'):
150 if opts.get('diffstat'):
151 width -= 15
151 width -= 15
152 def format(name, (added, removed)):
152 def format(name, (added, removed)):
153 return "%s %15s %s%s\n" % (pad(name, maxname),
153 return "%s %15s %s%s\n" % (ui.label(pad(name, maxname),
154 '+%d/-%d' % (added, removed),
154 'ui.plain'),
155 ui.label('+%d/-%d' % (added, removed),
156 'ui.plain'),
155 ui.label('+' * charnum(added),
157 ui.label('+' * charnum(added),
156 'diffstat.inserted'),
158 'diffstat.inserted'),
157 ui.label('-' * charnum(removed),
159 ui.label('-' * charnum(removed),
@@ -159,14 +161,14 b' def churn(ui, repo, *pats, **opts):'
159 else:
161 else:
160 width -= 6
162 width -= 6
161 def format(name, count):
163 def format(name, count):
162 return "%s %6d %s\n" % (pad(name, maxname), sum(count),
164 return ui.label("%s %6d %s\n" % (pad(name, maxname), sum(count),
163 '*' * charnum(sum(count)))
165 '*' * charnum(sum(count))), 'ui.plain')
164
166
165 def charnum(count):
167 def charnum(count):
166 return int(round(count * width / maxcount))
168 return int(round(count * width / maxcount))
167
169
168 for name, count in rate:
170 for name, count in rate:
169 ui.write(format(name, count))
171 ui.write(format(name, count), label='ui.labeled')
170
172
171
173
172 cmdtable = {
174 cmdtable = {
@@ -108,7 +108,9 b' from mercurial.i18n import _'
108 'status.ignored': 'black bold',
108 'status.ignored': 'black bold',
109 'status.modified': 'blue bold',
109 'status.modified': 'blue bold',
110 'status.removed': 'red bold',
110 'status.removed': 'red bold',
111 'status.unknown': 'magenta bold underline'}
111 'status.unknown': 'magenta bold underline',
112 'ui.labeled': 'none',
113 'ui.plain': 'none'}
112
114
113
115
114 def render_effects(text, effects):
116 def render_effects(text, effects):
@@ -142,6 +144,8 b' def configstyles(ui):'
142
144
143 _buffers = None
145 _buffers = None
144 def style(msg, label):
146 def style(msg, label):
147 if label in ('ui.plain', 'ui.labeled'):
148 return msg
145 effects = []
149 effects = []
146 for l in label.split():
150 for l in label.split():
147 s = _styles.get(l, '')
151 s = _styles.get(l, '')
@@ -2145,17 +2145,17 b' def guard(ui, repo, *args, **opts):'
2145 '''
2145 '''
2146 def status(idx):
2146 def status(idx):
2147 guards = q.series_guards[idx] or ['unguarded']
2147 guards = q.series_guards[idx] or ['unguarded']
2148 ui.write('%s: ' % ui.label(q.series[idx], 'qguard.patch'))
2148 out = ['%s: ' % ui.label(q.series[idx], 'qguard.patch')]
2149 for i, guard in enumerate(guards):
2149 for i, guard in enumerate(guards):
2150 if guard.startswith('+'):
2150 if guard.startswith('+'):
2151 ui.write(guard, label='qguard.positive')
2151 out.append(ui.label(guard, 'qguard.positive'))
2152 elif guard.startswith('-'):
2152 elif guard.startswith('-'):
2153 ui.write(guard, label='qguard.negative')
2153 out.append(ui.label(guard, 'qguard.negative'))
2154 else:
2154 else:
2155 ui.write(guard, label='qguard.unguarded')
2155 out.append(ui.label(guard, 'qguard.unguarded'))
2156 if i != len(guards) - 1:
2156 if i != len(guards) - 1:
2157 ui.write(' ')
2157 out.append(ui.label(' ', 'ui.plain'))
2158 ui.write('\n')
2158 ui.write(''.join(out) + '\n', label='ui.labeled')
2159 q = repo.mq
2159 q = repo.mq
2160 patch = None
2160 patch = None
2161 args = list(args)
2161 args = list(args)
@@ -2799,7 +2799,8 b' def summary(orig, ui, repo, *args, **kwa'
2799 if u:
2799 if u:
2800 m.append(ui.label(_("%d unapplied"), 'qseries.unapplied') % u)
2800 m.append(ui.label(_("%d unapplied"), 'qseries.unapplied') % u)
2801 if m:
2801 if m:
2802 ui.write("mq: %s\n" % ', '.join(m))
2802 ui.write("mq: ")
2803 ui.write(', '.join(m) + '\n', label='ui.labeled')
2803 else:
2804 else:
2804 ui.note(_("mq: (empty queue)\n"))
2805 ui.note(_("mq: (empty queue)\n"))
2805 return r
2806 return r
@@ -3280,22 +3280,22 b' def summary(ui, repo, **opts):'
3280 cleanworkdir = False
3280 cleanworkdir = False
3281
3281
3282 if len(parents) > 1:
3282 if len(parents) > 1:
3283 t += _(' (merge)')
3283 t += ui.label(_(' (merge)'), 'ui.plain')
3284 elif branch != parents[0].branch():
3284 elif branch != parents[0].branch():
3285 t += _(' (new branch)')
3285 t += ui.label(_(' (new branch)'), 'ui.plain')
3286 elif (parents[0].extra().get('close') and
3286 elif (parents[0].extra().get('close') and
3287 pnode in repo.branchheads(branch, closed=True)):
3287 pnode in repo.branchheads(branch, closed=True)):
3288 t += _(' (head closed)')
3288 t += ui.label(_(' (head closed)'), 'ui.plain')
3289 elif (not st[0] and not st[1] and not st[2] and not st[7]):
3289 elif (not st[0] and not st[1] and not st[2] and not st[7]):
3290 t += _(' (clean)')
3290 t += ui.label(_(' (clean)'), 'ui.plain')
3291 cleanworkdir = True
3291 cleanworkdir = True
3292 elif pnode not in bheads:
3292 elif pnode not in bheads:
3293 t += _(' (new branch head)')
3293 t += ui.label(_(' (new branch head)'), 'ui.plain')
3294
3294
3295 if cleanworkdir:
3295 if cleanworkdir:
3296 ui.status(_('commit: %s\n') % t.strip())
3296 ui.status(_('commit: %s\n') % t.strip(), label='ui.labeled')
3297 else:
3297 else:
3298 ui.write(_('commit: %s\n') % t.strip())
3298 ui.write(_('commit: %s\n') % t.strip(), label='ui.labeled')
3299
3299
3300 # all ancestors of branch heads - all ancestors of parent = new csets
3300 # all ancestors of branch heads - all ancestors of parent = new csets
3301 new = [0] * len(repo)
3301 new = [0] * len(repo)
@@ -546,5 +546,9 b' class ui(object):'
546
546
547 ui.write(s, 'label') is equivalent to
547 ui.write(s, 'label') is equivalent to
548 ui.write(ui.label(s, 'label')).
548 ui.write(ui.label(s, 'label')).
549
550 Callers of ui.label() should pass labeled text back to
551 ui.write() with a label of 'ui.labeled' so implementations know
552 that the text has already been escaped and marked up.
549 '''
553 '''
550 return msg
554 return msg
General Comments 0
You need to be logged in to leave comments. Login now