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, MergeConflictException { if (!change.currentPatchSetId().equals(patchSetId)) { throw new InvalidChangeOperationException("patch set is not current"); } final PatchSet originalPatchSet = db.get().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, uploader); PatchSetInserter patchSetInserter = patchSetInserterFactory .create(git, revWalk, changeControl, rebasedCommit) .setValidatePolicy(validate) .setDraft(originalPatchSet.isDraft()) .setUploader(uploader.getAccountId()) .setSendMail(sendMail) .setRunHooks(runHooks); final PatchSet.Id newPatchSetId = patchSetInserter.getPatchSetId(); final ChangeMessage cmsg = new ChangeMessage( new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db.get())), uploader.getAccountId(), TimeUtil.nowTs(), patchSetId); cmsg.setMessage("Patch Set " + newPatchSetId.get() + ": Patch Set " + patchSetId.get() + " was rebased"); Change newChange = patchSetInserter .setMessage(cmsg) .setSendMail(false) .insert(); return db.get().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, MergeConflictException { if (!change.currentPatchSetId().equals(patchSetId)) { throw new InvalidChangeOperationException("patch set is not current"); } final PatchSet originalPatchSet = db.get().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, uploader); PatchSetInserter patchSetInserter = patchSetInserterFactory .create(git, revWalk, changeControl, rebasedCommit) .setValidatePolicy(validate) .setDraft(originalPatchSet.isDraft()) .setUploader(uploader.getAccountId()) .setSendMail(sendMail) .setRunHooks(runHooks); final PatchSet.Id newPatchSetId = patchSetInserter.getPatchSetId(); final ChangeMessage cmsg = new ChangeMessage( new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db.get())), uploader.getAccountId(), TimeUtil.nowTs(), patchSetId); cmsg.setMessage("Patch Set " + newPatchSetId.get() + ": Patch Set " + patchSetId.get() + " was rebased"); Change newChange = patchSetInserter .setMessage(cmsg) .insert(); return db.get().patchSets().get(newChange.currentPatchSetId()); }