Add options to /changes/<id>/detail

Clients fetching the detailed information about a change need more
than just the labels, they also expect to see the current revision and
data from its commit.  Support the o/O options used by /changes/ to
permit clients to obtain more information than the default set.

Change-Id: Ic8f910474b8f13e6faf76199c5781a38075380ac
This commit is contained in:
Shawn Pearce
2013-07-06 19:24:29 -07:00
parent 630dd1d7a5
commit 7f3dccfe6f
2 changed files with 17 additions and 0 deletions

View File

@@ -364,6 +364,11 @@ Retrieves a change with link:#labels[labels], link:#detailed-labels[
detailed labels], link:#detailed-accounts[detailed accounts], and
link:#messages[messages].
Additional fields can be obtained by adding `o` parameters, each
option requires more database lookups and slows down the query
response time to the client so they are generally disabled by
default. Fields are described in link:#list-changes[Query Changes].
.Request
----
GET /changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940/detail HTTP/1.0

View File

@@ -19,9 +19,21 @@ import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import org.kohsuke.args4j.Option;
public class GetDetail implements RestReadView<ChangeResource> {
private final ChangeJson json;
@Option(name = "-o", multiValued = true, usage = "Output options")
void addOption(ListChangesOption o) {
json.addOption(o);
}
@Option(name = "-O", usage = "Output option flags, in hex")
void setOptionFlagsHex(String hex) {
json.addOptions(ListChangesOption.fromBits(Integer.parseInt(hex, 16)));
}
@Inject
GetDetail(ChangeJson json) {
this.json = json