mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
This commit is contained in:
@@ -44,7 +44,7 @@ public class JGitDiff<T> implements DiffAlgorithm<T> {
|
||||
diffList.addAll(new HistogramDiff().diff(new DataListComparator<>(), new DataList<>(original), new DataList<>(revised)));
|
||||
List<Change> patch = new ArrayList<>();
|
||||
for (Edit edit : diffList) {
|
||||
DeltaType type = DeltaType.EQUAL;
|
||||
DeltaType type;
|
||||
switch (edit.getType()) {
|
||||
case DELETE:
|
||||
type = DeltaType.DELETE;
|
||||
@@ -55,6 +55,8 @@ public class JGitDiff<T> implements DiffAlgorithm<T> {
|
||||
case REPLACE:
|
||||
type = DeltaType.CHANGE;
|
||||
break;
|
||||
default:
|
||||
type = DeltaType.EQUAL;
|
||||
}
|
||||
patch.add(new Change(type,edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB()));
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class DiffRowGenerator {
|
||||
|
||||
public static final BiPredicate<String,String> IGNORE_WHITESPACE_EQUALIZER = (original, revised)
|
||||
-> original.trim().replaceAll("\\s+", " ").equals(revised.trim().replaceAll("\\s+", " "));
|
||||
public static final BiPredicate<String,String> DEFAULT_EQUALIZER = Object::equals;
|
||||
private static final Pattern SPLIT_PATTERN = Pattern.compile("\\s+|[,.\\[\\](){}/\\\\*+\\-#]");
|
||||
private final boolean showInlineDiffs;
|
||||
private final boolean ignoreWhiteSpaces;
|
||||
@@ -171,10 +174,6 @@ public class DiffRowGenerator {
|
||||
public static Builder create() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static final BiPredicate<String,String> IGNORE_WHITESPACE_EQUALIZER = (original, revised)
|
||||
-> original.trim().replaceAll("\\s+", " ").equals(revised.trim().replaceAll("\\s+", " "));
|
||||
public static final BiPredicate<String,String> DEFAULT_EQUALIZER = Object::equals;
|
||||
|
||||
private DiffRowGenerator(Builder builder) {
|
||||
showInlineDiffs = builder.showInlineDiffs;
|
||||
|
||||
@@ -15,20 +15,11 @@
|
||||
*/
|
||||
package com.github.difflib.algorithm.jgit;
|
||||
|
||||
import com.github.difflib.algorithm.jgit.JGitDiff;
|
||||
import static com.github.difflib.DiffUtilsTest.readStringListFromInputStream;
|
||||
import com.github.difflib.TestConstants;
|
||||
import com.github.difflib.algorithm.DiffException;
|
||||
import com.github.difflib.patch.Patch;
|
||||
import com.github.difflib.patch.PatchFailedException;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipFile;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -37,29 +28,7 @@ import static org.junit.Assert.*;
|
||||
* @author toben
|
||||
*/
|
||||
public class JGitDiffTest {
|
||||
|
||||
public JGitDiffTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of diff method, of class JGitDiff.
|
||||
*/
|
||||
@Test
|
||||
public void testDiff() throws DiffException, PatchFailedException {
|
||||
List<String> orgList = Arrays.asList("A","B","C","A","B","B","A");
|
||||
|
||||
@@ -15,20 +15,14 @@
|
||||
*/
|
||||
package com.github.difflib.algorithm.jgit;
|
||||
|
||||
import com.github.difflib.algorithm.jgit.JGitDiff;
|
||||
import static com.github.difflib.DiffUtilsTest.readStringListFromInputStream;
|
||||
import com.github.difflib.TestConstants;
|
||||
import com.github.difflib.algorithm.DiffException;
|
||||
import com.github.difflib.patch.Patch;
|
||||
import com.github.difflib.patch.PatchFailedException;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipFile;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -38,26 +32,6 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
public class LRJGitDiffTest {
|
||||
|
||||
public LRJGitDiffTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPossibleDiffHangOnLargeDatasetDnaumenkoIssue26() throws IOException, DiffException, PatchFailedException {
|
||||
ZipFile zip = new ZipFile(TestConstants.MOCK_FOLDER + "/large_dataset1.zip");
|
||||
|
||||
@@ -34,25 +34,6 @@ import static org.junit.Assert.*;
|
||||
*/
|
||||
public class MyersDiffTest {
|
||||
|
||||
public MyersDiffTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDiffMyersExample1Forward() throws DiffException {
|
||||
List<String> original = Arrays.asList("A", "B", "C", "A", "B", "B", "A");
|
||||
|
||||
Reference in New Issue
Block a user