Mercurial > hg-stable
changeset 18463:07771e233cf1 stable
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.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Tue, 22 Jan 2013 03:23:02 +0100 |
parents | 593eb3786165 |
children | a2e9fe93d9ea |
files | mercurial/hbisect.py tests/test-bisect.t |
diffstat | 2 files changed, 57 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hbisect.py Mon Jan 21 19:40:15 2013 +0100 +++ b/mercurial/hbisect.py Tue Jan 22 03:23:02 2013 +0100 @@ -38,7 +38,7 @@ # 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] = [] @@ -46,7 +46,7 @@ # 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
--- a/tests/test-bisect.t Mon Jan 21 19:40:15 2013 +0100 +++ b/tests/test-bisect.t Tue Jan 22 03:23:02 2013 +0100 @@ -508,3 +508,58 @@ 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 +