[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
Fri Sep 23 19:23:55 CDT 2011


# HG changeset patch
# User "Yann E. MORIN" <yann.morin.1998 at anciens.enib.fr>
# Date 1316726929 -7200
# Node ID 43bf682e1fdf41f726ea5bc516c1c31c537874e5
# Parent  10e555d8856b6f89edc9e1dca10c83536cbe74c3
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 at anciens.enib.fr>

diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py
--- a/mercurial/hbisect.py
+++ b/mercurial/hbisect.py
@@ -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


More information about the Mercurial-devel mailing list