[PATCH 6 of 6 RFC] color: add special case handling for default template labels
Sean Farley
sean.michael.farley at gmail.com
Mon Dec 24 01:03:13 CST 2012
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1356329669 21600
# Node ID eea4451a32d34299a8a4107d1a1ea0c977848858
# Parent 414aafdbce3cffe24b69d652055f443d9cad9f68
color: add special case handling for default template labels
diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -404,10 +404,26 @@
thing = templater.stringify(thing)
sym = extractsymbol(templater._flatten(args[0]))
default_label = _labels.get(sym, '')
+ # special case handling
+ if 'changeset' in default_label and thing in repo:
+ default_label += ' changeset.' + repo[thing].phasestr()
+
+ if 'file' in default_label:
+ ctx, revcache = mapping['ctx'], mapping['revcache']
+ if 'files' not in revcache:
+ revcache['files'] = repo.status(ctx.p1().node(), ctx.node())[:3]
+
+ if thing in revcache['files'][0]:
+ default_label += ' status.modified'
+ elif thing in revcache['files'][1]:
+ default_label += ' status.added'
+ elif thing in revcache['files'][2]:
+ default_label += ' status.removed'
+
if default_label:
label = default_label + ' ' + label
return repo.ui.label(thing, label)
More information about the Mercurial-devel
mailing list