Show the depends on and needed by lists on a change page
The lists are automatically expanded open if there is a dependency which is not yet merged and we are still open. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -152,9 +152,8 @@ public class ChangeListServiceImpl extends BaseServiceImplementation implements
|
||||
final Set<Change.Id> starred, final AccountInfoCacheFactory accts) {
|
||||
final ArrayList<ChangeInfo> r = new ArrayList<ChangeInfo>();
|
||||
for (final Change c : rs) {
|
||||
final ChangeInfo ci = new ChangeInfo(c);
|
||||
final ChangeInfo ci = new ChangeInfo(c, accts);
|
||||
ci.setStarred(starred.contains(ci.getId()));
|
||||
accts.want(c.getOwner());
|
||||
r.add(ci);
|
||||
}
|
||||
return r;
|
||||
|
||||
@@ -191,7 +191,21 @@ public class ChangeScreen extends Screen {
|
||||
addPatchSets(detail);
|
||||
addMessages(detail);
|
||||
|
||||
// If any dependency change is still open, show our dependency list.
|
||||
//
|
||||
boolean depsOpen = false;
|
||||
if (!detail.getChange().getStatus().isClosed()
|
||||
&& detail.getDependsOn() != null) {
|
||||
for (final ChangeInfo ci : detail.getDependsOn()) {
|
||||
if (ci.getStatus() != Change.Status.MERGED) {
|
||||
depsOpen = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
descriptionPanel.setOpen(true);
|
||||
dependenciesPanel.setOpen(depsOpen);
|
||||
approvalsPanel.setOpen(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.gerrit.client.reviewdb.Change;
|
||||
import com.google.gerrit.client.reviewdb.ChangeApproval;
|
||||
import com.google.gerrit.client.reviewdb.ChangeMessage;
|
||||
import com.google.gerrit.client.reviewdb.PatchSet;
|
||||
import com.google.gerrit.client.reviewdb.PatchSetAncestor;
|
||||
import com.google.gerrit.client.reviewdb.ReviewDb;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
|
||||
@@ -27,7 +28,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** Detail necessary to display{@link ChangeScreen}. */
|
||||
public class ChangeDetail {
|
||||
@@ -83,6 +86,51 @@ public class ChangeDetail {
|
||||
if (currentPatchSetId != null) {
|
||||
currentDetail = new PatchSetDetail();
|
||||
currentDetail.load(db, getCurrentPatchSet());
|
||||
|
||||
final HashSet<Change.Id> changesToGet = new HashSet<Change.Id>();
|
||||
final List<Change.Id> ancestorOrder = new ArrayList<Change.Id>();
|
||||
for (final PatchSetAncestor a : db.patchSetAncestors().ancestorsOf(
|
||||
currentPatchSetId).toList()) {
|
||||
for (PatchSet p : db.patchSets().byRevision(a.getAncestorRevision())) {
|
||||
final Change.Id ck = p.getKey().getParentKey();
|
||||
if (changesToGet.add(ck)) {
|
||||
ancestorOrder.add(ck);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final String cprev = getCurrentPatchSet().getRevision();
|
||||
final List<PatchSetAncestor> descendants =
|
||||
cprev != null ? db.patchSetAncestors().descendantsOf(cprev).toList()
|
||||
: Collections.<PatchSetAncestor> emptyList();
|
||||
for (final PatchSetAncestor a : descendants) {
|
||||
changesToGet.add(a.getPatchSet().getParentKey());
|
||||
}
|
||||
final Map<Change.Id, Change> m =
|
||||
db.changes().toMap(db.changes().get(changesToGet));
|
||||
|
||||
dependsOn = new ArrayList<ChangeInfo>();
|
||||
for (final Change.Id a : ancestorOrder) {
|
||||
final Change ac = m.get(a);
|
||||
if (ac != null) {
|
||||
dependsOn.add(new ChangeInfo(ac, acc));
|
||||
}
|
||||
}
|
||||
|
||||
neededBy = new ArrayList<ChangeInfo>();
|
||||
for (final PatchSetAncestor a : descendants) {
|
||||
final Change ac = m.get(a.getPatchSet().getParentKey());
|
||||
if (ac != null) {
|
||||
neededBy.add(new ChangeInfo(ac, acc));
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(neededBy, new Comparator<ChangeInfo>() {
|
||||
public int compare(final ChangeInfo o1, final ChangeInfo o2) {
|
||||
// TODO sort neededBy by something more reasonable than Id
|
||||
return o1.getId().get() - o2.getId().get();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
accounts = acc.create();
|
||||
|
||||
@@ -28,12 +28,14 @@ public class ChangeInfo {
|
||||
protected ChangeInfo() {
|
||||
}
|
||||
|
||||
public ChangeInfo(final Change c) {
|
||||
public ChangeInfo(final Change c, final AccountInfoCacheFactory acc) {
|
||||
id = c.getKey();
|
||||
owner = c.getOwner();
|
||||
subject = c.getSubject();
|
||||
status = c.getStatus();
|
||||
project = new ProjectInfo(c.getDest().getParentKey());
|
||||
|
||||
acc.want(owner);
|
||||
}
|
||||
|
||||
public Change.Id getId() {
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright 2008 Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.reviewdb;
|
||||
|
||||
import com.google.gwtorm.client.Column;
|
||||
import com.google.gwtorm.client.IntKey;
|
||||
|
||||
/** Ancestors of a {@link PatchSet} that the PatchSet depends upon. */
|
||||
public final class PatchSetAncestor {
|
||||
public static class Key extends IntKey<PatchSet.Id> {
|
||||
@Column(name = Column.NONE)
|
||||
protected PatchSet.Id patchSetId;
|
||||
|
||||
@Column
|
||||
protected int position;
|
||||
|
||||
protected Key() {
|
||||
patchSetId = new PatchSet.Id();
|
||||
}
|
||||
|
||||
public Key(final PatchSet.Id psId, final int pos) {
|
||||
this.patchSetId = psId;
|
||||
this.position = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PatchSet.Id getParentKey() {
|
||||
return patchSetId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int get() {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = Column.NONE)
|
||||
protected Key key;
|
||||
|
||||
@Column(length = 40)
|
||||
protected String ancestorRevision;
|
||||
|
||||
protected PatchSetAncestor() {
|
||||
}
|
||||
|
||||
public PatchSetAncestor(final PatchSetAncestor.Key k, final String rev) {
|
||||
key = k;
|
||||
ancestorRevision = rev;
|
||||
}
|
||||
|
||||
public PatchSetAncestor.Key getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public PatchSet.Id getPatchSet() {
|
||||
return key.patchSetId;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return key.position;
|
||||
}
|
||||
|
||||
public String getAncestorRevision() {
|
||||
return ancestorRevision;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright 2008 Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.client.reviewdb;
|
||||
|
||||
import com.google.gwtorm.client.Access;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.gwtorm.client.PrimaryKey;
|
||||
import com.google.gwtorm.client.Query;
|
||||
import com.google.gwtorm.client.ResultSet;
|
||||
|
||||
public interface PatchSetAncestorAccess extends
|
||||
Access<PatchSetAncestor, PatchSetAncestor.Key> {
|
||||
@PrimaryKey("key")
|
||||
PatchSetAncestor get(PatchSetAncestor.Key key) throws OrmException;
|
||||
|
||||
@Query("WHERE key.patchSetId = ? ORDER BY key.position")
|
||||
ResultSet<PatchSetAncestor> ancestorsOf(PatchSet.Id id) throws OrmException;
|
||||
|
||||
@Query("WHERE ancestorRevision = ?")
|
||||
ResultSet<PatchSetAncestor> descendantsOf(String revision)
|
||||
throws OrmException;
|
||||
}
|
||||
@@ -77,6 +77,9 @@ public interface ReviewDb extends Schema {
|
||||
@Relation
|
||||
PatchSetInfoAccess patchSetInfo();
|
||||
|
||||
@Relation
|
||||
PatchSetAncestorAccess patchSetAncestors();
|
||||
|
||||
@Relation
|
||||
PatchAccess patches();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user