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:
Colby Ranger
2012-11-28 15:44:57 -08:00
parent a78f2db980
commit c627bc54d0
4 changed files with 13 additions and 34 deletions

View File

@@ -436,10 +436,6 @@ public final class Change {
lastUpdatedOn = new Timestamp(System.currentTimeMillis()); lastUpdatedOn = new Timestamp(System.currentTimeMillis());
} }
public int getNumberOfPatchSets() {
return nbrPatchSets;
}
public String getSortKey() { public String getSortKey() {
return sortKey; return sortKey;
} }

View File

@@ -68,38 +68,25 @@ public class ApprovalsUtil {
} }
/** /**
* Moves the PatchSetApprovals to the last PatchSet on the change while * Moves the PatchSetApprovals to the specified PatchSet on the change from
* keeping the vetos. * the prior PatchSet, 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.
* *
* @param db database connection to use for updates. * @param db database connection to use for updates.
* @param change Change to update * @param dest PatchSet to copy to
* @throws OrmException * @throws OrmException
* @return List<PatchSetApproval> The previous approvals * @return List<PatchSetApproval> The previous approvals
*/ */
public List<PatchSetApproval> copyVetosToLatestPatchSet(ReviewDb db, public List<PatchSetApproval> copyVetosToPatchSet(ReviewDb db,
Change change) throws OrmException { PatchSet.Id dest) throws OrmException {
PatchSet.Id source; PatchSet.Id source;
if (change.getNumberOfPatchSets() > 1) { if (dest.get() > 1) {
source = new PatchSet.Id(change.getId(), change.getNumberOfPatchSets() - 1); source = new PatchSet.Id(dest.getParentKey(), dest.get() - 1);
} else { } else {
throw new OrmException("Previous patch set could not be found"); throw new OrmException("Previous patch set could not be found");
} }
PatchSet.Id dest = change.currPatchSetId(); List<PatchSetApproval> patchSetApprovals =
List<PatchSetApproval> patchSetApprovals = db.patchSetApprovals().byChange(change.getId()).toList(); db.patchSetApprovals().byChange(dest.getParentKey()).toList();
for (PatchSetApproval a : patchSetApprovals) { for (PatchSetApproval a : patchSetApprovals) {
// ApprovalCategory.SUBMIT is still in db but not relevant in git-store // ApprovalCategory.SUBMIT is still in db but not relevant in git-store
if (!ApprovalCategory.SUBMIT.equals(a.getCategoryId())) { if (!ApprovalCategory.SUBMIT.equals(a.getCategoryId())) {

View File

@@ -189,7 +189,6 @@ public class RebaseChange {
* @param db the ReviewDb * @param db the ReviewDb
* @param destBranch the destination branch * @param destBranch the destination branch
* @param git the repository * @param git the repository
* @param rw the RevWalk
* @param patchSetAncestors the original PatchSetAncestor of the given patch * @param patchSetAncestors the original PatchSetAncestor of the given patch
* set that should be based * set that should be based
* @param depPatchSetList the original patch set list on which the rebased * @param depPatchSetList the original patch set list on which the rebased
@@ -393,7 +392,7 @@ public class RebaseChange {
"Change %s was modified", change.getId())); "Change %s was modified", change.getId()));
} }
approvalsUtil.copyVetosToLatestPatchSet(change); approvalsUtil.copyVetosToPatchSet(db, change.currentPatchSetId());
final ChangeMessage cmsg = final ChangeMessage cmsg =
new ChangeMessage(new ChangeMessage.Key(change.getId(), new ChangeMessage(new ChangeMessage.Key(change.getId(),

View File

@@ -111,7 +111,6 @@ import org.eclipse.jgit.transport.BaseReceivePack;
import org.eclipse.jgit.transport.ReceiveCommand; import org.eclipse.jgit.transport.ReceiveCommand;
import org.eclipse.jgit.transport.ReceiveCommand.Result; import org.eclipse.jgit.transport.ReceiveCommand.Result;
import org.eclipse.jgit.transport.ReceivePack; import org.eclipse.jgit.transport.ReceivePack;
import org.eclipse.jgit.transport.ServiceMayNotContinueException;
import org.eclipse.jgit.transport.UploadPack; import org.eclipse.jgit.transport.UploadPack;
import org.eclipse.jgit.util.SystemReader; import org.eclipse.jgit.util.SystemReader;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -362,8 +361,7 @@ public class ReceiveCommits {
List<AdvertiseRefsHook> advHooks = new ArrayList<AdvertiseRefsHook>(3); List<AdvertiseRefsHook> advHooks = new ArrayList<AdvertiseRefsHook>(3);
advHooks.add(new AdvertiseRefsHook() { advHooks.add(new AdvertiseRefsHook() {
@Override @Override
public void advertiseRefs(BaseReceivePack rp) public void advertiseRefs(BaseReceivePack rp) {
throws ServiceMayNotContinueException {
allRefs = rp.getAdvertisedRefs(); allRefs = rp.getAdvertisedRefs();
if (allRefs == null) { if (allRefs == null) {
allRefs = rp.getRepository().getAllRefs(); allRefs = rp.getRepository().getAllRefs();
@@ -372,8 +370,7 @@ public class ReceiveCommits {
} }
@Override @Override
public void advertiseRefs(UploadPack uploadPack) public void advertiseRefs(UploadPack uploadPack) {
throws ServiceMayNotContinueException {
} }
}); });
advHooks.add(rp.getAdvertiseRefsHook()); advHooks.add(rp.getAdvertiseRefsHook());
@@ -1723,7 +1720,7 @@ public class ReceiveCommits {
} }
List<PatchSetApproval> patchSetApprovals = List<PatchSetApproval> patchSetApprovals =
approvalsUtil.copyVetosToLatestPatchSet(db, change); approvalsUtil.copyVetosToPatchSet(db, newPatchSet.getId());
final Set<Account.Id> haveApprovals = new HashSet<Account.Id>(); final Set<Account.Id> haveApprovals = new HashSet<Account.Id>();
oldReviewers.clear(); oldReviewers.clear();