Merge changes I1a5d044d,If087a60d

* changes:
  Related Changes: Decorate merged and abandoned changes
  Related Changes: Link to ChangeScreen if change is merged or abandoned
This commit is contained in:
Shawn Pearce
2015-01-01 18:45:08 +00:00
committed by Gerrit Code Review
8 changed files with 51 additions and 1 deletions

View File

@@ -3387,6 +3387,7 @@ a related change and commit.
|===========================
|Field Name ||Description
|`change_id` |optional|The Change-Id of the change.
|`status` |optional|The status of the change.
|`commit` ||The commit as a
link:#commit-info[CommitInfo] entity.
|`_change_number` |optional|The change number.

View File

@@ -538,7 +538,7 @@ this change and the descendant change now needs to be rebased. Please
note that following the link to an indirect descendant change may
result in a completely different related changes listing.
** [[closed-ancestor]]Black Dot:
** [[merged-ancestor]]Black Dot:
+
Indicates a merged ancestor, e.g. the commit was directly pushed into
the repository bypassing code review, or the ancestor change was
@@ -547,6 +547,10 @@ the user has accidentally pushed the commit to the wrong branch, e.g.
the commit was done on `branch-a`, but was then pushed to
`refs/for/branch-b`.
** [[abandoned-change]]Dark Red Dot:
+
Indicates an abandoned change.
+
image::images/user-review-ui-change-screen-related-changes-indicators.png[width=800, link="images/user-review-ui-change-screen-related-changes-indicators.png"]

View File

@@ -47,4 +47,6 @@ interface ChangeConstants extends Constants {
String sameTopicTooltip();
String noChanges();
String indirectAncestor();
String merged();
String abandoned();
}

View File

@@ -28,3 +28,5 @@ sameTopic = Same Topic
sameTopicTooltip = Changes with the same topic
noChanges = No Changes
indirectAncestor = Indirect ancestor
merged = Merged
abandoned = Abandoned

View File

@@ -55,6 +55,8 @@ public class RelatedChanges extends TabPanel {
String current();
String gitweb();
String indirect();
String abandoned();
String merged();
String notCurrent();
String pointer();
String row();
@@ -342,6 +344,13 @@ public class RelatedChanges extends TabPanel {
}
public final native String id() /*-{ return this.change_id }-*/;
public final Change.Status status() {
String s = statusRaw();
return s != null ? Change.Status.valueOf(s) : null;
}
private final native String statusRaw() /*-{ return this.status; }-*/;
public final native CommitInfo commit() /*-{ return this.commit }-*/;
final native String branch() /*-{ return this.branch }-*/;

View File

@@ -20,6 +20,7 @@ import com.google.gerrit.client.change.RelatedChanges.ChangeAndCommit;
import com.google.gerrit.client.changes.ChangeInfo.CommitInfo;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JsArray;
@@ -301,6 +302,14 @@ class RelatedChangesTab implements IsWidget {
sb.setStyleName(RelatedChanges.R.css().notCurrent());
sb.setAttribute("title", Util.C.notCurrent());
sb.append('\u25CF');
} else if (Change.Status.MERGED == info.status()) {
sb.setStyleName(RelatedChanges.R.css().merged());
sb.setAttribute("title", Resources.C.merged());
sb.append('\u25CF');
} else if (Change.Status.ABANDONED == info.status()) {
sb.setStyleName(RelatedChanges.R.css().abandoned());
sb.setAttribute("title", Resources.C.abandoned());
sb.append('\u25CF');
} else {
sb.setStyleName(RelatedChanges.R.css().current());
}

View File

@@ -68,6 +68,8 @@
.current,
.gitweb,
.indirect,
.abandoned,
.merged,
.notCurrent {
display: inline-block;
text-align: center;
@@ -75,6 +77,7 @@
width: 12px;
}
.merged,
.gitweb {
color: #000;
}
@@ -84,6 +87,10 @@
font-weight: bold;
}
.abandoned {
color: #900; /* dark red */
}
.notCurrent {
color: #FFA62F; /* orange */
}

View File

@@ -20,11 +20,13 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.common.ChangeStatus;
import com.google.gerrit.extensions.common.CommitInfo;
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 +121,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));
}
@@ -278,6 +292,7 @@ public class GetRelated implements RestReadView<RevisionResource> {
public static class ChangeAndCommit {
public String changeId;
public ChangeStatus status;
public CommitInfo commit;
public Integer _changeNumber;
public Integer _revisionNumber;
@@ -286,6 +301,7 @@ public class GetRelated implements RestReadView<RevisionResource> {
ChangeAndCommit(@Nullable Change change, @Nullable PatchSet ps, RevCommit c) {
if (change != null) {
changeId = change.getKey().get();
status = change.getStatus().asChangeStatus();
_changeNumber = change.getChangeId();
_revisionNumber = ps != null ? ps.getPatchSetId() : null;
PatchSet.Id curr = change.currentPatchSetId();