Related Changes: Link to ChangeScreen if change is merged or abandoned

For changes in the 'Related Changes' tab that are closed the link was
bringing the user to GitWeb, and not as expected to the ChangeScreen.

As result of this change, merged and abandoned changes are no longer
decorated with the black dot. The decoration will be fixed in a
follow-up change since this requires to transfer the change state to
the client.

Bug: issue 2894
Change-Id: If087a60d08223d9451173d48cca8596f5c13d499
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin 2014-12-09 14:24:10 +01:00
parent db62816d15
commit d3b6e1d531

View File

@ -25,6 +25,7 @@ import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
import com.google.gerrit.reviewdb.client.RevId;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CommonConverters;
import com.google.gerrit.server.git.GitRepositoryManager;
@ -119,6 +120,18 @@ public class GetRelated implements RestReadView<RevisionResource> {
if (p != null) {
g = changes.get(p.getId().getParentKey());
added.add(p.getId().getParentKey());
} else {
// check if there is a merged or abandoned change for this commit
ReviewDb db = dbProvider.get();
for (PatchSet ps : db.patchSets().byRevision(new RevId(c.name())).toList()) {
Change change = db.changes().get(ps.getId().getParentKey());
if (change != null && change.getDest().equals(rsrc.getChange().getDest())) {
p = ps;
g = change;
added.add(g.getId());
break;
}
}
}
parents.add(new ChangeAndCommit(g, p, c));
}