Gerrit 2.11 compatibility
Gerrit 2.11 no longer seems to support the sortKey method of skipping changes. Instead is provides a --start option that takes a number of changes to skip. See: https://review.openstack.org/Documentation/cmd-query.html In addition, this required a change to the format of the changes dict. It turns out we were overwriting some changes if two had the same id. This is common in stable branch cherry picks. In order to avoid this, I used a tuple of id, project, branch as the key for the changes dict. This does break compatibility with existing cache files, so a check was added to clear old caches. Both of these changes were required together because otherwise we end up with a smaller number of items in changes than we should have, and the --start argument is incorrect so we start double processing changes, which breaks the loop because it looks like the change was already cached. Change-Id: If5ab46ce3367b3790e0db1d8bb1ed18e39202ad9
This commit is contained in:
parent
1a2a999b5a
commit
e8566158dd
|
@ -145,7 +145,14 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='',
|
||||||
# The cache is in the old list format
|
# The cache is in the old list format
|
||||||
changes = {}
|
changes = {}
|
||||||
|
|
||||||
sortkey = None
|
if changes:
|
||||||
|
for k, v in changes.items():
|
||||||
|
# The cache is only using the id as a key. We now need both
|
||||||
|
# id and branch.
|
||||||
|
if not isinstance(k, tuple):
|
||||||
|
changes = {}
|
||||||
|
break
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
connect_attempts = 3
|
connect_attempts = 3
|
||||||
for attempt in range(connect_attempts):
|
for attempt in range(connect_attempts):
|
||||||
|
@ -175,8 +182,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 sortkey:
|
if len(changes):
|
||||||
cmd += ' resume_sortkey:%s' % sortkey
|
cmd += ' --start %d' % len(changes)
|
||||||
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
|
||||||
|
@ -201,14 +208,17 @@ def get_changes(projects, ssh_user, ssh_key, only_open=False, stable='',
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if changes.get(new_change['id'], None) == new_change:
|
if changes.get((new_change['id'],
|
||||||
|
new_change['project'],
|
||||||
|
new_change['branch']), None) == new_change:
|
||||||
# Changes are ordered by latest to be updated. As soon
|
# Changes are ordered by latest to be updated. As soon
|
||||||
# as we hit one that hasn't changed since our cached
|
# as we hit one that hasn't changed since our cached
|
||||||
# version, we're done.
|
# version, we're done.
|
||||||
end_of_changes = True
|
end_of_changes = True
|
||||||
break
|
break
|
||||||
sortkey = new_change['sortKey']
|
changes[(new_change['id'],
|
||||||
changes[new_change['id']] = new_change
|
new_change['project'],
|
||||||
|
new_change['branch'])] = new_change
|
||||||
if end_of_changes:
|
if end_of_changes:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue