[PATCH 3 of 6] revset.bisected: add new 'range' range to the bisect keyword

Yann E. MORIN yann.morin.1998 at anciens.enib.fr
Sat Sep 17 15:27:31 CDT 2011


 mercurial/revset.py |  32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)


# HG changeset patch
# User "Yann E. MORIN" <yann.morin.1998 at anciens.enib.fr>
# Date 1316273614 -7200
# Node ID b38b65fb3830507e0070f5110c066ee48aaf26e9
# Parent  ad4f959d88de6025bfcc2df5cf151c2e24a7ce6a
revset.bisected: add new 'range' range to the bisect keyword

The 'range' set is made of all changesets that make the bisection
range, that is
 - csets that are ancestors of bad csets and descendants of good csets
 or
 - csets that are ancestors of good csets and descendants of bad csets

That is, equivalent of:
  bisected(good)::bisected(bad) | bisected(bad)::bisected(good)

Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at anciens.enib.fr>

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -237,14 +237,42 @@
 
 def bisected(repo, subset, x):
     """``bisected(string)``
-    Changesets marked in the specified bisect state (good, bad, skip).
+    Changesets marked in the specified bisect state (``good``, ``bad``,
+    ``skip``), or any of the meta-states:
+
+    - ``range``    : all csets taking part in the bisection
     """
     state = getstring(x, _("bisect requires a string")).lower()
     bisectstate = hbisect.load_state(repo)
+
     if state in ('good', 'bad', 'skip'):
         marked = set(repo.changelog.rev(n) for n in bisectstate[state])
     else:
-        raise error.ParseError(_('invalid bisect state'))
+        # Build sets of good, bad, and skipped csets
+        goods = set(repo.changelog.rev(n) for n in bisectstate['good'])
+        bads  = set(repo.changelog.rev(n) for n in bisectstate['bad'])
+        skips = set(repo.changelog.rev(n) for n in bisectstate['skip'])
+        # Build ancestors and descendants of good csets
+        ga = goods.copy()
+        gd = goods.copy()
+        for g in goods:
+            ga |= set(repo.changelog.ancestors(g))
+            gd |= set(repo.changelog.descendants(g))
+        # Build ancestors and descendants of bad csets
+        ba = bads.copy()
+        bd = bads.copy()
+        for b in bads:
+            ba |= set(repo.changelog.ancestors(b))
+            bd |= set(repo.changelog.descendants(b))
+        # Build the range of the bisection (good::bad|bad::good)
+        range = set(c for c in ba if c in gd) | set(c for c in ga if c in bd)
+
+        if state == 'range':
+            marked = [c for c in range]
+
+        else:
+            raise error.ParseError(_('invalid bisect state'))
+
     return [r for r in subset if r in marked]
 
 def bookmark(repo, subset, x):


More information about the Mercurial-devel mailing list