hbisect: add functions to return a label for a cset bisection status
Add two new functions that return a string containing the bisection status
of the node passed in parameter:
- .label(node): return a multi-char string representing the status of node
- .shortlabel(node): return a single-char string representing the status
of node, usually the initial of the label
bisection status .label() .shortlabel()
----------------------------------------------------------
good 'good' 'G'
good (implicit) 'good (implicit)' 'G'
bad 'bad' 'B'
bad (implicit) 'bad (implicit)' 'B'
skipped 'skip' 'S'
untested 'untested' 'U'
ignored 'ignored' 'I'
(others) None None
There is no point in returning 'range' or 'pruned', as these get covered
by another, more meaningful status in the table above.
In case the node is not being bisected, the functions return None to leave
it up to the caller to decide what to print (nothing, an empty space, or
whatever else suits).
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
--- a/mercurial/hbisect.py Sat Sep 24 01:32:50 2011 +0200
+++ b/mercurial/hbisect.py Thu Sep 22 23:28:49 2011 +0200
@@ -220,3 +220,32 @@
else:
raise error.ParseError(_('invalid bisect state'))
+
+def label(repo, node, short=False):
+ rev = repo.changelog.rev(node)
+
+ # Try explicit sets
+ if rev in get(repo, 'good'):
+ return _('good')
+ if rev in get(repo, 'bad'):
+ return _('bad')
+ if rev in get(repo, 'skip'):
+ return _('skipped')
+ if rev in get(repo, 'untested'):
+ return _('untested')
+ if rev in get(repo, 'ignored'):
+ return _('ignored')
+
+ # Try implicit sets
+ if rev in get(repo, 'goods'):
+ return _('good (implicit)')
+ if rev in get(repo, 'bads'):
+ return _('bad (implicit)')
+
+ return None
+
+def shortlabel(label):
+ if label:
+ return label[0].upper()
+
+ return None