Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2195)

Unified Diff: gerrit_util.py

Issue 50283002: my_activity: Port gerrit to the new gerrit_util API. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | my_activity.py » ('j') | my_activity.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gerrit_util.py
diff --git a/gerrit_util.py b/gerrit_util.py
index 7c44f03107468de934940bd1bf7646630818c53f..0a677b02e774786fb591d47ca4b8e0d101a0052b 100755
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -180,6 +180,42 @@ def QueryChanges(host, param_dict, first_param=None, limit=None, o_params=None,
return ReadHttpJsonResponse(CreateHttpConn(host, path), ignore_404=False)
+def QueryAllChanges(host, param_dict, first_param=None, limit=500,
+ o_params=None, sortkey=None):
+ """
+ Queries a gerrit-on-borg server for all the changes matching the query terms.
+
+ A single query to gerrit-on-borg is limited on the number of results by the
+ limit parameter on the request (see QueryChanges) and the server maximum
+ limit. This function uses the "_more_changes" and "_sortkey" attributes on
+ the returned changes to iterate all of them making multiple queries to the
+ server, regardless the query limit.
+
+ Args:
+ param_dict: A dictionary of search parameters, as documented here:
+ http://gerrit-documentation.googlecode.com/svn/Documentation/2.6/user-search.html
+ first_param: A change identifier.
+ limit: Maximum number of requested changes per query.
+ o_params: A list of additional output specifiers, as documented here:
+ https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#list-changes
+ sortkey: The value of the "_sortkey" attribute where starts from. None to
+ start from the first change.
+
+ Returns:
+ A generator object to the list of returned changes, possibly unbound.
+ """
+ more_changes = True
+ while more_changes:
+ page = QueryChanges(host, param_dict, first_param, limit, o_params, sortkey)
+ for cl in page:
+ yield cl
+
+ more_changes = [cl for cl in page if '_more_changes' in cl]
+ sortkey = None
+ if more_changes:
+ sortkey = more_changes[0]['_sortkey']
+
+
def MultiQueryChanges(host, param_dict, change_list, limit=None, o_params=None,
sortkey=None):
"""Initiate a query composed of multiple sets of query parameters."""
« no previous file with comments | « no previous file | my_activity.py » ('j') | my_activity.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698