Source:
public PatchSet rebase(final Repository git, final RevWalk revWalk, final ObjectInserter inserter, final PatchSet.Id patchSetId, final Change change, final IdentifiedUser uploader, final RevCommit baseCommit, final MergeUtil mergeUtil, PersonIdent committerIdent, boolean sendMail, boolean runHooks, ValidatePolicy validate) throws NoSuchChangeException, OrmException, IOException, InvalidChangeOperationException, PathConflictException { if (!change.currentPatchSetId().equals(patchSetId)) { throw new InvalidChangeOperationException("patch set is not current"); } final PatchSet originalPatchSet = db.patchSets().get(patchSetId); final RevCommit rebasedCommit; ObjectId oldId = ObjectId.fromString(originalPatchSet.getRevision().get()); ObjectId newId = rebaseCommit(git, inserter, revWalk.parseCommit(oldId), baseCommit, mergeUtil, committerIdent); rebasedCommit = revWalk.parseCommit(newId); final ChangeControl changeControl = changeControlFactory.validateFor(change.getId(), uploader); PatchSetInserter patchSetinserter = patchSetInserterFactory .create(git, revWalk, changeControl.getRefControl(), uploader, change, rebasedCommit) .setCopyLabels(true) .setValidatePolicy(validate) .setDraft(originalPatchSet.isDraft()) .setSendMail(sendMail) .setRunHooks(runHooks); final int patchSetNumber = patchSetId.get(); final ChangeMessage cmsg = new ChangeMessage(new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)), uploader.getAccountId(), patchSetId); cmsg.setMessage("Patch Set " + (patchSetNumber + 1) + ": Patch Set " + patchSetNumber + " was rebased"); Change newChange = patchSetinserter .setMessage(cmsg) .insert(); return db.patchSets().get(newChange.currentPatchSetId()); }

Target:
public PatchSet rebase(final Repository git, final RevWalk revWalk, final ObjectInserter inserter, final PatchSet.Id patchSetId, final Change change, final IdentifiedUser uploader, final RevCommit baseCommit, final MergeUtil mergeUtil, PersonIdent committerIdent, boolean sendMail, boolean runHooks, ValidatePolicy validate) throws NoSuchChangeException, OrmException, IOException, InvalidChangeOperationException, PathConflictException { if (!change.currentPatchSetId().equals(patchSetId)) { throw new InvalidChangeOperationException("patch set is not current"); } final PatchSet originalPatchSet = db.patchSets().get(patchSetId); final RevCommit rebasedCommit; ObjectId oldId = ObjectId.fromString(originalPatchSet.getRevision().get()); ObjectId newId = rebaseCommit(git, inserter, revWalk.parseCommit(oldId), baseCommit, mergeUtil, committerIdent); rebasedCommit = revWalk.parseCommit(newId); final ChangeControl changeControl = changeControlFactory.validateFor(change.getId(), uploader); PatchSetInserter patchSetInserter = patchSetInserterFactory .create(git, revWalk, changeControl.getRefControl(), uploader, change, rebasedCommit) .setCopyLabels(true) .setValidatePolicy(validate) .setDraft(originalPatchSet.isDraft()) .setSendMail(sendMail) .setRunHooks(runHooks); final PatchSet.Id newPatchSetId = patchSetInserter.getPatchSetId(); final ChangeMessage cmsg = new ChangeMessage(new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)), uploader.getAccountId(), patchSetId); cmsg.setMessage("Patch Set " + newPatchSetId.get() + ": Patch Set " + patchSetId.get() + " was rebased"); Change newChange = patchSetInserter .setMessage(cmsg) .insert(); return db.patchSets().get(newChange.currentPatchSetId()); }