repo-bisect: do proper bisect

The bisect code was a bit confused, and would always look at the versions
at the boundaries, instead of the versions in the middle, thus not doing
a proper bisect.

This change fixes this behaviour, the revision tested will be in the middle
of the current range, and will then become the lower (for a good revision) or
upper (for a bad revision) boundary for the next iteration.
This commit is contained in:
Karsten Patzwaldt 2015-01-09 17:22:19 +09:00 committed by Tom Marshall
parent 3535ffb18c
commit 0d2ae5b4ac
1 changed files with 15 additions and 11 deletions

View File

@ -184,6 +184,16 @@ def repo_sync_to_date(date):
git_reset_hard(manifest_rev)
os.chdir(cwd)
def state_to_mid(state):
d1 = string_to_datetime(state['start'])
d2 = string_to_datetime(state['end'])
mid = datetime_mid(d1, d2)
return datetime_to_string(mid)
def repo_sync_to_mid(state):
mid = state_to_mid(state)
repo_sync_to_date(mid)
def state_read():
s = dict()
f = open('.repo/bisect', 'r')
@ -231,27 +241,21 @@ if action == 'start':
state['end'] = argv[2]
state_write(state)
if not cfg['nosync']:
repo_sync_to_date(state['start'])
repo_sync_to_mid(state)
if action == 'good':
state = state_read()
d1 = string_to_datetime(state['start'])
d2 = string_to_datetime(state['end'])
mid = datetime_mid(d1, d2)
state['start'] = datetime_to_string(mid)
state['start'] = state_to_mid(state)
state_write(state)
print "bisect: start=%s, end=%s" % (state['start'], state['end'])
if not cfg['nosync']:
repo_sync_to_date(state['start'])
repo_sync_to_mid(state)
if action == 'bad':
state = state_read()
d1 = string_to_datetime(state['start'])
d2 = string_to_datetime(state['end'])
mid = datetime_mid(d1, d2)
state['end'] = datetime_to_string(mid)
state['end'] = state_to_mid(state)
state_write(state)
print "bisect: start=%s, end=%s" % (state['start'], state['end'])
if not cfg['nosync']:
repo_sync_to_date(state['start'])
repo_sync_to_mid(state)
if action == 'reset':
state_delete()