Show More
@@ -103,6 +103,7 b' disable color.' | |||||
103 | import os |
|
103 | import os | |
104 |
|
104 | |||
105 | from mercurial import commands, dispatch, extensions, ui as uimod, util |
|
105 | from mercurial import commands, dispatch, extensions, ui as uimod, util | |
|
106 | from mercurial import templater | |||
106 | from mercurial.i18n import _ |
|
107 | from mercurial.i18n import _ | |
107 |
|
108 | |||
108 | testedwith = 'internal' |
|
109 | testedwith = 'internal' | |
@@ -354,6 +355,28 b' class colorui(uimod.ui):' | |||||
354 | for s in msg.split('\n')]) |
|
355 | for s in msg.split('\n')]) | |
355 | return msg |
|
356 | return msg | |
356 |
|
357 | |||
|
358 | def templatelabel(context, mapping, args): | |||
|
359 | if len(args) != 2: | |||
|
360 | # i18n: "label" is a keyword | |||
|
361 | raise error.ParseError(_("label expects two arguments")) | |||
|
362 | ||||
|
363 | thing = templater.stringify(args[1][0](context, mapping, args[1][1])) | |||
|
364 | thing = templater.runtemplate(context, mapping, | |||
|
365 | templater.compiletemplate(thing, context)) | |||
|
366 | ||||
|
367 | # apparently, repo could be a string that is the favicon? | |||
|
368 | repo = mapping.get('repo', '') | |||
|
369 | if isinstance(repo, str): | |||
|
370 | return thing | |||
|
371 | ||||
|
372 | label = templater.stringify(args[0][0](context, mapping, args[0][1])) | |||
|
373 | label = templater.runtemplate(context, mapping, | |||
|
374 | templater.compiletemplate(label, context)) | |||
|
375 | ||||
|
376 | thing = templater.stringify(thing) | |||
|
377 | label = templater.stringify(label) | |||
|
378 | ||||
|
379 | return repo.ui.label(thing, label) | |||
357 |
|
380 | |||
358 | def uisetup(ui): |
|
381 | def uisetup(ui): | |
359 | global _terminfo_params |
|
382 | global _terminfo_params | |
@@ -370,6 +393,7 b' def uisetup(ui):' | |||||
370 | configstyles(ui_) |
|
393 | configstyles(ui_) | |
371 | return orig(ui_, opts, cmd, cmdfunc) |
|
394 | return orig(ui_, opts, cmd, cmdfunc) | |
372 | extensions.wrapfunction(dispatch, '_runcommand', colorcmd) |
|
395 | extensions.wrapfunction(dispatch, '_runcommand', colorcmd) | |
|
396 | templater.funcs['label'] = templatelabel | |||
373 |
|
397 | |||
374 | def extsetup(ui): |
|
398 | def extsetup(ui): | |
375 | commands.globalopts.append( |
|
399 | commands.globalopts.append( |
General Comments 0
You need to be logged in to leave comments.
Login now