Patchwork [4,of,4] bisect: use changelog for iteration

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 21, 2013, 6:48 p.m.
Message ID <55ac350fd7dcd2e1435e.1358794110@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/697/
State Superseded
Commit 07771e233cf15724e8fc2112a4f23f5737bc5eed
Headers show

Comments

Pierre-Yves David - Jan. 21, 2013, 6:48 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1358793895 -3600
# Branch stable
# Node ID 55ac350fd7dcd2e1435e4f170667e788410556dd
# Parent  0ebc94ad72a9a7731388ce7fe95952d4dce956a6
bisect: use changelog for iteration

With changelog filtering, we can not use xrange anymore. We have to use the
changelog to do the iteration. This way, the changelog excludes filtered
revision and we can safely use what we iterate over.

Without this changes, bisect crash with a traceback if there is filtered
revision in the repo. Tests have been updated.

Patch

diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py
--- a/mercurial/hbisect.py
+++ b/mercurial/hbisect.py
@@ -36,19 +36,19 @@  def bisect(changelog, state):
         ancestors = [None] * (len(changelog) + 1) # an extra for [-1]
 
         # set nodes descended from goodrevs
         for rev in goodrevs:
             ancestors[rev] = []
-        for rev in xrange(goodrev + 1, len(changelog)):
+        for rev in changelog.revs(goodrev + 1):
             for prev in clparents(rev):
                 if ancestors[prev] == []:
                     ancestors[rev] = []
 
         # clear good revs from array
         for rev in goodrevs:
             ancestors[rev] = None
-        for rev in xrange(len(changelog), goodrev, -1):
+        for rev in changelog.revs(len(changelog), goodrev):
             if ancestors[rev] is None:
                 for prev in clparents(rev):
                     ancestors[prev] = None
 
         if ancestors[badrev] is None:
diff --git a/tests/test-bisect.t b/tests/test-bisect.t
--- a/tests/test-bisect.t
+++ b/tests/test-bisect.t
@@ -506,5 +506,57 @@  command
   
 
 ensure that we still don't have a working dir
 
   $ hg parents
+
+
+Check that bisect does not break on obsolete changesets
+=========================================================
+
+
+  $ echo '[extensions]' >> $HGRCPATH
+  $ echo "obs=${TESTDIR}/../contrib/obs.py" >> $HGRCPATH
+
+tip is obsolete
+---------------------
+
+  $ hg debugobsolete `hg id --debug -i -r tip`
+  $ hg bisect --reset
+  $ hg bisect --good 15
+  $ hg bisect --bad 30
+  Testing changeset 22:06c7993750ce (15 changesets remaining, ~3 tests)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg bisect --command true
+  changeset 22:06c7993750ce: good
+  changeset 26:3efc6fd51aeb: good
+  changeset 28:8e0c2264c8af: good
+  changeset 29:b5bd63375ab9: good
+  The first bad revision is:
+  changeset:   30:ed2d2f24b11c
+  tag:         tip
+  user:        test
+  date:        Thu Jan 01 00:00:30 1970 +0000
+  summary:     msg 30
+  
+
+Changeset in the bad:good range is obsolete
+---------------------------------------------
+
+  $ hg up 30
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo 'a' >> a
+  $ hg ci -m "msg 32" -d "32 0"
+  $ hg bisect --reset
+  $ hg bisect --good .
+  $ hg bisect --bad 25
+  Testing changeset 28:8e0c2264c8af (6 changesets remaining, ~2 tests)
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg bisect --command true
+  changeset 28:8e0c2264c8af: good
+  changeset 26:3efc6fd51aeb: good
+  The first good revision is:
+  changeset:   26:3efc6fd51aeb
+  user:        test
+  date:        Thu Jan 01 00:00:26 1970 +0000
+  summary:     msg 26
+