# HG changeset patch # User "Yann E. MORIN" # Date 2011-09-17 15:33:34 # Node ID 18219c0789ae4293f0ffa94f574dcc77359e7c74 # Parent f19de58af22531880a0d91c71b011c213b5de70f revset.bisect: add new 'range' set 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, roughly equivalent of: bisect(good)::bisect(bad) | bisect(bad)::bisect(good) Signed-off-by: "Yann E. MORIN" diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py --- a/mercurial/hbisect.py +++ b/mercurial/hbisect.py @@ -159,9 +159,37 @@ def get(repo, status): 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 """ state = load_state(repo) if status in ('good', 'bad', 'skip'): return [repo.changelog.rev(n) for n in state[status]] else: - raise error.ParseError(_('invalid bisect state')) + # Build sets of good, bad, and skipped csets + goods = set(repo.changelog.rev(n) for n in state['good']) + bads = set(repo.changelog.rev(n) for n in state['bad']) + skips = set(repo.changelog.rev(n) for n in state['skip']) + + # Build kinship of good csets + ga = goods.copy() # Goods' Ancestors + gd = goods.copy() # Goods' Descendants + for g in goods: + ga |= set(repo.changelog.ancestors(g)) + gd |= set(repo.changelog.descendants(g)) + + # Build kinship of bad csets + ba = bads.copy() # Bads' Ancestors + bd = bads.copy() # Bads' Descendants + for b in bads: + ba |= set(repo.changelog.ancestors(b)) + bd |= set(repo.changelog.descendants(b)) + + # Build the range of the bisection + range = set(c for c in ba if c in gd) + range |= set(c for c in ga if c in bd) + + if status == 'range': + return [c for c in range] + + else: + raise error.ParseError(_('invalid bisect state')) diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -237,7 +237,10 @@ def author(repo, subset, x): def bisect(repo, subset, x): """``bisect(string)`` - Changesets marked in the specified bisect status (good, bad, skip). + Changesets marked in the specified bisect status (``good``, ``bad``, + ``skip``), or any of the meta-status: + + - ``range`` : all csets taking part in the bisection """ status = getstring(x, _("bisect requires a string")).lower() return [r for r in subset if r in hbisect.get(repo, status)] diff --git a/tests/test-bisect2.t b/tests/test-bisect2.t --- a/tests/test-bisect2.t +++ b/tests/test-bisect2.t @@ -271,6 +271,23 @@ complex bisect test 1 # first bad rev i date: Thu Jan 01 00:00:09 1970 +0000 summary: 9 + $ hg log -q -r 'bisect(range)' + 0:33b1f9bc8bc5 + 1:4ca5088da217 + 2:051e12f87bf1 + 3:0950834f0a9c + 4:5c668c22234f + 5:385a529b6670 + 6:a214d5d3811a + 8:dab8161ac8fc + 9:3c77083deb4a + 10:429fcd26f52d + 11:82ca6f06eccd + 12:9f259202bbe7 + 13:b0a32c86eb31 + 15:857b178a7cf3 + 16:609d82a7ebae + 17:228c06deef46 complex bisect test 2 # first good rev is 13 @@ -295,6 +312,21 @@ complex bisect test 2 # first good rev date: Thu Jan 01 00:00:13 1970 +0000 summary: 13 + $ hg log -q -r 'bisect(range)' + 1:4ca5088da217 + 2:051e12f87bf1 + 3:0950834f0a9c + 4:5c668c22234f + 5:385a529b6670 + 6:a214d5d3811a + 8:dab8161ac8fc + 9:3c77083deb4a + 10:429fcd26f52d + 11:82ca6f06eccd + 12:9f259202bbe7 + 13:b0a32c86eb31 + 15:857b178a7cf3 + 18:d42e18c7bc9b complex bisect test 3 @@ -347,6 +379,21 @@ 10,9,13 are skipped an might be the firs date: Thu Jan 01 00:00:15 1970 +0000 summary: merge 10,13 + $ hg log -q -r 'bisect(range)' + 1:4ca5088da217 + 2:051e12f87bf1 + 3:0950834f0a9c + 4:5c668c22234f + 5:385a529b6670 + 6:a214d5d3811a + 8:dab8161ac8fc + 9:3c77083deb4a + 10:429fcd26f52d + 11:82ca6f06eccd + 12:9f259202bbe7 + 13:b0a32c86eb31 + 15:857b178a7cf3 + 16:609d82a7ebae complex bisect test 4 @@ -386,6 +433,16 @@ 15,16 are skipped an might be the first date: Thu Jan 01 00:00:17 1970 +0000 summary: 17 + $ hg log -q -r 'bisect(range)' + 8:dab8161ac8fc + 9:3c77083deb4a + 10:429fcd26f52d + 11:82ca6f06eccd + 12:9f259202bbe7 + 13:b0a32c86eb31 + 15:857b178a7cf3 + 16:609d82a7ebae + 17:228c06deef46 test unrelated revs: @@ -394,6 +451,7 @@ test unrelated revs: $ hg bisect -g 14 abort: starting revisions are not directly related [255] + $ hg log -q -r 'bisect(range)' $ hg bisect --reset end at merge: 17 bad, 11 good (but 9 is first bad) @@ -418,6 +476,13 @@ end at merge: 17 bad, 11 good (but 9 is Not all ancestors of this changeset have been checked. Use bisect --extend to continue the bisection from the common ancestor, dab8161ac8fc. + $ hg log -q -r 'bisect(range)' + 11:82ca6f06eccd + 12:9f259202bbe7 + 13:b0a32c86eb31 + 15:857b178a7cf3 + 16:609d82a7ebae + 17:228c06deef46 $ hg bisect --extend Extending search to changeset 8:dab8161ac8fc 2 files updated, 0 files merged, 2 files removed, 0 files unresolved @@ -431,6 +496,16 @@ end at merge: 17 bad, 11 good (but 9 is date: Thu Jan 01 00:00:09 1970 +0000 summary: 9 + $ hg log -q -r 'bisect(range)' + 8:dab8161ac8fc + 9:3c77083deb4a + 10:429fcd26f52d + 11:82ca6f06eccd + 12:9f259202bbe7 + 13:b0a32c86eb31 + 15:857b178a7cf3 + 16:609d82a7ebae + 17:228c06deef46 user adds irrelevant but consistent information (here: -g 2) to bisect state @@ -450,3 +525,8 @@ user adds irrelevant but consistent info date: Thu Jan 01 00:00:11 1970 +0000 summary: 11 + $ hg log -q -r 'bisect(range)' + 8:dab8161ac8fc + 11:82ca6f06eccd + 12:9f259202bbe7 + 13:b0a32c86eb31