Merge "Add parent(s) revision information to output of query."
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/events/EventFactory.java b/gerrit-server/src/main/java/com/google/gerrit/server/events/EventFactory.java
index 4d34b71..c538aa6 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/events/EventFactory.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/events/EventFactory.java
@@ -39,6 +39,8 @@
import com.google.inject.Singleton;
import org.eclipse.jgit.lib.ObjectId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
@@ -48,6 +50,7 @@
@Singleton
public class EventFactory {
+ private static final Logger log = LoggerFactory.getLogger(EventFactory.class);
private final AccountCache accountCache;
private final Provider<String> urlProvider;
private final ApprovalTypes approvalTypes;
@@ -273,6 +276,20 @@
p.ref = patchSet.getRefName();
p.uploader = asAccountAttribute(patchSet.getUploader());
p.createdOn = patchSet.getCreatedOn().getTime() / 1000L;
+ try {
+ final ReviewDb db = schema.open();
+ try {
+ p.parents = new ArrayList<String>();
+ for (PatchSetAncestor a : db.patchSetAncestors().ancestorsOf(
+ patchSet.getId())) {
+ p.parents.add(a.getAncestorRevision().get());
+ }
+ } finally {
+ db.close();
+ }
+ } catch (OrmException e) {
+ log.error("Cannot load patch set data for " + patchSet.getId(), e);
+ }
return p;
}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/events/PatchSetAttribute.java b/gerrit-server/src/main/java/com/google/gerrit/server/events/PatchSetAttribute.java
index dca4438..f726ce3 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/events/PatchSetAttribute.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/events/PatchSetAttribute.java
@@ -17,13 +17,14 @@
import java.util.List;
public class PatchSetAttribute {
- public String number;
- public String revision;
- public String ref;
- public AccountAttribute uploader;
- public Long createdOn;
+ public String number;
+ public String revision;
+ public List<String> parents;
+ public String ref;
+ public AccountAttribute uploader;
+ public Long createdOn;
- public List<ApprovalAttribute> approvals;
- public List<PatchSetCommentAttribute> comments;
- public List<PatchAttribute> files;
+ public List<ApprovalAttribute> approvals;
+ public List<PatchSetCommentAttribute> comments;
+ public List<PatchAttribute> files;
}