Fix --start with existing cache

It turns out len(changes) is only the correct number of changes to
skip the first time through with an empty cache.  On subsequent
runs it skips way too far ahead in the gerrit changes and thus
never gets any new ones.

This change keeps track of the number of new changes separately
from the length of changes, which seems to make the behavior with
a cache work correctly again.

Change-Id: I1e3509d2d54b514afba64fedecc6a9f5ca408235
This commit is contained in:
Ben Nemec 2015-12-23 15:51:52 +00:00
parent e8566158dd
commit 8984d97d20

View File

@ -128,6 +128,7 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='',
for project in projects: for project in projects:
changes = {} changes = {}
new_count = 0
logging.debug('Getting changes for project %s' % project['name']) logging.debug('Getting changes for project %s' % project['name'])
if not only_open and not stable: if not only_open and not stable:
@ -182,8 +183,8 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='',
cmd += ' status:open' cmd += ' status:open'
if stable: if stable:
cmd += ' branch:stable/%s' % stable cmd += ' branch:stable/%s' % stable
if len(changes): if new_count:
cmd += ' --start %d' % len(changes) cmd += ' --start %d' % new_count
else: else:
# Get a small set the first time so we can get to checking # Get a small set the first time so we can get to checking
# againt the cache sooner # againt the cache sooner
@ -219,6 +220,7 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='',
changes[(new_change['id'], changes[(new_change['id'],
new_change['project'], new_change['project'],
new_change['branch'])] = new_change new_change['branch'])] = new_change
new_count += 1
if end_of_changes: if end_of_changes:
break break