Remove method getNumberOfPatchSets() from Change.
Removed the only use of the method. Fixed RebaseChange to pass in the db object. Some other minor cleanups are included too. This is part of the code cleanup to remove the nbrPatchSets field. Change-Id: Iaa7431ea9c96e19c008d8ec25d774e0f7240ba35
This commit is contained in:
@@ -436,10 +436,6 @@ public final class Change {
|
||||
lastUpdatedOn = new Timestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public int getNumberOfPatchSets() {
|
||||
return nbrPatchSets;
|
||||
}
|
||||
|
||||
public String getSortKey() {
|
||||
return sortKey;
|
||||
}
|
||||
|
@@ -68,38 +68,25 @@ public class ApprovalsUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the PatchSetApprovals to the last PatchSet on the change while
|
||||
* keeping the vetos.
|
||||
*
|
||||
* @param change Change to update
|
||||
* @throws OrmException
|
||||
* @return List<PatchSetApproval> The previous approvals
|
||||
*/
|
||||
public List<PatchSetApproval> copyVetosToLatestPatchSet(Change change)
|
||||
throws OrmException {
|
||||
return copyVetosToLatestPatchSet(db, change);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the PatchSetApprovals to the last PatchSet on the change while
|
||||
* keeping the vetos.
|
||||
* Moves the PatchSetApprovals to the specified PatchSet on the change from
|
||||
* the prior PatchSet, while keeping the vetos.
|
||||
*
|
||||
* @param db database connection to use for updates.
|
||||
* @param change Change to update
|
||||
* @param dest PatchSet to copy to
|
||||
* @throws OrmException
|
||||
* @return List<PatchSetApproval> The previous approvals
|
||||
*/
|
||||
public List<PatchSetApproval> copyVetosToLatestPatchSet(ReviewDb db,
|
||||
Change change) throws OrmException {
|
||||
public List<PatchSetApproval> copyVetosToPatchSet(ReviewDb db,
|
||||
PatchSet.Id dest) throws OrmException {
|
||||
PatchSet.Id source;
|
||||
if (change.getNumberOfPatchSets() > 1) {
|
||||
source = new PatchSet.Id(change.getId(), change.getNumberOfPatchSets() - 1);
|
||||
if (dest.get() > 1) {
|
||||
source = new PatchSet.Id(dest.getParentKey(), dest.get() - 1);
|
||||
} else {
|
||||
throw new OrmException("Previous patch set could not be found");
|
||||
}
|
||||
|
||||
PatchSet.Id dest = change.currPatchSetId();
|
||||
List<PatchSetApproval> patchSetApprovals = db.patchSetApprovals().byChange(change.getId()).toList();
|
||||
List<PatchSetApproval> patchSetApprovals =
|
||||
db.patchSetApprovals().byChange(dest.getParentKey()).toList();
|
||||
for (PatchSetApproval a : patchSetApprovals) {
|
||||
// ApprovalCategory.SUBMIT is still in db but not relevant in git-store
|
||||
if (!ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {
|
||||
|
@@ -189,7 +189,6 @@ public class RebaseChange {
|
||||
* @param db the ReviewDb
|
||||
* @param destBranch the destination branch
|
||||
* @param git the repository
|
||||
* @param rw the RevWalk
|
||||
* @param patchSetAncestors the original PatchSetAncestor of the given patch
|
||||
* set that should be based
|
||||
* @param depPatchSetList the original patch set list on which the rebased
|
||||
@@ -393,7 +392,7 @@ public class RebaseChange {
|
||||
"Change %s was modified", change.getId()));
|
||||
}
|
||||
|
||||
approvalsUtil.copyVetosToLatestPatchSet(change);
|
||||
approvalsUtil.copyVetosToPatchSet(db, change.currentPatchSetId());
|
||||
|
||||
final ChangeMessage cmsg =
|
||||
new ChangeMessage(new ChangeMessage.Key(change.getId(),
|
||||
|
@@ -111,7 +111,6 @@ import org.eclipse.jgit.transport.BaseReceivePack;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand.Result;
|
||||
import org.eclipse.jgit.transport.ReceivePack;
|
||||
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
|
||||
import org.eclipse.jgit.transport.UploadPack;
|
||||
import org.eclipse.jgit.util.SystemReader;
|
||||
import org.slf4j.Logger;
|
||||
@@ -362,8 +361,7 @@ public class ReceiveCommits {
|
||||
List<AdvertiseRefsHook> advHooks = new ArrayList<AdvertiseRefsHook>(3);
|
||||
advHooks.add(new AdvertiseRefsHook() {
|
||||
@Override
|
||||
public void advertiseRefs(BaseReceivePack rp)
|
||||
throws ServiceMayNotContinueException {
|
||||
public void advertiseRefs(BaseReceivePack rp) {
|
||||
allRefs = rp.getAdvertisedRefs();
|
||||
if (allRefs == null) {
|
||||
allRefs = rp.getRepository().getAllRefs();
|
||||
@@ -372,8 +370,7 @@ public class ReceiveCommits {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void advertiseRefs(UploadPack uploadPack)
|
||||
throws ServiceMayNotContinueException {
|
||||
public void advertiseRefs(UploadPack uploadPack) {
|
||||
}
|
||||
});
|
||||
advHooks.add(rp.getAdvertiseRefsHook());
|
||||
@@ -1723,7 +1720,7 @@ public class ReceiveCommits {
|
||||
}
|
||||
|
||||
List<PatchSetApproval> patchSetApprovals =
|
||||
approvalsUtil.copyVetosToLatestPatchSet(db, change);
|
||||
approvalsUtil.copyVetosToPatchSet(db, newPatchSet.getId());
|
||||
|
||||
final Set<Account.Id> haveApprovals = new HashSet<Account.Id>();
|
||||
oldReviewers.clear();
|
||||
|
Reference in New Issue
Block a user