Merge branch 'stable-2.10'

* stable-2.10:
  SSH query command: Remove resume_sortkey query operator
  SSH query command: Add --start n option to skip n changes

Change-Id: I4ed4aae29d2cec46e9eb034d3ac19bb9c8079346
This commit is contained in:
David Pursehouse
2014-08-19 14:22:57 +09:00
3 changed files with 15 additions and 13 deletions

View File

@@ -15,10 +15,10 @@ gerrit query - Query the change database
[--dependencies] [--dependencies]
[--submit-records] [--submit-records]
[--all-reviewers] [--all-reviewers]
[--start <n> | -S <n>]
[--] [--]
<query> <query>
[limit:<n>] [limit:<n>]
[resume_sortkey:<sortKey>]
-- --
== DESCRIPTION == DESCRIPTION
@@ -33,9 +33,8 @@ older patch set (for example an older patch set's sha1 revision).
A query may be limited on the number of results it returns with the A query may be limited on the number of results it returns with the
'limit:' operator. If no limit is supplied an internal default 'limit:' operator. If no limit is supplied an internal default
limit is used to prevent explosion of the result set. To obtain limit is used to prevent explosion of the result set. To obtain
results beyond the limit, the 'resume_sortkey:' operator can be used results beyond the limit, the '--start' flag can be used to resume
to resume the query at the change that follows the last change of the query after skipping a certain number of results.
the prior result set.
Non-option arguments to this command are joined with spaces and Non-option arguments to this command are joined with spaces and
then parsed as a query. This simplifies calling conventions over then parsed as a query. This simplifies calling conventions over
@@ -95,18 +94,16 @@ command line parser in the server).
includes whether the change meets the criteria for submission includes whether the change meets the criteria for submission
(including information for each review label). (including information for each review label).
--start::
-S::
Number of changes to skip.
limit:<n>:: limit:<n>::
Maximum number of results to return. This is actually a Maximum number of results to return. This is actually a
query operator, and not a command line option. If more query operator, and not a command line option. If more
than one limit: operator is provided, the smallest limit than one limit: operator is provided, the smallest limit
will be used to cut the result set. will be used to cut the result set.
resume_sortkey:<sortKey>::
Resume results from this sort key. Callers should pass
the sortKey of the last change of the prior result set to
resume a prior query. This is actually a query operator,
and not a command line option.
== ACCESS == ACCESS
Any user who has configured an SSH key. Any user who has configured an SSH key.
@@ -123,9 +120,9 @@ Find the 2 most recent open changes in the tools/gerrit project:
{"type":"stats","rowCount":2,"runningTimeMilliseconds:15} {"type":"stats","rowCount":2,"runningTimeMilliseconds:15}
==== ====
Resume the same query and obtain the final results: Skip number of changes:
==== ====
$ ssh -p 29418 review.example.com gerrit query --format=JSON status:open project:tools/gerrit limit:2 resume_sortkey:000e6aee00003e26 $ ssh -p 29418 review.example.com gerrit query --format=JSON --start 42 status:open project:tools/gerrit limit:2
{"project":"tools/gerrit", ...} {"project":"tools/gerrit", ...}
{"project":"tools/gerrit", ...} {"project":"tools/gerrit", ...}
{"type":"stats","rowCount":1,"runningTimeMilliseconds:15} {"type":"stats","rowCount":1,"runningTimeMilliseconds:15}

View File

@@ -146,7 +146,7 @@ public class QueryProcessor {
limit = n; limit = n;
} }
void setStart(int n) { public void setStart(int n) {
start = n; start = n;
} }

View File

@@ -85,6 +85,11 @@ class Query extends SshCommand {
processor.setIncludeSubmitRecords(on); processor.setIncludeSubmitRecords(on);
} }
@Option(name = "--start", aliases = {"-S"}, usage = "Number of changes to skip")
void setStart(int start) {
processor.setStart(start);
}
@Argument(index = 0, required = true, multiValued = true, metaVar = "QUERY", usage = "Query to execute") @Argument(index = 0, required = true, multiValued = true, metaVar = "QUERY", usage = "Query to execute")
private List<String> query; private List<String> query;