Rebase: Improve error message when rebasing a change onto itself
Change it from: "cannot depend on self" to "cannot rebase change onto itself" and add a test case for it. Also fix a couple of minor nits in rebaseOntoAbandonedChange. - use variable rather than calling getChangeId() again - fix indentation Change-Id: I70257c06af8872010958114537c092d4e9dcfc65
This commit is contained in:
parent
fa1a8280fe
commit
c5fc9ed2b5
@ -477,11 +477,26 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
ri.base = r.getCommit().name();
|
||||
|
||||
exception.expect(ResourceConflictException.class);
|
||||
exception.expectMessage("base change is abandoned: " + r.getChangeId());
|
||||
exception.expectMessage("base change is abandoned: " + changeId);
|
||||
gApi.changes()
|
||||
.id(r2.getChangeId())
|
||||
.revision(r2.getCommit().name())
|
||||
.rebase(ri);
|
||||
.id(r2.getChangeId())
|
||||
.revision(r2.getCommit().name())
|
||||
.rebase(ri);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rebaseOntoSelf() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
String changeId = r.getChangeId();
|
||||
String commit = r.getCommit().name();
|
||||
RebaseInput ri = new RebaseInput();
|
||||
ri.base = commit;
|
||||
exception.expect(ResourceConflictException.class);
|
||||
exception.expectMessage("cannot rebase change onto itself");
|
||||
gApi.changes()
|
||||
.id(changeId)
|
||||
.revision(commit)
|
||||
.rebase(ri);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -152,7 +152,7 @@ public class Rebase implements RestModifyView<RevisionResource, RebaseInput>,
|
||||
if (!base.control().isPatchVisible(base.patchSet(), db)) {
|
||||
throw new AuthException("base revision not accessible: " + str);
|
||||
} else if (change.getId().equals(baseId.getParentKey())) {
|
||||
throw new ResourceConflictException("cannot depend on self");
|
||||
throw new ResourceConflictException("cannot rebase change onto itself");
|
||||
}
|
||||
|
||||
Change baseChange = base.control().getChange();
|
||||
|
Loading…
Reference in New Issue
Block a user