PatchListCache: Add method for getting old ID of a patch set
For a batch NoteDb rebuilding job with its own PatchListCache implementation, this method is much easier to implement than the more generic get methods. Plus, it simplifies the code in setCommentRevId. Change-Id: Iee126283e04328f2a497d99efe0f4f9cdc961590
This commit is contained in:
@@ -41,7 +41,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.notedb.DraftCommentNotes;
|
||||
import com.google.gerrit.server.notedb.NotesMigration;
|
||||
import com.google.gerrit.server.patch.PatchList;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
@@ -363,14 +362,9 @@ public class PatchLineCommentsUtil {
|
||||
"cannot set RevId for patch set %s on comment %s", ps.getId(), c);
|
||||
if (c.getRevId() == null) {
|
||||
try {
|
||||
if (Side.fromShort(c.getSide()) == Side.REVISION) {
|
||||
c.setRevId(ps.getRevision());
|
||||
} else {
|
||||
PatchList patchList = cache.get(change, ps);
|
||||
c.setRevId((c.getSide() == (short) 0)
|
||||
? new RevId(ObjectId.toString(patchList.getOldId()))
|
||||
: new RevId(ObjectId.toString(patchList.getNewId())));
|
||||
}
|
||||
c.setRevId(Side.fromShort(c.getSide()) == Side.PARENT
|
||||
? new RevId(ObjectId.toString(cache.getOldId(change, ps)))
|
||||
: ps.getRevision());
|
||||
} catch (PatchListNotAvailableException e) {
|
||||
throw new OrmException(e);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
|
||||
/** Provides a cached list of {@link PatchListEntry}. */
|
||||
public interface PatchListCache {
|
||||
PatchList get(PatchListKey key, Project.NameKey project)
|
||||
@@ -26,6 +28,9 @@ public interface PatchListCache {
|
||||
PatchList get(Change change, PatchSet patchSet)
|
||||
throws PatchListNotAvailableException;
|
||||
|
||||
ObjectId getOldId(Change change, PatchSet patchSet)
|
||||
throws PatchListNotAvailableException;
|
||||
|
||||
IntraLineDiff getIntraLineDiff(IntraLineDiffKey key,
|
||||
IntraLineDiffArgs args);
|
||||
}
|
||||
|
||||
@@ -106,6 +106,12 @@ public class PatchListCacheImpl implements PatchListCache {
|
||||
return get(new PatchListKey(null, b, ws), project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectId getOldId(Change change, PatchSet patchSet)
|
||||
throws PatchListNotAvailableException {
|
||||
return get(change, patchSet).getOldId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntraLineDiff getIntraLineDiff(IntraLineDiffKey key,
|
||||
IntraLineDiffArgs args) {
|
||||
|
||||
Reference in New Issue
Block a user