Provide a useful body when revision parsing is ambiguous

Change-Id: I845fef6da5f0e01461f2e4be351a39170196b67b
This commit is contained in:
Dave Borowitz
2014-10-15 07:47:14 -07:00
parent fc43b7e9eb
commit 5e5544ee5f
2 changed files with 19 additions and 3 deletions

View File

@@ -95,4 +95,13 @@ public class RevisionResource implements RestResource, HasETag {
Optional<ChangeEdit> getEdit() {
return edit;
}
@Override
public String toString() {
String s = ps.getId().toString();
if (edit.isPresent()) {
s = "edit:" + s;
}
return s;
}
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.change;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Lists;
@@ -84,10 +85,16 @@ public class Revisions implements ChildCollection<ChangeResource, RevisionResour
match.add(rsrc);
}
}
if (match.size() != 1) {
switch (match.size()) {
case 0:
throw new ResourceNotFoundException(id);
}
case 1:
return match.get(0);
default:
throw new ResourceNotFoundException(
"Multiple patch sets for \"" + id.get() + "\": "
+ Joiner.on("; ").join(match));
}
}
private boolean visible(ChangeResource change, PatchSet ps)