Remove duplicate retrieving patchset code in editCommitMessage()

There are two places to retrieve the same patchset from DB in
method ChangeUtil.editCommitMessage(), we remove the last one.

Change-Id: Ib517b52aba0774580a9462696e073105724e75a3
This commit is contained in:
Yang Zhenhui
2013-03-05 15:41:57 +08:00
committed by Bruce Zu
parent 3f13a8ff37
commit c160b09d7e

View File

@@ -333,8 +333,8 @@ public class ChangeUtil {
MissingObjectException, IncorrectObjectTypeException, IOException, MissingObjectException, IncorrectObjectTypeException, IOException,
InvalidChangeOperationException, PatchSetInfoNotAvailableException { InvalidChangeOperationException, PatchSetInfoNotAvailableException {
final Change.Id changeId = patchSetId.getParentKey(); final Change.Id changeId = patchSetId.getParentKey();
final PatchSet patch = db.patchSets().get(patchSetId); final PatchSet originalPS = db.patchSets().get(patchSetId);
if (patch == null) { if (originalPS == null) {
throw new NoSuchChangeException(changeId); throw new NoSuchChangeException(changeId);
} }
@@ -345,7 +345,7 @@ public class ChangeUtil {
final RevWalk revWalk = new RevWalk(git); final RevWalk revWalk = new RevWalk(git);
try { try {
RevCommit commit = RevCommit commit =
revWalk.parseCommit(ObjectId.fromString(patch.getRevision().get())); revWalk.parseCommit(ObjectId.fromString(originalPS.getRevision().get()));
if (commit.getFullMessage().equals(message)) { if (commit.getFullMessage().equals(message)) {
throw new InvalidChangeOperationException("New commit message cannot be same as existing commit message"); throw new InvalidChangeOperationException("New commit message cannot be same as existing commit message");
} }
@@ -372,7 +372,6 @@ public class ChangeUtil {
oi.release(); oi.release();
} }
final PatchSet originalPS = db.patchSets().get(patchSetId);
PatchSet.Id id = nextPatchSetId(git, change.currentPatchSetId()); PatchSet.Id id = nextPatchSetId(git, change.currentPatchSetId());
final PatchSet newPatchSet = new PatchSet(id); final PatchSet newPatchSet = new PatchSet(id);
newPatchSet.setCreatedOn(new Timestamp(now.getTime())); newPatchSet.setCreatedOn(new Timestamp(now.getTime()));