Patchwork [1,of,2,V2] bisect: use changelog for iteration

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 22, 2013, 2:36 a.m.
Message ID <9f92ee2c969579d2c65c.1358822200@yamac.lan>
Download mbox | patch
Permalink /patch/704/
State Accepted
Commit 07771e233cf15724e8fc2112a4f23f5737bc5eed
Headers show

Comments

Pierre-Yves David - Jan. 22, 2013, 2:36 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1358821382 -3600
# Branch stable
# Node ID 9f92ee2c969579d2c65cafaccffd938f82303982
# Parent  f4d2c2dafbb336a89a036b669c03112dd6306331
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.
Matt Mackall - Jan. 22, 2013, 11:39 p.m.
On Tue, 2013-01-22 at 03:36 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@logilab.fr>
> # Date 1358821382 -3600
> # Branch stable
> # Node ID 9f92ee2c969579d2c65cafaccffd938f82303982
> # Parent  f4d2c2dafbb336a89a036b669c03112dd6306331
> bisect: use changelog for iteration

Queued for stable, thanks.

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,60 @@  command
   
 
 ensure that we still don't have a working dir
 
   $ hg parents
+
+
+Check that bisect does not break on obsolete changesets
+=========================================================
+
+  $ cat > ${TESTTMP}/obs.py << EOF
+  > import mercurial.obsolete
+  > mercurial.obsolete._enabled = True
+  > EOF
+  $ echo '[extensions]' >> $HGRCPATH
+  $ echo "obs=${TESTTMP}/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
+