From 0d2ae5b4acafa8d50f67f95dd7b22e6e6c75552b Mon Sep 17 00:00:00 2001 From: Karsten Patzwaldt Date: Fri, 9 Jan 2015 17:22:19 +0900 Subject: [PATCH] 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. --- repo-bisect | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/repo-bisect b/repo-bisect index 6e4abf1..a74b7a7 100644 --- a/repo-bisect +++ b/repo-bisect @@ -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()