Mark hunks which are present due to a rebase when diffing patch sets
The diff between two patch sets contains hunks which weren't introduced by either patch set if a rebase occurred between those patch sets. Previous optimizations for this case simply omitted all files which aren't touched by either of the patch sets. This change goes one step further: All hunks which can clearly be identified as being introduced by a rebase are marked. In case of doubt (e.g. they overlap with a regular hunk), they aren't marked. To be consistent with the previous behavior, we exclude all files from the result which only contain hunks due to rebase. In some cases (e.g. a patch set touches 'fileA' but all identified hunks were introduced by the rebase), this rule can be stricter than the previously mentioned (as the previous rule would still show file 'fileA' but we exclude it now). Hunks which are introduced by a rebase are identified by computing the diff between the parents of the two patch sets and transforming the result to differences in terms of treeA of patch set A and treeB of patch set B. This follows a suggestion which was posted as a comment (https://gerrit-review.googlesource.com/c/33091/5//COMMIT_MSG#7) in change I63d3a21ad4f. As we always determine which hunks are introduced by a rebase when two commits are explicitly specified which don't share a common parent, we will determine those hunks even when we compute the diff between the parents of the patch sets provided that those parents fulfill the condition of being separated by a rebase. Those situations should be rare and hence we refrain from adding optimizations for this case for the moment. Bug: Issue 217 Change-Id: If06381d506d360f0e3d24d078dcb54692698e766
This commit is contained in:
@@ -21,6 +21,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
import com.google.gerrit.reviewdb.client.Patch.ChangeType;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.eclipse.jgit.diff.Edit;
|
||||
|
||||
public class PatchScript {
|
||||
@@ -47,6 +48,7 @@ public class PatchScript {
|
||||
private SparseFileContent a;
|
||||
private SparseFileContent b;
|
||||
private List<Edit> edits;
|
||||
private Set<Edit> editsDueToRebase;
|
||||
private DisplayMethod displayMethodA;
|
||||
private DisplayMethod displayMethodB;
|
||||
private transient String mimeTypeA;
|
||||
@@ -62,30 +64,31 @@ public class PatchScript {
|
||||
private transient String commitIdB;
|
||||
|
||||
public PatchScript(
|
||||
final Change.Key ck,
|
||||
final ChangeType ct,
|
||||
final String on,
|
||||
final String nn,
|
||||
final FileMode om,
|
||||
final FileMode nm,
|
||||
final List<String> h,
|
||||
final DiffPreferencesInfo dp,
|
||||
final SparseFileContent ca,
|
||||
final SparseFileContent cb,
|
||||
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,
|
||||
Change.Key ck,
|
||||
ChangeType ct,
|
||||
String on,
|
||||
String nn,
|
||||
FileMode om,
|
||||
FileMode nm,
|
||||
List<String> h,
|
||||
DiffPreferencesInfo dp,
|
||||
SparseFileContent ca,
|
||||
SparseFileContent cb,
|
||||
List<Edit> e,
|
||||
Set<Edit> editsDueToRebase,
|
||||
DisplayMethod ma,
|
||||
DisplayMethod mb,
|
||||
String mta,
|
||||
String mtb,
|
||||
CommentDetail cd,
|
||||
List<Patch> hist,
|
||||
boolean hf,
|
||||
boolean id,
|
||||
boolean idf,
|
||||
boolean idt,
|
||||
boolean bin,
|
||||
final String cma,
|
||||
final String cmb) {
|
||||
String cma,
|
||||
String cmb) {
|
||||
changeId = ck;
|
||||
changeType = ct;
|
||||
oldName = on;
|
||||
@@ -97,6 +100,7 @@ public class PatchScript {
|
||||
a = ca;
|
||||
b = cb;
|
||||
edits = e;
|
||||
this.editsDueToRebase = editsDueToRebase;
|
||||
displayMethodA = ma;
|
||||
displayMethodB = mb;
|
||||
mimeTypeA = mta;
|
||||
@@ -210,6 +214,10 @@ public class PatchScript {
|
||||
return edits;
|
||||
}
|
||||
|
||||
public Set<Edit> getEditsDueToRebase() {
|
||||
return editsDueToRebase;
|
||||
}
|
||||
|
||||
public boolean isBinary() {
|
||||
return binary;
|
||||
}
|
||||
|
Reference in New Issue
Block a user