[PATCH 2 of 4] hbisect: add functions to return a label for a cset bisection status

Yann E. MORIN yann.morin.1998 at anciens.enib.fr
Wed Sep 21 19:10:18 CDT 2011


# HG changeset patch
# User "Yann E. MORIN" <yann.morin.1998 at anciens.enib.fr>
# Date 1316375970 -7200
# Node ID 38490dd8eadf5c5e8b77ad2582328d6a4caf1f86
# Parent  85607e1e24e03e75410739cfee8465c3520ef0cd
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'          '+'
    bad                 'bad'           '-'
    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 at anciens.enib.fr>

diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py
--- a/mercurial/hbisect.py
+++ b/mercurial/hbisect.py
@@ -219,3 +219,40 @@
 
         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 == 'good' or label == 'good (implicit)':
+        return '+'
+    if label == 'bad' or label == 'bad (implicit)':
+        return '-'
+    if label == 'skipped':
+        return '<'
+    if label == 'untested':
+        return '?'
+    if label == 'ignored':
+        return '!'
+
+    return None


More information about the Mercurial-devel mailing list