Allow {} to be used for quoting in query expressions

This makes it a little easier to query for group names that contain
a space over SSH:

  ssh srv gerrit query " 'status:open NOT reviewerin:{Developer Group}' "

Change-Id: I7c81c752236c85d4ed5bd3ed7ad79486b3336510
This commit is contained in:
Shawn O. Pearce
2012-11-30 11:20:37 -08:00
parent c3657e0b10
commit 757df06505
3 changed files with 25 additions and 5 deletions

View File

@@ -37,10 +37,14 @@ results beyond the limit, the 'resume_sortkey:' operator can be used
to resume the query at the change that follows the last change of to resume the query at the change that follows the last change of
the prior result set. the prior result set.
Non-option arguments to this command are joined with spaces and then Non-option arguments to this command are joined with spaces and
parsed as a query. This simplifies calling conventions over SSH then parsed as a query. This simplifies calling conventions over
by permitting operators to appear in different arguments without SSH by permitting operators to appear in different arguments.
multiple levels of quoting required.
Query operators may quote values using matched curly braches
(e.g. `reviewerin:{Developer Group}`) to sidestep issues with 2
levels of shell quoting (caller shell invoking SSH, and the SSH
command line parser in the server).
OPTIONS OPTIONS
------- -------

View File

@@ -23,6 +23,7 @@ matches the search, the change will be presented instead of a list.
|Open changes in Foo | status:open project:Foo |Open changes in Foo | status:open project:Foo
|================================================= |=================================================
Basic Change Search Basic Change Search
------------------- -------------------
@@ -109,7 +110,6 @@ matches project names by regular expression. The
link:http://www.brics.dk/automaton/[dk.brics.automaton link:http://www.brics.dk/automaton/[dk.brics.automaton
library] is used for evaluation of such patterns. library] is used for evaluation of such patterns.
[[branch]] [[branch]]
branch:'BRANCH':: branch:'BRANCH'::
+ +
@@ -271,6 +271,17 @@ status:abandoned::
Change has been abandoned. Change has been abandoned.
Argument Quoting
----------------
Operator values that are not bare words (roughly A-Z, a-z, 0-9, @,
hypen, dot and underscore) must be quoted for the query parser.
Quoting is accepted as either double quotes
(e.g. `message:"the value"`) or as matched
curly braces (e.g. `message:{the value}`).
Boolean Operators Boolean Operators
----------------- -----------------
@@ -427,6 +438,7 @@ set by the pagination system as the user navigates through results
of a query. Including either value in a web query may lead to of a query. Including either value in a web query may lead to
unpredictable results. unpredictable results.
GERRIT GERRIT
------ ------
Part of link:index.html[Gerrit Code Review] Part of link:index.html[Gerrit Code Review]

View File

@@ -155,6 +155,10 @@ EXACT_PHRASE
String s = $text; String s = $text;
setText(s.substring(1, s.length() - 1)); setText(s.substring(1, s.length() - 1));
} }
| '{' ( ~('{'|'}') )* '}' {
String s = $text;
setText(s.substring(1, s.length() - 1));
}
; ;
SINGLE_WORD SINGLE_WORD