Merge "Pass commit IDs into DiffInfo"

This commit is contained in:
Shawn Pearce 2015-05-05 16:21:19 +00:00 committed by Gerrit Code Review
commit 5ecc22535f
4 changed files with 25 additions and 2 deletions

View File

@ -57,6 +57,8 @@ public class PatchScript {
protected boolean intralineFailure;
protected boolean intralineTimeout;
protected boolean binary;
protected transient String commitIdA;
protected transient String commitIdB;
public PatchScript(final Change.Key ck, final ChangeType ct, final String on,
final String nn, final FileMode om, final FileMode nm,
@ -65,7 +67,8 @@ public class PatchScript {
final List<Edit> e, final DisplayMethod ma, final DisplayMethod mb,
final String mta, final String mtb, final CommentDetail cd,
final List<Patch> hist, final boolean hf, final boolean id,
final boolean idf, final boolean idt, boolean bin) {
final boolean idf, final boolean idt, boolean bin,
final String cma, final String cmb) {
changeId = ck;
changeType = ct;
oldName = on;
@ -88,6 +91,8 @@ public class PatchScript {
intralineFailure = idf;
intralineTimeout = idt;
binary = bin;
commitIdA = cma;
commitIdB = cmb;
}
protected PatchScript() {
@ -200,4 +205,12 @@ public class PatchScript {
public boolean isBinary() {
return binary;
}
public String getCommitIdA() {
return commitIdA;
}
public String getCommitIdB() {
return commitIdB;
}
}

View File

@ -42,6 +42,8 @@ public class DiffInfo {
}
public static class FileMeta {
// The ID of the commit containing the file
public transient String commitId;
// The name of the file
public String name;
// The content type of the file

View File

@ -201,6 +201,7 @@ public class GetDiff implements RestReadView<FileResource> {
result.metaA.lines = ps.getA().size();
result.metaA.webLinks =
getFileWebLinks(state.getProject(), revA, result.metaA.name);
result.metaA.commitId = content.commitIdA;
}
if (ps.getDisplayMethodB() != DisplayMethod.NONE) {
@ -211,6 +212,7 @@ public class GetDiff implements RestReadView<FileResource> {
result.metaB.lines = ps.getB().size();
result.metaB.webLinks =
getFileWebLinks(state.getProject(), revB, result.metaB.name);
result.metaB.commitId = content.commitIdB;
}
if (intraline) {
@ -264,6 +266,8 @@ public class GetDiff implements RestReadView<FileResource> {
final SparseFileContent fileA;
final SparseFileContent fileB;
final boolean ignoreWS;
final String commitIdA;
final String commitIdB;
int nextA;
int nextB;
@ -273,6 +277,8 @@ public class GetDiff implements RestReadView<FileResource> {
fileA = ps.getA();
fileB = ps.getB();
ignoreWS = ps.isIgnoreWhitespace();
commitIdA = ps.getCommitIdA();
commitIdB = ps.getCommitIdB();
}
void addCommon(int end) {

View File

@ -214,7 +214,9 @@ class PatchScriptBuilder {
a.displayMethod, b.displayMethod, a.mimeType.toString(),
b.mimeType.toString(), comments, history, hugeFile,
intralineDifferenceIsPossible, intralineFailure, intralineTimeout,
content.getPatchType() == Patch.PatchType.BINARY);
content.getPatchType() == Patch.PatchType.BINARY,
aId == null ? null : aId.getName(),
bId == null ? null : bId.getName());
}
private static boolean isModify(PatchListEntry content) {