Make portions of ListChanges public

This enables other callers to use ListChanges, for example a plugin
might want to drive ListChanges with their own arguments without going
through the args4j option parser.

Change-Id: I5cfd342673e9e381079b2c1891fe73e48be3e93b
This commit is contained in:
Shawn O. Pearce
2012-07-31 13:11:02 -07:00
parent 423c4a972c
commit 86d22c2276
2 changed files with 20 additions and 4 deletions

View File

@@ -38,6 +38,14 @@ public enum ListChangesOption {
this.value = v;
}
public int getValue() {
return value;
}
public static ListChangesOption fromValue(int value) {
return ListChangesOption.values()[value];
}
public static EnumSet<ListChangesOption> fromBits(int v) {
EnumSet<ListChangesOption> r = EnumSet.noneOf(ListChangesOption.class);
for (ListChangesOption o : ListChangesOption.values()) {

View File

@@ -124,12 +124,12 @@ public class ListChanges {
private List<String> queries;
@Option(name = "--limit", aliases = {"-n"}, metaVar = "CNT", usage = "Maximum number of results to return")
void setLimit(int limit) {
public void setLimit(int limit) {
imp.setLimit(limit);
}
@Option(name = "-o", multiValued = true, usage = "Output options per change")
void addOption(ListChangesOption o) {
public void addOption(ListChangesOption o) {
options.add(o);
}
@@ -139,7 +139,7 @@ public class ListChanges {
}
@Option(name = "-P", metaVar = "SORTKEY", usage = "Previous changes before SORTKEY")
void setSortKeyAfter(String key) {
public void setSortKeyAfter(String key) {
// Querying for the prior page of changes requires sortkey_after predicate.
// Changes are shown most recent->least recent. The previous page of
// results contains changes that were updated after the given key.
@@ -148,7 +148,7 @@ public class ListChanges {
}
@Option(name = "-N", metaVar = "SORTKEY", usage = "Next changes after SORTKEY")
void setSortKeyBefore(String key) {
public void setSortKeyBefore(String key) {
// Querying for the next page of changes requires sortkey_before predicate.
// Changes are shown most recent->least recent. The next page contains
// changes that were updated before the given key.
@@ -193,6 +193,14 @@ public class ListChanges {
return this;
}
public ListChanges addQuery(String query) {
if (queries == null) {
queries = Lists.newArrayList();
}
queries.add(query);
return this;
}
public void query(Writer out)
throws OrmException, QueryParseException, IOException {
if (imp.isDisabled()) {