comparison mercurial/commands.py @ 6858:8f256bf98219

Add support for multiple possible bisect results (issue1228, issue1182) The real reason for both issue is that bisect can not handle cases where there are multiple possibilities for the result. Example (from issue1228): rev 0 -> good rev 1 -> skipped rev 2 -> skipped rev 3 -> skipped rev 4 -> bad Note that this patch does not only fix the reported Assertion Error but also the problem of a non converging bisect: hg init for i in `seq 3`; do echo $i > $i; hg add $i; hg ci -m$i; done hg bisect -b 2 hg bisect -g 0 hg bisect -s From this state on, you can: a) mark as bad forever (non converging!) b) mark as good to get an inconsistent state c) skip for the Assertion Error Minor description and code edits by pmezard.
author Bernhard Leiner <bleiner@gmail.com>
date Sat, 02 Aug 2008 22:10:10 +0200
parents e37fa751182a
children 0b6f2fa5e03f 1a4c66d741a2
comparison
equal deleted inserted replaced
6856:c6890cfc2253 6858:8f256bf98219
322 322
323 if not state['good'] or not state['bad']: 323 if not state['good'] or not state['bad']:
324 return 324 return
325 325
326 # actually bisect 326 # actually bisect
327 node, changesets, good = hbisect.bisect(repo.changelog, state) 327 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
328 if changesets == 0: 328 if changesets == 0:
329 ui.write(_("The first %s revision is:\n") % (good and "good" or "bad"))
330 displayer = cmdutil.show_changeset(ui, repo, {}) 329 displayer = cmdutil.show_changeset(ui, repo, {})
331 displayer.show(changenode=node) 330 transition = (good and "good" or "bad")
332 elif node is not None: 331 if len(nodes) == 1:
332 # narrowed it down to a single revision
333 ui.write(_("The first %s revision is:\n") % transition)
334 displayer.show(changenode=nodes[0])
335 else:
336 # multiple possible revisions
337 ui.write(_("Due to skipped revisions, the first "
338 "%s revision could be any of:\n") % transition)
339 for n in nodes:
340 displayer.show(changenode=n)
341 else:
342 assert len(nodes) == 1 # only a single node can be tested next
343 node = nodes[0]
333 # compute the approximate number of remaining tests 344 # compute the approximate number of remaining tests
334 tests, size = 0, 2 345 tests, size = 0, 2
335 while size <= changesets: 346 while size <= changesets:
336 tests, size = tests + 1, size * 2 347 tests, size = tests + 1, size * 2
337 rev = repo.changelog.rev(node) 348 rev = repo.changelog.rev(node)