Support SyncQueriedChanges batching in Gerrit >=2.9

The commits 76ccd91ff9 and
74abd8e318 added support in (what was
then) the SyncProjectTask for the changes in the Gerrit API to batching
of queries starting with Gerrit 2.9. This patch applies the same fixes
to the SyncQueriedChangesTask.

Change-Id: Ic2786c10ac326d453b5b7a8bfcad3d1e87db1f52
This commit is contained in:
Zane Bitter 2016-05-06 10:01:14 -04:00
parent 2efa0606f7
commit 7a1795b297
1 changed files with 6 additions and 1 deletions

View File

@ -419,6 +419,7 @@ class SyncQueriedChangesTask(Task):
changes = []
sortkey = ''
done = False
offset = 0
while not done:
# We don't actually want to limit to 500, but that's the server-side default, and
# if we don't specify this, we won't get a _more_changes flag.
@ -429,8 +430,12 @@ class SyncQueriedChangesTask(Task):
if batch:
changes += batch
if '_more_changes' in batch[-1]:
sortkey = '&N=%s' % (batch[-1]['_sortkey'],)
done = False
if '_sortkey' in batch[-1]:
sortkey = '&N=%s' % (batch[-1]['_sortkey'],)
else:
offset += len(batch)
sortkey = '&start=%s' % (offset,)
change_ids = [c['id'] for c in changes]
with app.db.getSession() as session:
# Winnow the list of IDs to only the ones in the local DB.