Show old file paths on renamed files
In the side-by-side view its hard to know that a file was actually a rename from somewhere else. Make it clear by showing the old path in the column header when its not the same location. Change-Id: I1d0e2fd370d34f9d4da481f7034380de0099a6af Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import com.google.gerrit.prettify.common.SparseFileContent;
|
||||
import com.google.gerrit.prettify.common.SparseHtmlFile;
|
||||
import com.google.gerrit.reviewdb.Change;
|
||||
import com.google.gerrit.reviewdb.Patch;
|
||||
import com.google.gerrit.reviewdb.Patch.ChangeType;
|
||||
|
||||
import org.eclipse.jgit.diff.Edit;
|
||||
|
||||
@@ -34,6 +35,9 @@ public class PatchScript {
|
||||
}
|
||||
|
||||
protected Change.Key changeId;
|
||||
protected ChangeType changeType;
|
||||
protected String oldName;
|
||||
protected String newName;
|
||||
protected List<String> header;
|
||||
protected PatchScriptSettings settings;
|
||||
protected SparseFileContent a;
|
||||
@@ -44,11 +48,15 @@ public class PatchScript {
|
||||
protected CommentDetail comments;
|
||||
protected List<Patch> history;
|
||||
|
||||
public PatchScript(final Change.Key ck, final List<String> h,
|
||||
final PatchScriptSettings s, final SparseFileContent ca,
|
||||
final SparseFileContent cb, final List<Edit> e, final DisplayMethod ma,
|
||||
final DisplayMethod mb, final CommentDetail cd, final List<Patch> hist) {
|
||||
public PatchScript(final Change.Key ck, final ChangeType ct, final String on,
|
||||
final String nn, final List<String> h, final PatchScriptSettings s,
|
||||
final SparseFileContent ca, final SparseFileContent cb,
|
||||
final List<Edit> e, final DisplayMethod ma, final DisplayMethod mb,
|
||||
final CommentDetail cd, final List<Patch> hist) {
|
||||
changeId = ck;
|
||||
changeType = ct;
|
||||
oldName = on;
|
||||
newName = nn;
|
||||
header = h;
|
||||
settings = s;
|
||||
a = ca;
|
||||
@@ -79,6 +87,18 @@ public class PatchScript {
|
||||
return header;
|
||||
}
|
||||
|
||||
public ChangeType getChangeType() {
|
||||
return changeType;
|
||||
}
|
||||
|
||||
public String getOldName() {
|
||||
return oldName;
|
||||
}
|
||||
|
||||
public String getNewName() {
|
||||
return newName;
|
||||
}
|
||||
|
||||
public CommentDetail getCommentDetail() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.google.gerrit.prettify.common.EditList;
|
||||
import com.google.gerrit.prettify.common.SparseHtmlFile;
|
||||
import com.google.gerrit.reviewdb.Patch;
|
||||
import com.google.gerrit.reviewdb.PatchLineComment;
|
||||
import com.google.gerrit.reviewdb.Patch.ChangeType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
|
||||
import com.google.gwtexpui.safehtml.client.SafeHtml;
|
||||
@@ -209,7 +210,12 @@ public class SideBySideTable extends AbstractPatchContentTable {
|
||||
m.openTd();
|
||||
m.setStyleName(Gerrit.RESOURCES.css().fileColumnHeader());
|
||||
m.setAttribute("width", "50%");
|
||||
m.append(PatchUtil.C.patchHeaderOld());
|
||||
if (script.getChangeType() == ChangeType.RENAMED
|
||||
|| script.getChangeType() == ChangeType.COPIED) {
|
||||
m.append(script.getOldName());
|
||||
} else {
|
||||
m.append(PatchUtil.C.patchHeaderOld());
|
||||
}
|
||||
m.br();
|
||||
if (0 < script.getA().size()) {
|
||||
if (idSideA == null) {
|
||||
|
||||
@@ -63,7 +63,6 @@ class PatchScriptBuilder {
|
||||
}
|
||||
};
|
||||
|
||||
private final List<String> header;
|
||||
private Repository db;
|
||||
private Change change;
|
||||
private PatchScriptSettings settings;
|
||||
@@ -79,7 +78,6 @@ class PatchScriptBuilder {
|
||||
|
||||
@Inject
|
||||
PatchScriptBuilder(final FileTypeRegistry ftr) {
|
||||
header = new ArrayList<String>();
|
||||
a = new Side();
|
||||
b = new Side();
|
||||
registry = ftr;
|
||||
@@ -110,7 +108,8 @@ class PatchScriptBuilder {
|
||||
// For a diff --cc format we don't support converting it into
|
||||
// a patch script. Instead treat everything as a file header.
|
||||
//
|
||||
return new PatchScript(change.getKey(), content.getHeaderLines(),
|
||||
return new PatchScript(change.getKey(), content.getChangeType(), content
|
||||
.getOldName(), content.getNewName(), content.getHeaderLines(),
|
||||
settings, a.dst, b.dst, Collections.<Edit> emptyList(),
|
||||
a.displayMethod, b.displayMethod, comments, history);
|
||||
}
|
||||
@@ -123,7 +122,6 @@ class PatchScriptBuilder {
|
||||
|
||||
edits = new ArrayList<Edit>(content.getEdits());
|
||||
ensureCommentsVisible(comments);
|
||||
header.addAll(content.getHeaderLines());
|
||||
|
||||
if (a.mode == FileMode.GITLINK || b.mode == FileMode.GITLINK) {
|
||||
|
||||
@@ -158,8 +156,10 @@ class PatchScriptBuilder {
|
||||
packContent(settings.getWhitespace() != Whitespace.IGNORE_NONE);
|
||||
}
|
||||
|
||||
return new PatchScript(change.getKey(), header, settings, a.dst, b.dst,
|
||||
edits, a.displayMethod, b.displayMethod, comments, history);
|
||||
return new PatchScript(change.getKey(), content.getChangeType(), content
|
||||
.getOldName(), content.getNewName(), content.getHeaderLines(),
|
||||
settings, a.dst, b.dst, edits, a.displayMethod, b.displayMethod,
|
||||
comments, history);
|
||||
}
|
||||
|
||||
private static String oldName(final PatchListEntry entry) {
|
||||
|
||||
Reference in New Issue
Block a user