changeset 15153:fa0a464e4ca5

hbisect: add two new revset descriptions: 'goods' and 'bads' This patch adds two new revset descriptions: - 'goods': the list of topologicaly-good csets: - if good csets are topologically before bad csets, yields '::good' - else, yields 'good::' - and conversely for 'bads' Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
date Sat, 24 Sep 2011 01:32:50 +0200
parents 0d4f6e843b05
children aa2e908c521e
files mercurial/hbisect.py mercurial/revset.py tests/test-bisect2.t
diffstat 3 files changed, 118 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hbisect.py	Tue Sep 20 15:21:27 2011 +0300
+++ b/mercurial/hbisect.py	Sat Sep 24 01:32:50 2011 +0200
@@ -158,9 +158,10 @@
     """
     Return a list of revision(s) that match the given status:
 
-    - ``good``, ``bad``, ``skip``: as the names imply
-    - ``range``              : all csets taking part in the bisection
-    - ``pruned``             : csets that are good, bad or skipped
+    - ``good``, ``bad``, ``skip``: csets explicitly marked as good/bad/skip
+    - ``goods``, ``bads``      : csets topologicaly good/bad
+    - ``range``              : csets taking part in the bisection
+    - ``pruned``             : csets that are goods, bads or skipped
     - ``untested``           : csets whose fate is yet unknown
     - ``ignored``            : csets ignored due to DAG topology
     """
@@ -178,16 +179,20 @@
         # that's because the bisection can go either way
         range = '( bisect(bad)::bisect(good) | bisect(good)::bisect(bad) )'
 
-        # 'pruned' is all csets whose fate is already known:
-        #   - a good ancestor and a good ascendant, or
-        #   - a bad ancestor and a bad descendant, or
-        #   - skipped
-        # But in case of irrelevant goods/bads, we also need to
-        # include them.
-        pg = 'bisect(good)::bisect(good)'   # Pruned goods
-        pb = 'bisect(bad)::bisect(bad)'     # Pruned bads
-        ps = 'bisect(skip)'                 # Pruned skipped
-        pruned = '( (%s) | (%s) | (%s) )' % (pg, pb, ps)
+        _t = [c.rev() for c in repo.set('bisect(good)::bisect(bad)')]
+        # The sets of topologically good or bad csets
+        if len(_t) == 0:
+            # Goods are topologically after bads
+            goods = 'bisect(good)::'    # Pruned good csets
+            bads  = '::bisect(bad)'     # Pruned bad csets
+        else:
+            # Goods are topologically before bads
+            goods = '::bisect(good)'    # Pruned good csets
+            bads  = 'bisect(bad)::'     # Pruned bad csets
+
+        # 'pruned' is all csets whose fate is already known: good, bad, skip
+        skips = 'bisect(skip)'                 # Pruned skipped csets
+        pruned = '( (%s) | (%s) | (%s) )' % (goods, bads, skips)
 
         # 'untested' is all cset that are- in 'range', but not in 'pruned'
         untested = '( (%s) - (%s) )' % (range, pruned)
@@ -208,6 +213,10 @@
             return [c.rev() for c in repo.set(untested)]
         elif status == 'ignored':
             return [c.rev() for c in repo.set(ignored)]
+        elif status == "goods":
+            return [c.rev() for c in repo.set(goods)]
+        elif status == "bads":
+            return [c.rev() for c in repo.set(bads)]
 
         else:
             raise error.ParseError(_('invalid bisect state'))
--- a/mercurial/revset.py	Tue Sep 20 15:21:27 2011 +0300
+++ b/mercurial/revset.py	Sat Sep 24 01:32:50 2011 +0200
@@ -237,13 +237,14 @@
 
 def bisect(repo, subset, x):
     """``bisect(string)``
-    Changesets marked in the specified bisect status (``good``, ``bad``,
-    ``skip``), or any of the meta-status:
+    Changesets marked in the specified bisect status:
 
-    - ``range``      : all csets taking part in the bisection
-    - ``pruned``     : csets that are good, bad or skipped
-    - ``untested``   : csets whose fate is yet unknown
-    - ``ignored``    : csets ignored due to DAG topology
+    - ``good``, ``bad``, ``skip``: csets explicitly marked as good/bad/skip
+    - ``goods``, ``bads``      : csets topologicaly good/bad
+    - ``range``              : csets taking part in the bisection
+    - ``pruned``             : csets that are goods, bads or skipped
+    - ``untested``           : csets whose fate is yet unknown
+    - ``ignored``            : csets ignored due to DAG topology
     """
     status = getstring(x, _("bisect requires a string")).lower()
     return [r for r in subset if r in hbisect.get(repo, status)]
--- a/tests/test-bisect2.t	Tue Sep 20 15:21:27 2011 +0300
+++ b/tests/test-bisect2.t	Sat Sep 24 01:32:50 2011 +0200
@@ -322,9 +322,26 @@
   15:857b178a7cf3
   16:609d82a7ebae
   17:228c06deef46
+  18:d42e18c7bc9b
   $ hg log -q -r 'bisect(untested)'
   11:82ca6f06eccd
   12:9f259202bbe7
+  $ hg log -q -r 'bisect(goods)'
+  0:33b1f9bc8bc5
+  1:4ca5088da217
+  2:051e12f87bf1
+  3:0950834f0a9c
+  4:5c668c22234f
+  5:385a529b6670
+  6:a214d5d3811a
+  8:dab8161ac8fc
+  $ hg log -q -r 'bisect(bads)'
+  9:3c77083deb4a
+  10:429fcd26f52d
+  15:857b178a7cf3
+  16:609d82a7ebae
+  17:228c06deef46
+  18:d42e18c7bc9b
 
 complex bisect test 2  # first good rev is 13
 
@@ -337,6 +354,7 @@
   Testing changeset 10:429fcd26f52d (13 changesets remaining, ~3 tests)
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
   1:4ca5088da217
   6:a214d5d3811a
   18:d42e18c7bc9b
@@ -344,6 +362,7 @@
   Testing changeset 12:9f259202bbe7 (5 changesets remaining, ~2 tests)
   3 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
   1:4ca5088da217
   2:051e12f87bf1
   3:0950834f0a9c
@@ -396,8 +415,10 @@
   Testing changeset 6:a214d5d3811a (13 changesets remaining, ~3 tests)
   2 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
   1:4ca5088da217
   16:609d82a7ebae
+  17:228c06deef46
   $ hg bisect -g      # -> update to rev 13
   Testing changeset 13:b0a32c86eb31 (8 changesets remaining, ~3 tests)
   3 files updated, 0 files merged, 1 files removed, 0 files unresolved
@@ -408,6 +429,7 @@
   Testing changeset 12:9f259202bbe7 (8 changesets remaining, ~3 tests)
   3 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
   1:4ca5088da217
   2:051e12f87bf1
   3:0950834f0a9c
@@ -417,6 +439,7 @@
   10:429fcd26f52d
   13:b0a32c86eb31
   16:609d82a7ebae
+  17:228c06deef46
   $ hg bisect -g      # -> update to rev 9
   Testing changeset 9:3c77083deb4a (5 changesets remaining, ~2 tests)
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
@@ -484,6 +507,13 @@
   Testing changeset 15:857b178a7cf3 (3 changesets remaining, ~1 tests)
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
+  1:4ca5088da217
+  2:051e12f87bf1
+  3:0950834f0a9c
+  4:5c668c22234f
+  5:385a529b6670
+  6:a214d5d3811a
   8:dab8161ac8fc
   9:3c77083deb4a
   10:429fcd26f52d
@@ -495,6 +525,13 @@
   Testing changeset 16:609d82a7ebae (3 changesets remaining, ~1 tests)
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
+  1:4ca5088da217
+  2:051e12f87bf1
+  3:0950834f0a9c
+  4:5c668c22234f
+  5:385a529b6670
+  6:a214d5d3811a
   8:dab8161ac8fc
   9:3c77083deb4a
   10:429fcd26f52d
@@ -533,6 +570,13 @@
   16:609d82a7ebae
   17:228c06deef46
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
+  1:4ca5088da217
+  2:051e12f87bf1
+  3:0950834f0a9c
+  4:5c668c22234f
+  5:385a529b6670
+  6:a214d5d3811a
   8:dab8161ac8fc
   9:3c77083deb4a
   10:429fcd26f52d
@@ -552,6 +596,11 @@
   [255]
   $ hg log -q -r 'bisect(range)'
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
+  1:4ca5088da217
+  2:051e12f87bf1
+  3:0950834f0a9c
+  4:5c668c22234f
   7:50c76098bbf2
   14:faa450606157
   $ hg bisect --reset
@@ -594,12 +643,16 @@
   16:609d82a7ebae
   17:228c06deef46
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
+  1:4ca5088da217
+  8:dab8161ac8fc
   11:82ca6f06eccd
   12:9f259202bbe7
   13:b0a32c86eb31
   15:857b178a7cf3
   16:609d82a7ebae
   17:228c06deef46
+  18:d42e18c7bc9b
   $ hg log -q -r 'bisect(untested)'
   $ hg log -q -r 'bisect(ignored)'
   2:051e12f87bf1
@@ -633,6 +686,18 @@
   4:5c668c22234f
   5:385a529b6670
   6:a214d5d3811a
+  $ hg log -q -r 'bisect(goods)'
+  0:33b1f9bc8bc5
+  1:4ca5088da217
+  8:dab8161ac8fc
+  11:82ca6f06eccd
+  12:9f259202bbe7
+  13:b0a32c86eb31
+  $ hg log -q -r 'bisect(bads)'
+  15:857b178a7cf3
+  16:609d82a7ebae
+  17:228c06deef46
+  18:d42e18c7bc9b
   $ hg bisect -b
   The first bad revision is:
   changeset:   9:3c77083deb4a
@@ -651,6 +716,8 @@
   16:609d82a7ebae
   17:228c06deef46
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
+  1:4ca5088da217
   8:dab8161ac8fc
   9:3c77083deb4a
   10:429fcd26f52d
@@ -660,6 +727,7 @@
   15:857b178a7cf3
   16:609d82a7ebae
   17:228c06deef46
+  18:d42e18c7bc9b
   $ hg log -q -r 'bisect(untested)'
   $ hg log -q -r 'bisect(ignored)'
   2:051e12f87bf1
@@ -667,6 +735,20 @@
   4:5c668c22234f
   5:385a529b6670
   6:a214d5d3811a
+  $ hg log -q -r 'bisect(goods)'
+  0:33b1f9bc8bc5
+  1:4ca5088da217
+  8:dab8161ac8fc
+  11:82ca6f06eccd
+  12:9f259202bbe7
+  13:b0a32c86eb31
+  $ hg log -q -r 'bisect(bads)'
+  9:3c77083deb4a
+  10:429fcd26f52d
+  15:857b178a7cf3
+  16:609d82a7ebae
+  17:228c06deef46
+  18:d42e18c7bc9b
 
 user adds irrelevant but consistent information (here: -g 2) to bisect state
 
@@ -698,9 +780,16 @@
   12:9f259202bbe7
   13:b0a32c86eb31
   $ hg log -q -r 'bisect(pruned)'
+  0:33b1f9bc8bc5
+  1:4ca5088da217
   2:051e12f87bf1
   8:dab8161ac8fc
   11:82ca6f06eccd
   12:9f259202bbe7
   13:b0a32c86eb31
+  14:faa450606157
+  15:857b178a7cf3
+  16:609d82a7ebae
+  17:228c06deef46
+  18:d42e18c7bc9b
   $ hg log -q -r 'bisect(untested)'