Merge "Fail with proper error when trying to revert initial commit"

This commit is contained in:
David Pursehouse
2015-10-30 12:59:49 +00:00
committed by Gerrit Code Review
2 changed files with 26 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Change;
@@ -234,6 +235,10 @@ public class ChangeUtil {
PersonIdent authorIdent = user.get()
.newCommitterIdent(myIdent.getWhen(), myIdent.getTimeZone());
if (commitToRevert.getParentCount() == 0) {
throw new ResourceConflictException("Cannot revert initial commit");
}
RevCommit parentToCommitToRevert = commitToRevert.getParent(0);
revWalk.parseHeaders(parentToCommitToRevert);