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