Remove some false negatives for edits due to rebase
When intraline diffs are enabled, we apply some optimizations (see Ie9f4210c2). Those optimization modify identified edits. Unfortunately, this clashes with the highlighting of edits due to rebase. As we use JGit's Edit class to represent an edit, we don't have a way to pass any additional details along with an edit. For this reason, we compare all identified edits with the ones we know are introduced by a rebase right before we send the diff results out of the Gerrit server. This only works if the identified edits aren't modified after being computed by JGit's diff mechanisms. A side effect of this issue is that the number of added/deleted lines for a file on the change screen doesn't always match the number of added/deleted lines of the regular hunks shown on the diff screen when comparing patch sets. The reason is that we use the non-intraline diffs for the numbers shown on the change screen even when intraline diffs are shown to a user on the diff screen. To fix this, we don't apply the optimizations whenever an edit due to rebase is involved in a to-be-combined edit. As users shouldn't need to look closely at any edits/hunks which are introduced by a rebase, it should be innocuous that we don't apply the optimizations in that case. Ideally, we would switch our internal representation from Edit to a custom class which allows us to associate custom attributes with an edit. In that case, we could apply the optimizations again for to-be-combined edits which consist completely of edits due to rebase. Using the optimization for mixing edits with edits due to rebase still wouldn't be possible. As this refactoring takes some more effort, we at least get in this quick fix for the moment. This change needs to invalidate the IntraLineDiff cache. Change-Id: If68b68b4cebd243defdb71181326a1eceee95954
This commit is contained in:
@@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.List;
|
||||
import org.eclipse.jgit.diff.Edit;
|
||||
import org.eclipse.jgit.diff.EditList;
|
||||
@@ -149,7 +150,8 @@ public class IntraLineLoaderTest {
|
||||
Text aText = new Text(a.getBytes(UTF_8));
|
||||
Text bText = new Text(b.getBytes(UTF_8));
|
||||
|
||||
IntraLineDiff diff = IntraLineLoader.compute(aText, bText, ImmutableList.of(lines));
|
||||
IntraLineDiff diff =
|
||||
IntraLineLoader.compute(aText, bText, ImmutableList.of(lines), ImmutableSet.of());
|
||||
|
||||
assertThat(diff.getStatus()).isEqualTo(IntraLineDiff.Status.EDIT_LIST);
|
||||
List<Edit> actualEdits = diff.getEdits();
|
||||
|
||||
Reference in New Issue
Block a user