From 65183197c5ef207e6a38bca32f72be5e0d2dee17 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Thu, 18 Oct 2018 21:39:22 +0200
Subject: [PATCH 001/262] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 081b7949..0dff7a71 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
com.github.wumpzdiffutilsjar
- 3.0
+ 3.1-SNAPSHOTjava-diff-utilsThe DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.https://github.com/wumpz/java-diff-utils
@@ -24,7 +24,7 @@
scm:git:https://github.com/wumpz/java-diff-utils.gitscm:git:ssh://git@github.com:wumpz/java-diff-utils.githttps://github.com/wumpz/java-diff-utils.git
- diffutils-3.0
+ HEAD
From d4f114226d1e76ddc28f96281d74d836f8651876 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Thu, 18 Oct 2018 21:52:57 +0200
Subject: [PATCH 002/262] fixes #26
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index df31d84b..1b2c8be8 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ This is a test ~senctence~**for diffutils**.
But it can easily replaced by any other which is better for handing your texts. I have plan to add implementation of some in future.
### Changelog ###
- * Version 3.0-SNAPSHOT
+ * Version 3.0
* changed generation of inline diffes, if there are different linefeeds within one diff, then these are excluded
from the diff block.
* Due to licensing issues Delta.java and DiffAlgorithm.java were removed.
@@ -108,7 +108,7 @@ Just add the code below to your maven dependencies:
com.github.wumpzdiffutils
- 2.2
+ 3.0
```
or using gradle:
From 306f92684f864da3e1cca77275f03a8f071c0784 Mon Sep 17 00:00:00 2001
From: Oliver Kopp
Date: Sun, 28 Oct 2018 17:13:03 +0100
Subject: [PATCH 003/262] Use Objects.hash() instead of custom hashCode()
method
---
.../github/difflib/patch/AbstractDelta.java | 6 +-----
.../java/com/github/difflib/patch/Chunk.java | 18 ++----------------
.../java/com/github/difflib/text/DiffRow.java | 18 ++----------------
3 files changed, 5 insertions(+), 37 deletions(-)
diff --git a/src/main/java/com/github/difflib/patch/AbstractDelta.java b/src/main/java/com/github/difflib/patch/AbstractDelta.java
index 30de287c..9f1fb451 100644
--- a/src/main/java/com/github/difflib/patch/AbstractDelta.java
+++ b/src/main/java/com/github/difflib/patch/AbstractDelta.java
@@ -63,11 +63,7 @@ protected void verifyChunk(List target) throws PatchFailedException {
@Override
public int hashCode() {
- int hash = 3;
- hash = 61 * hash + Objects.hashCode(this.source);
- hash = 61 * hash + Objects.hashCode(this.target);
- hash = 61 * hash + Objects.hashCode(this.type);
- return hash;
+ return Objects.hash(this.source, this.target, this.type);
}
@Override
diff --git a/src/main/java/com/github/difflib/patch/Chunk.java b/src/main/java/com/github/difflib/patch/Chunk.java
index 3812be09..7871c714 100644
--- a/src/main/java/com/github/difflib/patch/Chunk.java
+++ b/src/main/java/com/github/difflib/patch/Chunk.java
@@ -21,6 +21,7 @@
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
/**
* Holds the information about the part of text involved in the diff process
@@ -108,26 +109,11 @@ public int last() {
return getPosition() + size() - 1;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((lines == null) ? 0 : lines.hashCode());
- result = prime * result + position;
- result = prime * result + size();
- return result;
+ return Objects.hash(lines, position, size());
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git a/src/main/java/com/github/difflib/text/DiffRow.java b/src/main/java/com/github/difflib/text/DiffRow.java
index dd8cd9d6..95fa61f7 100644
--- a/src/main/java/com/github/difflib/text/DiffRow.java
+++ b/src/main/java/com/github/difflib/text/DiffRow.java
@@ -20,6 +20,7 @@
package com.github.difflib.text;
import java.io.Serializable;
+import java.util.Objects;
/**
* Describes the diff row in form [tag, oldLine, newLine) for showing the difference between two texts
@@ -70,26 +71,11 @@ public String getNewLine() {
return newLine;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((newLine == null) ? 0 : newLine.hashCode());
- result = prime * result + ((oldLine == null) ? 0 : oldLine.hashCode());
- result = prime * result + ((tag == null) ? 0 : tag.hashCode());
- return result;
+ return Objects.hash(newLine, oldLine, tag);
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
if (this == obj) {
From 30a23c00d1f15990f8cb74dcbdfd3a6b21b89d11 Mon Sep 17 00:00:00 2001
From: Oliver Kopp
Date: Sun, 28 Oct 2018 17:25:20 +0100
Subject: [PATCH 004/262] Reformat Apache 2.0 headers (remove #%L things)
---
.../java/com/github/difflib/DiffUtils.java | 30 ++++++++-----------
.../difflib/algorithm/DiffException.java | 30 ++++++++-----------
.../DifferentiationFailedException.java | 30 ++++++++-----------
.../difflib/algorithm/myers/MyersDiff.java | 30 ++++++++-----------
.../difflib/algorithm/myers/PathNode.java | 30 ++++++++-----------
.../com/github/difflib/patch/ChangeDelta.java | 30 ++++++++-----------
.../java/com/github/difflib/patch/Chunk.java | 30 ++++++++-----------
.../com/github/difflib/patch/DeleteDelta.java | 30 ++++++++-----------
.../github/difflib/patch/DiffException.java | 30 ++++++++-----------
.../com/github/difflib/patch/InsertDelta.java | 30 ++++++++-----------
.../difflib/patch/PatchFailedException.java | 30 ++++++++-----------
.../java/com/github/difflib/text/DiffRow.java | 30 ++++++++-----------
.../github/difflib/text/DiffRowGenerator.java | 30 ++++++++-----------
.../com/github/difflib/text/StringUtils.java | 30 ++++++++-----------
14 files changed, 182 insertions(+), 238 deletions(-)
diff --git a/src/main/java/com/github/difflib/DiffUtils.java b/src/main/java/com/github/difflib/DiffUtils.java
index f2c8eb19..8b144642 100644
--- a/src/main/java/com/github/difflib/DiffUtils.java
+++ b/src/main/java/com/github/difflib/DiffUtils.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib;
diff --git a/src/main/java/com/github/difflib/algorithm/DiffException.java b/src/main/java/com/github/difflib/algorithm/DiffException.java
index 491bf38c..d36d16fb 100644
--- a/src/main/java/com/github/difflib/algorithm/DiffException.java
+++ b/src/main/java/com/github/difflib/algorithm/DiffException.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.algorithm;
diff --git a/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java b/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java
index 80c881e5..682a9b48 100644
--- a/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java
+++ b/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.algorithm;
diff --git a/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java b/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java
index 00d22359..8c183411 100644
--- a/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java
+++ b/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.algorithm.myers;
diff --git a/src/main/java/com/github/difflib/algorithm/myers/PathNode.java b/src/main/java/com/github/difflib/algorithm/myers/PathNode.java
index 01d669f7..a3f2070c 100644
--- a/src/main/java/com/github/difflib/algorithm/myers/PathNode.java
+++ b/src/main/java/com/github/difflib/algorithm/myers/PathNode.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.algorithm.myers;
diff --git a/src/main/java/com/github/difflib/patch/ChangeDelta.java b/src/main/java/com/github/difflib/patch/ChangeDelta.java
index eb67606b..43f68b35 100644
--- a/src/main/java/com/github/difflib/patch/ChangeDelta.java
+++ b/src/main/java/com/github/difflib/patch/ChangeDelta.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.patch;
diff --git a/src/main/java/com/github/difflib/patch/Chunk.java b/src/main/java/com/github/difflib/patch/Chunk.java
index 3812be09..a4244fea 100644
--- a/src/main/java/com/github/difflib/patch/Chunk.java
+++ b/src/main/java/com/github/difflib/patch/Chunk.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.patch;
diff --git a/src/main/java/com/github/difflib/patch/DeleteDelta.java b/src/main/java/com/github/difflib/patch/DeleteDelta.java
index d7417246..66a928ca 100644
--- a/src/main/java/com/github/difflib/patch/DeleteDelta.java
+++ b/src/main/java/com/github/difflib/patch/DeleteDelta.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.patch;
diff --git a/src/main/java/com/github/difflib/patch/DiffException.java b/src/main/java/com/github/difflib/patch/DiffException.java
index 9b8b53b4..da01d621 100644
--- a/src/main/java/com/github/difflib/patch/DiffException.java
+++ b/src/main/java/com/github/difflib/patch/DiffException.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.patch;
diff --git a/src/main/java/com/github/difflib/patch/InsertDelta.java b/src/main/java/com/github/difflib/patch/InsertDelta.java
index 3cb40dde..08de5f1f 100644
--- a/src/main/java/com/github/difflib/patch/InsertDelta.java
+++ b/src/main/java/com/github/difflib/patch/InsertDelta.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.patch;
diff --git a/src/main/java/com/github/difflib/patch/PatchFailedException.java b/src/main/java/com/github/difflib/patch/PatchFailedException.java
index fa8bf8e0..7521c892 100644
--- a/src/main/java/com/github/difflib/patch/PatchFailedException.java
+++ b/src/main/java/com/github/difflib/patch/PatchFailedException.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.patch;
diff --git a/src/main/java/com/github/difflib/text/DiffRow.java b/src/main/java/com/github/difflib/text/DiffRow.java
index dd8cd9d6..340bb93f 100644
--- a/src/main/java/com/github/difflib/text/DiffRow.java
+++ b/src/main/java/com/github/difflib/text/DiffRow.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.text;
diff --git a/src/main/java/com/github/difflib/text/DiffRowGenerator.java b/src/main/java/com/github/difflib/text/DiffRowGenerator.java
index 8ded4253..2ed2662e 100644
--- a/src/main/java/com/github/difflib/text/DiffRowGenerator.java
+++ b/src/main/java/com/github/difflib/text/DiffRowGenerator.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.text;
diff --git a/src/main/java/com/github/difflib/text/StringUtils.java b/src/main/java/com/github/difflib/text/StringUtils.java
index 4166b311..3a2dab05 100644
--- a/src/main/java/com/github/difflib/text/StringUtils.java
+++ b/src/main/java/com/github/difflib/text/StringUtils.java
@@ -1,21 +1,17 @@
-/*-
- * #%L
- * java-diff-utils
- * %%
- * Copyright (C) 2009 - 2017 java-diff-utils
- * %%
+/*
+ * Copyright 2009-2017 java-diff-utils.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
- * #L%
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package com.github.difflib.text;
From d5fbf5022eecf3d0d24ab34c271bc47b33e587fd Mon Sep 17 00:00:00 2001
From: wumpz
Date: Sun, 4 Nov 2018 22:56:17 +0100
Subject: [PATCH 005/262] changed groupid, artifactid moved to new organistion
java-diff-utils switched to version 4.0-SNAPSHOT
---
README.md | 3 +
pom.xml | 516 +++++++++++++++++++++++++++---------------------------
2 files changed, 262 insertions(+), 257 deletions(-)
diff --git a/README.md b/README.md
index 1b2c8be8..ab3e13de 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,9 @@ This is a test ~senctence~**for diffutils**.
But it can easily replaced by any other which is better for handing your texts. I have plan to add implementation of some in future.
### Changelog ###
+ * Version 4.0-SNAPSHOT
+ * moved to organisation **java-diff-utils**
+ * changed groupid to **io.github.java-diff-utils** and artifact id to **java-diff-utils**
* Version 3.0
* changed generation of inline diffes, if there are different linefeeds within one diff, then these are excluded
from the diff block.
diff --git a/pom.xml b/pom.xml
index 0dff7a71..553950b3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,253 +1,255 @@
- 4.0.0
- com.github.wumpz
- diffutils
- jar
- 3.1-SNAPSHOT
- java-diff-utils
- The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.
- https://github.com/wumpz/java-diff-utils
- 2009
+ 4.0.0
+ io.github.java-diff-utils
+ java-diff-utils
+ jar
+ 4.0-SNAPSHOT
+ java-diff-utils
+ The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.
+ https://github.com/wumpz/java-diff-utils
+ 2009
-
-
- sonatype-nexus-staging
- https://oss.sonatype.org/service/local/staging/deploy/maven2
-
-
- sonatype-nexus-snapshots
- https://oss.sonatype.org/content/repositories/snapshots
-
-
+
+
+ sonatype-nexus-staging
+ https://oss.sonatype.org/service/local/staging/deploy/maven2
+
+
+ sonatype-nexus-snapshots
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
-
- scm:git:https://github.com/wumpz/java-diff-utils.git
- scm:git:ssh://git@github.com:wumpz/java-diff-utils.git
- https://github.com/wumpz/java-diff-utils.git
- HEAD
-
+
+ scm:git:https://github.com/wumpz/java-diff-utils.git
+ scm:git:ssh://git@github.com:wumpz/java-diff-utils.git
+ https://github.com/wumpz/java-diff-utils.git
+ HEAD
+
-
- GitHub Issues
- https://github.com/wumpz/java-diff-utils/issues
-
+
+ GitHub Issues
+ https://github.com/java-diff-utils/java-diff-utils/issues
+
-
- java-diff-utils
-
+
+ java-diff-utils
+
-
-
- Tobias Warneke
- t.warneke@gmx.net
-
-
- Dmitry Naumenko
- dm.naumenko@gmail.com
-
-
- Juanco Anez
- juanco@suigeneris.org
-
-
+
+
+ Tobias Warneke
+ t.warneke@gmx.net
+
+
+
-
-
- The Apache Software License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
- A business-friendly OSS license
-
-
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+ A business-friendly OSS license
+
+
-
- UTF-8
-
+
+ UTF-8
+
-
-
- junit
- junit
- 4.12
- jar
- test
-
-
- org.eclipse.jgit
- org.eclipse.jgit
- 4.4.1.201607150455-r
-
-
- com.googlecode.javaewah
- JavaEWAH
-
-
- commons-codec
- commons-codec
-
-
- commons-logging
- commons-logging
-
-
- org.apache.httpcomponents
- httpclient
-
-
- com.jcraft
- jsch
-
-
- org.slf4j
- slf4j-api
-
-
-
-
+
+
+ junit
+ junit
+ 4.12
+ jar
+ test
+
+
+ org.eclipse.jgit
+ org.eclipse.jgit
+ 4.4.1.201607150455-r
+
+
+ com.googlecode.javaewah
+ JavaEWAH
+
+
+ commons-codec
+ commons-codec
+
+
+ commons-logging
+ commons-logging
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+ com.jcraft
+ jsch
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+
-
-
+
+
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.6.1
-
- 1.8
- 1.8
- UTF-8
-
-
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.1
+
+ 1.8
+ 1.8
+ UTF-8
+
+
-
-
-
- maven-jar-plugin
- 3.0.2
-
-
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
+
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ ${project.build.outputDirectory}/META-INF/MANIFEST.MFcom.github.wumpz.diffutils
-
-
-
-
- org.apache.felix
- maven-bundle-plugin
- 3.3.0
-
-
- bundle-manifest
- process-classes
-
- manifest
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.10.4
-
- ${javadoc.opts}
-
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.19.1
-
-
- **/LR*.java
-
-
-
-
- org.apache.maven.plugins
- maven-release-plugin
- 2.5.3
-
- true
- false
- forked-path
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
- 2.17
-
-
- verify-style
- process-classes
-
- check
-
-
-
-
- true
- true
- ${project.build.sourceDirectory}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ 3.3.0
+
+
+ bundle-manifest
+ process-classes
+
+ manifest
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.10.4
+
+ ${javadoc.opts}
+
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.19.1
+
+
+ **/LR*.java
+
+
+
+
+ org.apache.maven.plugins
+ maven-release-plugin
+ 2.5.3
+
+ true
+ false
+ forked-path
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 2.17
+
+
+ verify-style
+ process-classes
+
+ check
+
+
+
+
+ true
+ true
+ ${project.build.sourceDirectory}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
- com.puppycrawl.tools
- checkstyle
- 6.19
-
-
-
-
-
-
+
+
+
+
+
+
+
+ com.puppycrawl.tools
+ checkstyle
+ 6.19
+
+
+
+
+
+ sign-release-artifacts
@@ -278,31 +280,31 @@
-
- doclint-java8-disable
-
- [1.8,)
-
-
- -Xdoclint:none
-
-
-
- long-running-tests
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- xxx
-
-
-
-
-
-
-
+
+ doclint-java8-disable
+
+ [1.8,)
+
+
+ -Xdoclint:none
+
+
+
+ long-running-tests
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ xxx
+
+
+
+
+
+
+
From 0fbbb53b77307054d62eaadd4b30e842d19947d0 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Mon, 12 Nov 2018 18:10:49 +0100
Subject: [PATCH 006/262]
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 553950b3..6213ca29 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0-SNAPSHOTjava-diff-utilsThe DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.
- https://github.com/wumpz/java-diff-utils
+ https://github.com/java-diff-utils/java-diff-utils2009
@@ -21,9 +21,9 @@
- scm:git:https://github.com/wumpz/java-diff-utils.git
- scm:git:ssh://git@github.com:wumpz/java-diff-utils.git
- https://github.com/wumpz/java-diff-utils.git
+ scm:git:https://github.com/java-diff-utils/java-diff-utils.git
+ scm:git:ssh://git@github.com:java-diff-utils/java-diff-utils.git
+ https://github.com/java-diff-utils/java-diff-utils.gitHEAD
From 005ba349f844c663bcc6e1e29fb6ef72705275c3 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Thu, 15 Nov 2018 17:32:08 +0100
Subject: [PATCH 007/262]
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index ab3e13de..2552a65b 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# java-diff-utils
## Status ##
-[](https://travis-ci.org/wumpz/java-diff-utils) [](https://www.codacy.com/app/wumpz/java-diff-utils?utm_source=github.com&utm_medium=referral&utm_content=wumpz/java-diff-utils&utm_campaign=Badge_Grade)
+[](https://travis-ci.org/java-diff-utils/java-diff-utils) [](https://www.codacy.com/app/wumpz/java-diff-utils?utm_source=github.com&utm_medium=referral&utm_content=java-diff-utils/java-diff-utils&utm_campaign=Badge_Grade)
[](http://maven-badges.herokuapp.com/maven-central/com.github.wumpz/diffutils)
From 4fe80bdf1e3b083ce40b2b42f9c8494caafa1629 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Fri, 16 Nov 2018 00:30:34 +0100
Subject: [PATCH 008/262] changed readme to new home
---
README.md | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/README.md b/README.md
index 2552a65b..e62f0e5c 100644
--- a/README.md
+++ b/README.md
@@ -114,6 +114,17 @@ Just add the code below to your maven dependencies:
3.0
```
+
+Attention. We changed groupid and artifactid. Starting with version 4 you have to use:
+
+```
+
+ io.github.java-diff-utils
+ java-diff-utils
+ 4.0-SNAPSHOT
+
+```
+
or using gradle:
```
// https://mvnrepository.com/artifact/com.github.wumpz/diffutils
From 4bab820483ce25974b4e366659d9c9e98135d09e Mon Sep 17 00:00:00 2001
From: wumpz
Date: Thu, 22 Nov 2018 21:50:52 +0100
Subject: [PATCH 009/262] [maven-release-plugin] prepare release
java-diff-utils-4.0
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 6213ca29..5a85f49f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
io.github.java-diff-utilsjava-diff-utilsjar
- 4.0-SNAPSHOT
+ 4.0java-diff-utilsThe DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.https://github.com/java-diff-utils/java-diff-utils
@@ -24,7 +24,7 @@
scm:git:https://github.com/java-diff-utils/java-diff-utils.gitscm:git:ssh://git@github.com:java-diff-utils/java-diff-utils.githttps://github.com/java-diff-utils/java-diff-utils.git
- HEAD
+ java-diff-utils-4.0
From c9a2c9e7f01e85f9f889979bd22d21e0affb4b6c Mon Sep 17 00:00:00 2001
From: wumpz
Date: Thu, 22 Nov 2018 21:50:54 +0100
Subject: [PATCH 010/262] [maven-release-plugin] prepare for next development
iteration
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5a85f49f..200c4d14 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
io.github.java-diff-utilsjava-diff-utilsjar
- 4.0
+ 4.1-SNAPSHOTjava-diff-utilsThe DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.https://github.com/java-diff-utils/java-diff-utils
@@ -24,7 +24,7 @@
scm:git:https://github.com/java-diff-utils/java-diff-utils.gitscm:git:ssh://git@github.com:java-diff-utils/java-diff-utils.githttps://github.com/java-diff-utils/java-diff-utils.git
- java-diff-utils-4.0
+ HEAD
From 785c368f01264ed871578f9b5d7324be6ce4c089 Mon Sep 17 00:00:00 2001
From: Tobias
Date: Fri, 23 Nov 2018 08:15:08 +0100
Subject: [PATCH 011/262] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e62f0e5c..e5c731ef 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
## Status ##
[](https://travis-ci.org/java-diff-utils/java-diff-utils) [](https://www.codacy.com/app/wumpz/java-diff-utils?utm_source=github.com&utm_medium=referral&utm_content=java-diff-utils/java-diff-utils&utm_campaign=Badge_Grade)
-[](http://maven-badges.herokuapp.com/maven-central/com.github.wumpz/diffutils)
+[](http://maven-badges.herokuapp.com/maven-central/io.github.java-diff-utils/java-diff-utils)
## Intro ##
From 5fe7e58f7640cc85c0c9528f4863f75706d4e48d Mon Sep 17 00:00:00 2001
From: Tobias
Date: Fri, 23 Nov 2018 08:16:05 +0100
Subject: [PATCH 012/262] Update README.md
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index e5c731ef..7cd6ee1b 100644
--- a/README.md
+++ b/README.md
@@ -109,9 +109,9 @@ This is a valid piece of source code:
Just add the code below to your maven dependencies:
```
- com.github.wumpz
- diffutils
- 3.0
+ io.github.java-diff-utils
+ java-diff-utils
+ 4.0
```
From ab05a8bdb4dcdd899d9d7aef3e2e7302476bfbcb Mon Sep 17 00:00:00 2001
From: Tobias
Date: Fri, 23 Nov 2018 08:19:56 +0100
Subject: [PATCH 013/262] Update README.md
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 7cd6ee1b..c3c335ac 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
# java-diff-utils
## Status ##
-[](https://travis-ci.org/java-diff-utils/java-diff-utils) [](https://www.codacy.com/app/wumpz/java-diff-utils?utm_source=github.com&utm_medium=referral&utm_content=java-diff-utils/java-diff-utils&utm_campaign=Badge_Grade)
+[](https://travis-ci.org/java-diff-utils/java-diff-utils)
+[](https://www.codacy.com/app/wumpz/java-diff-utils?utm_source=github.com&utm_medium=referral&utm_content=java-diff-utils/java-diff-utils&utm_campaign=Badge_Grade)
[](http://maven-badges.herokuapp.com/maven-central/io.github.java-diff-utils/java-diff-utils)
From fc1e247de206bf8a6f0b8b05d59d103b2b1e5592 Mon Sep 17 00:00:00 2001
From: heisluft
Date: Sat, 8 Dec 2018 14:56:40 +0100
Subject: [PATCH 014/262] Exchange "0 += 1" for "0 = 1"
---
src/main/java/com/github/difflib/UnifiedDiffUtils.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/github/difflib/UnifiedDiffUtils.java b/src/main/java/com/github/difflib/UnifiedDiffUtils.java
index fe5b6f69..d5812c31 100644
--- a/src/main/java/com/github/difflib/UnifiedDiffUtils.java
+++ b/src/main/java/com/github/difflib/UnifiedDiffUtils.java
@@ -83,10 +83,10 @@ public static Patch parseUnifiedDiff(List diff) {
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
if (old_ln == 0) {
- old_ln += 1;
+ old_ln = 1;
}
if (new_ln == 0) {
- new_ln += 1;
+ new_ln = 1;
}
} else {
if (line.length() > 0) {
From de2f19497a86f1be638890cc443053095a83db52 Mon Sep 17 00:00:00 2001
From: Stephen Kitt
Date: Thu, 7 Feb 2019 18:51:58 +0100
Subject: [PATCH 015/262] Remove unused DiffException declarations
Signed-off-by: Stephen Kitt
---
.../com/github/difflib/algorithm/jgit/HistogramDiff.java | 3 +--
.../com/github/difflib/algorithm/jgit/HistogramDiffTest.java | 5 ++---
.../github/difflib/algorithm/jgit/LRHistogramDiffTest.java | 3 +--
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java b/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java
index c2e941f2..e3f6cd5b 100644
--- a/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java
+++ b/src/main/java/com/github/difflib/algorithm/jgit/HistogramDiff.java
@@ -18,7 +18,6 @@
import com.github.difflib.algorithm.Change;
import com.github.difflib.algorithm.DiffAlgorithmI;
import com.github.difflib.algorithm.DiffAlgorithmListener;
-import com.github.difflib.algorithm.DiffException;
import com.github.difflib.patch.DeltaType;
import java.util.ArrayList;
import java.util.List;
@@ -37,7 +36,7 @@
public class HistogramDiff implements DiffAlgorithmI {
@Override
- public List computeDiff(List source, List target, DiffAlgorithmListener progress) throws DiffException {
+ public List computeDiff(List source, List target, DiffAlgorithmListener progress) {
Objects.requireNonNull(source, "source list must not be null");
Objects.requireNonNull(target, "target list must not be null");
if (progress != null) {
diff --git a/src/test/java/com/github/difflib/algorithm/jgit/HistogramDiffTest.java b/src/test/java/com/github/difflib/algorithm/jgit/HistogramDiffTest.java
index 0009f18b..e1030242 100644
--- a/src/test/java/com/github/difflib/algorithm/jgit/HistogramDiffTest.java
+++ b/src/test/java/com/github/difflib/algorithm/jgit/HistogramDiffTest.java
@@ -16,7 +16,6 @@
package com.github.difflib.algorithm.jgit;
import com.github.difflib.algorithm.DiffAlgorithmListener;
-import com.github.difflib.algorithm.DiffException;
import com.github.difflib.patch.Patch;
import com.github.difflib.patch.PatchFailedException;
import java.util.ArrayList;
@@ -58,7 +57,7 @@ public void tearDown() {
* Test of diff method, of class HistogramDiff.
*/
@Test
- public void testDiff() throws DiffException, PatchFailedException {
+ public void testDiff() throws PatchFailedException {
List orgList = Arrays.asList("A", "B", "C", "A", "B", "B", "A");
List revList = Arrays.asList("C", "B", "A", "B", "A", "C");
final Patch patch = Patch.generate(orgList, revList, new HistogramDiff().computeDiff(orgList, revList, null));
@@ -72,7 +71,7 @@ public void testDiff() throws DiffException, PatchFailedException {
}
@Test
- public void testDiffWithListener() throws DiffException, PatchFailedException {
+ public void testDiffWithListener() throws PatchFailedException {
List orgList = Arrays.asList("A", "B", "C", "A", "B", "B", "A");
List revList = Arrays.asList("C", "B", "A", "B", "A", "C");
diff --git a/src/test/java/com/github/difflib/algorithm/jgit/LRHistogramDiffTest.java b/src/test/java/com/github/difflib/algorithm/jgit/LRHistogramDiffTest.java
index 5f93570d..9aee685a 100644
--- a/src/test/java/com/github/difflib/algorithm/jgit/LRHistogramDiffTest.java
+++ b/src/test/java/com/github/difflib/algorithm/jgit/LRHistogramDiffTest.java
@@ -18,7 +18,6 @@
import static com.github.difflib.DiffUtilsTest.readStringListFromInputStream;
import com.github.difflib.TestConstants;
import com.github.difflib.algorithm.DiffAlgorithmListener;
-import com.github.difflib.algorithm.DiffException;
import com.github.difflib.patch.Patch;
import com.github.difflib.patch.PatchFailedException;
import java.io.IOException;
@@ -58,7 +57,7 @@ public void tearDown() {
}
@Test
- public void testPossibleDiffHangOnLargeDatasetDnaumenkoIssue26() throws IOException, DiffException, PatchFailedException {
+ public void testPossibleDiffHangOnLargeDatasetDnaumenkoIssue26() throws IOException, PatchFailedException {
ZipFile zip = new ZipFile(TestConstants.MOCK_FOLDER + "/large_dataset1.zip");
List original = readStringListFromInputStream(zip.getInputStream(zip.getEntry("ta")));
List revised = readStringListFromInputStream(zip.getInputStream(zip.getEntry("tb")));
From 2d116d8c540c472205e5d1fa552f86835fce7920 Mon Sep 17 00:00:00 2001
From: Stephen Kitt
Date: Thu, 7 Feb 2019 18:55:41 +0100
Subject: [PATCH 016/262] Use String.join instead of streaming/collecting
Signed-off-by: Stephen Kitt
---
src/main/java/com/github/difflib/DiffUtils.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/main/java/com/github/difflib/DiffUtils.java b/src/main/java/com/github/difflib/DiffUtils.java
index 8b144642..b57a0d2f 100644
--- a/src/main/java/com/github/difflib/DiffUtils.java
+++ b/src/main/java/com/github/difflib/DiffUtils.java
@@ -28,7 +28,6 @@
import java.util.List;
import java.util.Objects;
import java.util.function.BiPredicate;
-import static java.util.stream.Collectors.joining;
/**
* Implements the difference and patching engine
@@ -143,7 +142,7 @@ private static List compressLines(List lines, String delimiter)
if (lines.isEmpty()) {
return Collections.emptyList();
}
- return Collections.singletonList(lines.stream().collect(joining(delimiter)));
+ return Collections.singletonList(String.join(delimiter, lines));
}
/**
From 47c6e9b417af69153a64ea27f04de82707fe7ee8 Mon Sep 17 00:00:00 2001
From: Stephen Kitt
Date: Thu, 7 Feb 2019 18:56:44 +0100
Subject: [PATCH 017/262] Drop unnecessary Integer.toString
Signed-off-by: Stephen Kitt
---
.../java/com/github/difflib/algorithm/myers/PathNode.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/github/difflib/algorithm/myers/PathNode.java b/src/main/java/com/github/difflib/algorithm/myers/PathNode.java
index a3f2070c..f3c153f8 100644
--- a/src/main/java/com/github/difflib/algorithm/myers/PathNode.java
+++ b/src/main/java/com/github/difflib/algorithm/myers/PathNode.java
@@ -102,9 +102,9 @@ public String toString() {
PathNode node = this;
while (node != null) {
buf.append("(");
- buf.append(Integer.toString(node.i));
+ buf.append(node.i);
buf.append(",");
- buf.append(Integer.toString(node.j));
+ buf.append(node.j);
buf.append(")");
node = node.prev;
}
From b41e2d5b5a6efbd8deb6a56bfa6e3a478f74faec Mon Sep 17 00:00:00 2001
From: Stephen Kitt
Date: Thu, 7 Feb 2019 18:57:00 +0100
Subject: [PATCH 018/262] Use assertEquals for comparison
... instead of assertTrue(a == b)
Signed-off-by: Stephen Kitt
---
src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java b/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java
index 89ab32f6..53aade3e 100644
--- a/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java
+++ b/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java
@@ -10,7 +10,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Test;
@@ -114,7 +114,7 @@ private void verify(List origLines, List revLines,
List patchedLines;
try {
patchedLines = (List) fromUnifiedPatch.applyTo(origLines);
- assertTrue(revLines.size() == patchedLines.size());
+ assertEquals(revLines.size(), patchedLines.size());
for (int i = 0; i < revLines.size(); i++) {
String l1 = revLines.get(i);
String l2 = patchedLines.get(i);
From 3443d55a19ecb2ece0f4fac31bd3273a158e3efe Mon Sep 17 00:00:00 2001
From: Stephen Kitt
Date: Thu, 7 Feb 2019 18:59:01 +0100
Subject: [PATCH 019/262] Drop redundant casts
Signed-off-by: Stephen Kitt
---
src/main/java/com/github/difflib/text/DiffRowGenerator.java | 4 ++--
src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/github/difflib/text/DiffRowGenerator.java b/src/main/java/com/github/difflib/text/DiffRowGenerator.java
index 2ed2662e..e7246a4e 100644
--- a/src/main/java/com/github/difflib/text/DiffRowGenerator.java
+++ b/src/main/java/com/github/difflib/text/DiffRowGenerator.java
@@ -199,7 +199,7 @@ public List generateDiffRows(final List original, Patch
// Inserted DiffRow
if (delta instanceof InsertDelta) {
endPos = orig.last() + 1;
- for (String line : (List) rev.getLines()) {
+ for (String line : rev.getLines()) {
diffRows.add(buildDiffRow(Tag.INSERT, "", line));
}
continue;
@@ -208,7 +208,7 @@ public List generateDiffRows(final List original, Patch
// Deleted DiffRow
if (delta instanceof DeleteDelta) {
endPos = orig.last() + 1;
- for (String line : (List) orig.getLines()) {
+ for (String line : orig.getLines()) {
diffRows.add(buildDiffRow(Tag.DELETE, line, ""));
}
continue;
diff --git a/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java b/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java
index 53aade3e..49497e33 100644
--- a/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java
+++ b/src/test/java/com/github/difflib/GenerateUnifiedDiffTest.java
@@ -113,7 +113,7 @@ private void verify(List origLines, List revLines,
Patch fromUnifiedPatch = UnifiedDiffUtils.parseUnifiedDiff(unifiedDiff);
List patchedLines;
try {
- patchedLines = (List) fromUnifiedPatch.applyTo(origLines);
+ patchedLines = fromUnifiedPatch.applyTo(origLines);
assertEquals(revLines.size(), patchedLines.size());
for (int i = 0; i < revLines.size(); i++) {
String l1 = revLines.get(i);
From a312ec14ea5d41cf2d249b71afec125f077959fd Mon Sep 17 00:00:00 2001
From: Stephen Kitt
Date: Thu, 7 Feb 2019 19:00:02 +0100
Subject: [PATCH 020/262] Use foreach loop
Signed-off-by: Stephen Kitt
---
src/main/java/com/github/difflib/text/DiffRowGenerator.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/main/java/com/github/difflib/text/DiffRowGenerator.java b/src/main/java/com/github/difflib/text/DiffRowGenerator.java
index e7246a4e..1f2d8e02 100644
--- a/src/main/java/com/github/difflib/text/DiffRowGenerator.java
+++ b/src/main/java/com/github/difflib/text/DiffRowGenerator.java
@@ -187,8 +187,7 @@ public List generateDiffRows(final List original, Patch
List diffRows = new ArrayList<>();
int endPos = 0;
final List> deltaList = patch.getDeltas();
- for (int i = 0; i < deltaList.size(); i++) {
- AbstractDelta delta = deltaList.get(i);
+ for (AbstractDelta delta : deltaList) {
Chunk orig = delta.getSource();
Chunk rev = delta.getTarget();
From 765dc29386a2e0e3cf00cda0cf4c4560d7a8260a Mon Sep 17 00:00:00 2001
From: Stephen Kitt
Date: Thu, 7 Feb 2019 19:00:44 +0100
Subject: [PATCH 021/262] Use List.sort instead of Collections.sort
Signed-off-by: Stephen Kitt
---
src/main/java/com/github/difflib/patch/Patch.java | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/github/difflib/patch/Patch.java b/src/main/java/com/github/difflib/patch/Patch.java
index 9bbb30dc..74e99f81 100644
--- a/src/main/java/com/github/difflib/patch/Patch.java
+++ b/src/main/java/com/github/difflib/patch/Patch.java
@@ -19,12 +19,9 @@
*/
package com.github.difflib.patch;
+import static java.util.Comparator.comparing;
import com.github.difflib.algorithm.Change;
-import static com.github.difflib.patch.DeltaType.DELETE;
-import static com.github.difflib.patch.DeltaType.INSERT;
import java.util.ArrayList;
-import java.util.Collections;
-import static java.util.Comparator.comparing;
import java.util.List;
import java.util.ListIterator;
@@ -93,7 +90,7 @@ public void addDelta(AbstractDelta delta) {
* @return the deltas
*/
public List> getDeltas() {
- Collections.sort(deltas, comparing(d -> d.getSource().getPosition()));
+ deltas.sort(comparing(d -> d.getSource().getPosition()));
return deltas;
}
From e8c015a2ec6ec724c417e1125b85b162473a8c7e Mon Sep 17 00:00:00 2001
From: Stephen Kitt
Date: Fri, 8 Feb 2019 09:17:43 +0100
Subject: [PATCH 022/262] Fix Javadoc errors
Signed-off-by: Stephen Kitt
---
.../difflib/algorithm/DifferentiationFailedException.java | 4 ++--
.../com/github/difflib/algorithm/myers/MyersDiff.java | 2 +-
.../java/com/github/difflib/algorithm/myers/PathNode.java | 8 ++------
src/main/java/com/github/difflib/patch/ChangeDelta.java | 2 +-
src/main/java/com/github/difflib/patch/Chunk.java | 2 +-
src/main/java/com/github/difflib/patch/DeleteDelta.java | 2 +-
src/main/java/com/github/difflib/patch/InsertDelta.java | 2 +-
src/main/java/com/github/difflib/patch/Patch.java | 2 +-
.../java/com/github/difflib/text/DiffRowGenerator.java | 6 ++----
src/test/java/com/github/difflib/TestConstants.java | 2 +-
10 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java b/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java
index 682a9b48..e201e440 100644
--- a/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java
+++ b/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java
@@ -18,8 +18,8 @@
/**
* Thrown whenever the differencing engine cannot produce the differences between two revisions of ta text.
*
- * @see MyersDiff
- * @see difflib.DiffAlgorithm
+ * @see com.github.difflib.algorithm.myers.MyersDiff
+ * @see DiffAlgorithmI
*/
public class DifferentiationFailedException extends DiffException {
diff --git a/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java b/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java
index 8c183411..abcf31e2 100644
--- a/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java
+++ b/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java
@@ -138,7 +138,7 @@ private PathNode buildPath(final List orig, final List rev, DiffAlgorithmL
/**
* Constructs a {@link Patch} from a difference path.
*
- * @param path The path.
+ * @param actualPath The path.
* @param orig The original sequence.
* @param rev The revised sequence.
* @return A {@link Patch} script corresponding to the path.
diff --git a/src/main/java/com/github/difflib/algorithm/myers/PathNode.java b/src/main/java/com/github/difflib/algorithm/myers/PathNode.java
index f3c153f8..fe8fd03a 100644
--- a/src/main/java/com/github/difflib/algorithm/myers/PathNode.java
+++ b/src/main/java/com/github/difflib/algorithm/myers/PathNode.java
@@ -19,10 +19,6 @@
* A node in a diffpath.
*
* @author Juanco Anez
- *
- * @see DiffNode
- * @see Snake
- *
*/
public final class PathNode {
@@ -78,10 +74,10 @@ public boolean isBootstrap() {
}
/**
- * Skips sequences of {@link DiffNode DiffNodes} until a {@link Snake} or bootstrap node is found, or the end of the
+ * Skips sequences of {@link PathNode PathNodes} until a snake or bootstrap node is found, or the end of the
* path is reached.
*
- * @return The next first {@link Snake} or bootstrap node in the path, or null if none found.
+ * @return The next first {@link PathNode} or bootstrap node in the path, or null if none found.
*/
public final PathNode previousSnake() {
if (isBootstrap()) {
diff --git a/src/main/java/com/github/difflib/patch/ChangeDelta.java b/src/main/java/com/github/difflib/patch/ChangeDelta.java
index 43f68b35..7c1cd98b 100644
--- a/src/main/java/com/github/difflib/patch/ChangeDelta.java
+++ b/src/main/java/com/github/difflib/patch/ChangeDelta.java
@@ -22,7 +22,7 @@
* Describes the change-delta between original and revised texts.
*
* @author Dmitry Naumenko
- * @param T The type of the compared elements in the data 'lines'.
+ * @param The type of the compared elements in the data 'lines'.
*/
public final class ChangeDelta extends AbstractDelta {
diff --git a/src/main/java/com/github/difflib/patch/Chunk.java b/src/main/java/com/github/difflib/patch/Chunk.java
index ed70e20d..6c1a9918 100644
--- a/src/main/java/com/github/difflib/patch/Chunk.java
+++ b/src/main/java/com/github/difflib/patch/Chunk.java
@@ -29,7 +29,7 @@
*
*
* @author Dmitry Naumenko
- * @param T The type of the compared elements in the 'lines'.
+ * @param The type of the compared elements in the 'lines'.
*/
public final class DeleteDelta extends AbstractDelta {
diff --git a/src/main/java/com/github/difflib/patch/InsertDelta.java b/src/main/java/com/github/difflib/patch/InsertDelta.java
index 08de5f1f..12164fa4 100644
--- a/src/main/java/com/github/difflib/patch/InsertDelta.java
+++ b/src/main/java/com/github/difflib/patch/InsertDelta.java
@@ -21,7 +21,7 @@
* Describes the add-delta between original and revised texts.
*
* @author Dmitry Naumenko
- * @param T The type of the compared elements in the 'lines'.
+ * @param The type of the compared elements in the 'lines'.
*/
public final class InsertDelta extends AbstractDelta {
diff --git a/src/main/java/com/github/difflib/patch/Patch.java b/src/main/java/com/github/difflib/patch/Patch.java
index 74e99f81..688e9f16 100644
--- a/src/main/java/com/github/difflib/patch/Patch.java
+++ b/src/main/java/com/github/difflib/patch/Patch.java
@@ -29,7 +29,7 @@
* Describes the patch holding all deltas between the original and revised texts.
*
* @author Dmitry Naumenko
- * @param T The type of the compared elements in the 'lines'.
+ * @param The type of the compared elements in the 'lines'.
*/
public final class Patch {
diff --git a/src/main/java/com/github/difflib/text/DiffRowGenerator.java b/src/main/java/com/github/difflib/text/DiffRowGenerator.java
index 1f2d8e02..c0267345 100644
--- a/src/main/java/com/github/difflib/text/DiffRowGenerator.java
+++ b/src/main/java/com/github/difflib/text/DiffRowGenerator.java
@@ -98,8 +98,7 @@ protected final static List splitStringPreserveDelimiter(String str, Pat
*
* @param startPosition the position from which tag should start. The counting start from a zero.
* @param endPosition the position before which tag should should be closed.
- * @param tag the tag name without angle brackets, just a word
- * @param cssClass the optional css class
+ * @param tagGenerator the tag generator
*/
static void wrapInTag(List sequence, int startPosition,
int endPosition, Function tagGenerator) {
@@ -179,7 +178,6 @@ public List generateDiffRows(List original, List revise
* for displaying side-by-side diff.
*
* @param original the original text
- * @param revised the revised text
* @param patch the given patch
* @return the DiffRows between original and revised texts
*/
@@ -400,7 +398,7 @@ public Builder reportLinesUnchanged(final boolean val) {
/**
* Generator for Old-Text-Tags.
*
- * @param tag the tag to set. Without angle brackets. Default: span.
+ * @param generator the tag generator
* @return builder with configured ignoreBlankLines parameter
*/
public Builder oldTag(Function generator) {
diff --git a/src/test/java/com/github/difflib/TestConstants.java b/src/test/java/com/github/difflib/TestConstants.java
index 56f5bf66..ba6d754e 100644
--- a/src/test/java/com/github/difflib/TestConstants.java
+++ b/src/test/java/com/github/difflib/TestConstants.java
@@ -10,7 +10,7 @@ public final class TestConstants {
public static final String BASE_FOLDER_RESOURCES = "target/test-classes/";
/**
- * The base folder containing the test files. Ends with {@link #FS}.
+ * The base folder containing the test files.
*/
public static final String MOCK_FOLDER = BASE_FOLDER_RESOURCES + "/mocks/";
From c0a1a3777c5fc084e73f8bbc1d2470efc87f1d66 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Thu, 28 Feb 2019 23:59:26 +0100
Subject: [PATCH 023/262] first start unified diff
---
.../difflib/unifieddiff/UnifiedDiff.java | 44 +++++++++++++
.../difflib/unifieddiff/UnifiedDiffTest.java | 57 +++++++++++++++++
.../unifieddiff/jsqlparser_patch_1.diff | 61 +++++++++++++++++++
3 files changed, 162 insertions(+)
create mode 100644 src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
create mode 100644 src/test/java/com/github/difflib/unifieddiff/UnifiedDiffTest.java
create mode 100644 src/test/resources/com/github/difflib/unifieddiff/jsqlparser_patch_1.diff
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
new file mode 100644
index 00000000..9fb51846
--- /dev/null
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2019 java-diff-utils.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.difflib.unifieddiff;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Tobias Warneke (t.warneke@gmx.net)
+ */
+public final class UnifiedDiff {
+
+ private UnifiedDiff(InputStream stream) throws IOException {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream));) {
+ while (reader.ready()) {
+ String line = reader.readLine();
+ LOG.info(line);
+ }
+ }
+
+ }
+ private static final Logger LOG = Logger.getLogger(UnifiedDiff.class.getName());
+
+ public static UnifiedDiff parse(InputStream stream) throws IOException {
+ return new UnifiedDiff(stream);
+ }
+}
diff --git a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffTest.java b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffTest.java
new file mode 100644
index 00000000..380eb8e9
--- /dev/null
+++ b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2019 java-diff-utils.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.difflib.unifieddiff;
+
+import java.io.IOException;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author Tobias Warneke (t.warneke@gmx.net)
+ */
+public class UnifiedDiffTest {
+
+ public UnifiedDiffTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void testSimpleParse() throws IOException {
+ UnifiedDiff diff = UnifiedDiff.parse(UnifiedDiffTest.class.getResourceAsStream("jsqlparser_patch_1.diff"));
+
+ System.out.println(diff);
+ }
+
+}
diff --git a/src/test/resources/com/github/difflib/unifieddiff/jsqlparser_patch_1.diff b/src/test/resources/com/github/difflib/unifieddiff/jsqlparser_patch_1.diff
new file mode 100644
index 00000000..c868759e
--- /dev/null
+++ b/src/test/resources/com/github/difflib/unifieddiff/jsqlparser_patch_1.diff
@@ -0,0 +1,61 @@
+From 3209a16c55c1976d5b772c607fd4b9d5fb9f9483 Mon Sep 17 00:00:00 2001
+From: wumpz
+Date: Tue, 19 Feb 2019 01:35:14 +0100
+Subject: [PATCH] fixes #753
+
+---
+ src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt | 5 +++--
+ .../net/sf/jsqlparser/statement/select/SelectTest.java | 7 +++++++
+ 2 files changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt b/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
+index cd9bcd1..5f4b2b7 100644
+--- a/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
++++ b/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
+@@ -189,6 +189,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
+ |
+ |
+ |
++|
+ |
+ |
+ |
+@@ -1039,7 +1040,7 @@ String RelObjectNameWithoutValue() :
+ | tk= | tk= | tk= | tk=
+ | tk=
+ | tk= | tk= | tk= | tk=
+- | tk= | tk= | tk=
++ | tk= | tk= | tk= | tk=
+ /* | tk= | tk= | tk= | tk= */
+ )
+
+@@ -3118,7 +3119,7 @@ Function Function() #Function:
+ Expression expr1 = null;
+ }
+ {
+- ["{fn" { retval.setEscaped(true); } ]
++ ["{" { retval.setEscaped(true); } ]
+
+ funcName=RelObjectNameExt()
+
+diff --git a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
+index 7ee9b38..d39bfd3 100644
+--- a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
++++ b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
+@@ -1063,6 +1063,13 @@ public class SelectTest {
+ assertSqlCanBeParsedAndDeparsed("SELECT {fn concat(a, b)} AS COL");
+ }
+
++ @Test
++ public void testEscapedFunctionsIssue753() throws JSQLParserException {
++ Statement stmt = CCJSqlParserUtil.parse("SELECT { fn test(0)} AS COL");
++ assertEquals("SELECT {fn test(0)} AS COL", stmt.toString());
++ assertSqlCanBeParsedAndDeparsed("SELECT fn FROM fn");
++ }
++
+ @Test
+ public void testNamedParametersPR702() throws JSQLParserException {
+ assertSqlCanBeParsedAndDeparsed("SELECT substring(id, 2, 3), substring(id from 2 for 3), substring(id from 2), trim(BOTH ' ' from 'foo bar '), trim(LEADING ' ' from 'foo bar '), trim(TRAILING ' ' from 'foo bar '), trim(' ' from 'foo bar '), position('foo' in 'bar'), overlay('foo' placing 'bar' from 1), overlay('foo' placing 'bar' from 1 for 2) FROM my table");
+--
+2.17.1.windows.2
+
From 4caf63c19370a0f35d3a42764e88aa7b44e50616 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Wed, 6 Mar 2019 01:34:39 +0100
Subject: [PATCH 024/262]
---
pom.xml | 6 +
.../difflib/unifieddiff/UnifiedDiff.java | 35 ++--
.../difflib/unifieddiff/UnifiedDiffFile.java | 60 +++++++
.../unifieddiff/UnifiedDiffParser.java | 167 ++++++++++++++++++
...ffTest.java => UnifiedDiffParserTest.java} | 13 +-
5 files changed, 262 insertions(+), 19 deletions(-)
create mode 100644 src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java
create mode 100644 src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
rename src/test/java/com/github/difflib/unifieddiff/{UnifiedDiffTest.java => UnifiedDiffParserTest.java} (62%)
diff --git a/pom.xml b/pom.xml
index 200c4d14..82ccd481 100644
--- a/pom.xml
+++ b/pom.xml
@@ -105,6 +105,12 @@
+
+ org.assertj
+ assertj-core
+ 3.11.1
+ test
+
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
index 9fb51846..76bd2740 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
@@ -15,30 +15,33 @@
*/
package com.github.difflib.unifieddiff;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.logging.Logger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
/**
*
* @author Tobias Warneke (t.warneke@gmx.net)
*/
-public final class UnifiedDiff {
+public class UnifiedDiff {
- private UnifiedDiff(InputStream stream) throws IOException {
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream));) {
- while (reader.ready()) {
- String line = reader.readLine();
- LOG.info(line);
- }
- }
+ private String header;
+ private final List files = new ArrayList<>();
+ public String getHeader() {
+ return header;
}
- private static final Logger LOG = Logger.getLogger(UnifiedDiff.class.getName());
- public static UnifiedDiff parse(InputStream stream) throws IOException {
- return new UnifiedDiff(stream);
+ public void setHeader(String header) {
+ this.header = header;
}
+
+ void addFile(UnifiedDiffFile file) {
+ files.add(file);
+ }
+
+ public List getFiles() {
+ return Collections.unmodifiableList(files);
+ }
+
}
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java
new file mode 100644
index 00000000..c1faa5ab
--- /dev/null
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2019 java-diff-utils.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.difflib.unifieddiff;
+
+/**
+ *
+ * @author Tobias Warneke (t.warneke@gmx.net)
+ */
+public class UnifiedDiffFile {
+
+ private String diffCommand;
+ private String fromFile;
+ private String toFile;
+ private String index;
+
+ public String getDiffCommand() {
+ return diffCommand;
+ }
+
+ public void setDiffCommand(String diffCommand) {
+ this.diffCommand = diffCommand;
+ }
+
+ public String getFromFile() {
+ return fromFile;
+ }
+
+ public void setFromFile(String fromFile) {
+ this.fromFile = fromFile;
+ }
+
+ public String getToFile() {
+ return toFile;
+ }
+
+ public void setToFile(String toFile) {
+ this.toFile = toFile;
+ }
+
+ public void setIndex(String index) {
+ this.index = index;
+ }
+
+ public String getIndex() {
+ return index;
+ }
+}
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
new file mode 100644
index 00000000..26194f12
--- /dev/null
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2019 java-diff-utils.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.difflib.unifieddiff;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.function.BiConsumer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.MatchResult;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ *
+ * @author Tobias Warneke (t.warneke@gmx.net)
+ */
+public final class UnifiedDiffParser {
+
+ private final UnifiedDiffReader READER;
+ private final UnifiedDiff data = new UnifiedDiff();
+ private final UnifiedDiffLine[] PARSER_RULES = new UnifiedDiffLine[]{
+ new UnifiedDiffLine("^\\s+", (m, l) -> LOG.info("normal " + l)),
+ new UnifiedDiffLine(true, "^diff\\s", UnifiedDiffParser::processDiff),
+ new UnifiedDiffLine(true, "^index\\s[\\da-zA-Z]+\\.\\.[\\da-zA-Z]+(\\s(\\d+))?$", UnifiedDiffParser::processIndex)
+ };
+ private UnifiedDiffFile actualFile;
+
+ UnifiedDiffParser(Reader reader) {
+ this.READER = new UnifiedDiffReader(reader);
+ }
+
+ // schema = [[/^\s+/, normal], [/^diff\s/, start], [/^new file mode \d+$/, new_file],
+ // [/^deleted file mode \d+$/, deleted_file], [/^index\s[\da-zA-Z]+\.\.[\da-zA-Z]+(\s(\d+))?$/, index],
+ // [/^---\s/, from_file], [/^\+\+\+\s/, to_file], [/^@@\s+\-(\d+),?(\d+)?\s+\+(\d+),?(\d+)?\s@@/, chunk],
+ // [/^-/, del], [/^\+/, add], [/^\\ No newline at end of file$/, eof]];
+ private UnifiedDiff parse() throws IOException {
+ boolean header = true;
+ String headerTxt = "";
+ while (READER.ready()) {
+ String line = READER.readLine();
+ if (processLine(header, line) == false) {
+ if (header) {
+ headerTxt += line + "\n";
+ } else {
+ break;
+ }
+ } else {
+ header = false;
+ data.setHeader(headerTxt);
+ }
+ }
+ return data;
+ }
+
+ static String[] parseFileNames(String line) {
+ String[] split = line.split(" ");
+ return new String[]{
+ split[2].replaceAll("^a/", ""),
+ split[3].replaceAll("^b/", "")
+ };
+ }
+
+ private static final Logger LOG = Logger.getLogger(UnifiedDiffParser.class.getName());
+
+ public static UnifiedDiff parseUnifiedDiff(InputStream stream) throws IOException {
+ UnifiedDiffParser parser = new UnifiedDiffParser(new BufferedReader(new InputStreamReader(stream)));
+ return parser.parse();
+ }
+
+ private boolean processLine(boolean header, String line) {
+ for (UnifiedDiffLine rule : PARSER_RULES) {
+ if (header && rule.isStopsHeaderParsing() || !header) {
+ if (rule.processLine(line)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private void initFileIfNecessary() {
+ if (actualFile == null) {
+ actualFile = new UnifiedDiffFile();
+ }
+ }
+
+ private void processDiff(MatchResult match, String line) {
+ initFileIfNecessary();
+ LOG.log(Level.INFO, "start {0}", line);
+ String[] fromTo = parseFileNames(READER.lastLine());
+ actualFile.setFromFile(fromTo[0]);
+ actualFile.setToFile(fromTo[1]);
+ }
+
+ private void processIndex(MatchResult match, String line) {
+ initFileIfNecessary();
+ LOG.log(Level.INFO, "index {0}", line);
+ actualFile.setIndex(line.substring(6));
+ }
+
+ class UnifiedDiffLine {
+
+ private final Pattern pattern;
+ private final BiConsumer command;
+ private final boolean stopsHeaderParsing;
+
+ public UnifiedDiffLine(String pattern, BiConsumer command) {
+ this(false, pattern, command);
+ }
+
+ public UnifiedDiffLine(boolean stopsHeaderParsing, String pattern, BiConsumer command) {
+ this.pattern = Pattern.compile(pattern);
+ this.command = command;
+ this.stopsHeaderParsing = stopsHeaderParsing;
+ }
+
+ public boolean processLine(String line) {
+ Matcher m = pattern.matcher(line);
+ if (m.find()) {
+ command.accept(m.toMatchResult(), line);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isStopsHeaderParsing() {
+ return stopsHeaderParsing;
+ }
+ }
+}
+
+class UnifiedDiffReader extends BufferedReader {
+
+ private String lastLine;
+
+ public UnifiedDiffReader(Reader reader) {
+ super(reader);
+ }
+
+ @Override
+ public String readLine() throws IOException {
+ lastLine = super.readLine();
+ return lastLine();
+ }
+
+ String lastLine() {
+ return lastLine;
+ }
+}
diff --git a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffTest.java b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
similarity index 62%
rename from src/test/java/com/github/difflib/unifieddiff/UnifiedDiffTest.java
rename to src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
index 380eb8e9..9eb6e052 100644
--- a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffTest.java
+++ b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
@@ -16,6 +16,7 @@
package com.github.difflib.unifieddiff;
import java.io.IOException;
+import static org.assertj.core.api.Java6Assertions.assertThat;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -26,9 +27,9 @@
*
* @author Tobias Warneke (t.warneke@gmx.net)
*/
-public class UnifiedDiffTest {
+public class UnifiedDiffParserTest {
- public UnifiedDiffTest() {
+ public UnifiedDiffParserTest() {
}
@BeforeClass
@@ -49,9 +50,15 @@ public void tearDown() {
@Test
public void testSimpleParse() throws IOException {
- UnifiedDiff diff = UnifiedDiff.parse(UnifiedDiffTest.class.getResourceAsStream("jsqlparser_patch_1.diff"));
+ UnifiedDiff diff = UnifiedDiffParser.parseUnifiedDiff(UnifiedDiffParserTest.class.getResourceAsStream("jsqlparser_patch_1.diff"));
System.out.println(diff);
}
+ @Test
+ public void testParseDiffBlock() {
+ String[] files = UnifiedDiffParser.parseFileNames("diff --git a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java");
+ assertThat(files).containsExactly("src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java", "src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java");
+ }
+
}
From c917f77bbf754b23e454f0ee4c7492f9183ef940 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Wed, 6 Mar 2019 01:45:39 +0100
Subject: [PATCH 025/262]
---
.../com/github/difflib/unifieddiff/UnifiedDiffParser.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
index 26194f12..77f218d3 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
@@ -37,8 +37,8 @@ public final class UnifiedDiffParser {
private final UnifiedDiff data = new UnifiedDiff();
private final UnifiedDiffLine[] PARSER_RULES = new UnifiedDiffLine[]{
new UnifiedDiffLine("^\\s+", (m, l) -> LOG.info("normal " + l)),
- new UnifiedDiffLine(true, "^diff\\s", UnifiedDiffParser::processDiff),
- new UnifiedDiffLine(true, "^index\\s[\\da-zA-Z]+\\.\\.[\\da-zA-Z]+(\\s(\\d+))?$", UnifiedDiffParser::processIndex)
+ new UnifiedDiffLine(true, "^diff\\s", this::processDiff),
+ new UnifiedDiffLine(true, "^index\\s[\\da-zA-Z]+\\.\\.[\\da-zA-Z]+(\\s(\\d+))?$", this::processIndex)
};
private UnifiedDiffFile actualFile;
@@ -101,7 +101,7 @@ private void initFileIfNecessary() {
}
}
- private void processDiff(MatchResult match, String line) {
+ public void processDiff(MatchResult match, String line) {
initFileIfNecessary();
LOG.log(Level.INFO, "start {0}", line);
String[] fromTo = parseFileNames(READER.lastLine());
@@ -109,7 +109,7 @@ private void processDiff(MatchResult match, String line) {
actualFile.setToFile(fromTo[1]);
}
- private void processIndex(MatchResult match, String line) {
+ public void processIndex(MatchResult match, String line) {
initFileIfNecessary();
LOG.log(Level.INFO, "index {0}", line);
actualFile.setIndex(line.substring(6));
From 361c27d5e7e472df372894b29e3ebb96ae18b019 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Wed, 6 Mar 2019 01:54:39 +0100
Subject: [PATCH 026/262]
---
.../java/com/github/difflib/unifieddiff/UnifiedDiffParser.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
index 77f218d3..84ddfc41 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
@@ -98,6 +98,7 @@ private boolean processLine(boolean header, String line) {
private void initFileIfNecessary() {
if (actualFile == null) {
actualFile = new UnifiedDiffFile();
+ data.addFile(actualFile);
}
}
From a523ba3a14747c1ca0d6316215052698414d7463 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Sun, 10 Mar 2019 19:24:03 +0100
Subject: [PATCH 027/262]
---
.../difflib/unifieddiff/UnifiedDiffFile.java | 7 ++
.../unifieddiff/UnifiedDiffParser.java | 66 ++++++++++++++++---
.../UnifiedDiffParserException.java | 43 ++++++++++++
3 files changed, 108 insertions(+), 8 deletions(-)
create mode 100644 src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParserException.java
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java
index c1faa5ab..cd49de57 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java
@@ -15,6 +15,8 @@
*/
package com.github.difflib.unifieddiff;
+import com.github.difflib.patch.Patch;
+
/**
*
* @author Tobias Warneke (t.warneke@gmx.net)
@@ -25,6 +27,7 @@ public class UnifiedDiffFile {
private String fromFile;
private String toFile;
private String index;
+ private Patch patch = new Patch<>();
public String getDiffCommand() {
return diffCommand;
@@ -57,4 +60,8 @@ public void setIndex(String index) {
public String getIndex() {
return index;
}
+
+ public Patch getPatch() {
+ return patch;
+ }
}
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
index 84ddfc41..7244169b 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
@@ -20,6 +20,8 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
import java.util.function.BiConsumer;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -33,13 +35,18 @@
*/
public final class UnifiedDiffParser {
+ private static final String UNIFIED_DIFF_CHUNK_REGEXP = "^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@$";
+
private final UnifiedDiffReader READER;
private final UnifiedDiff data = new UnifiedDiff();
- private final UnifiedDiffLine[] PARSER_RULES = new UnifiedDiffLine[]{
- new UnifiedDiffLine("^\\s+", (m, l) -> LOG.info("normal " + l)),
+ private final UnifiedDiffLine[] MAIN_PARSER_RULES = new UnifiedDiffLine[]{
new UnifiedDiffLine(true, "^diff\\s", this::processDiff),
- new UnifiedDiffLine(true, "^index\\s[\\da-zA-Z]+\\.\\.[\\da-zA-Z]+(\\s(\\d+))?$", this::processIndex)
+ new UnifiedDiffLine(true, "^index\\s[\\da-zA-Z]+\\.\\.[\\da-zA-Z]+(\\s(\\d+))?$", this::processIndex),
+ new UnifiedDiffLine(true, "^---\\s", this::processFromFile),
+ new UnifiedDiffLine(true, "^\\+\\+\\+\\s", this::processToFile),
+ new UnifiedDiffLine(true, UNIFIED_DIFF_CHUNK_REGEXP, this::processChunk)
};
+
private UnifiedDiffFile actualFile;
UnifiedDiffParser(Reader reader) {
@@ -50,7 +57,7 @@ public final class UnifiedDiffParser {
// [/^deleted file mode \d+$/, deleted_file], [/^index\s[\da-zA-Z]+\.\.[\da-zA-Z]+(\s(\d+))?$/, index],
// [/^---\s/, from_file], [/^\+\+\+\s/, to_file], [/^@@\s+\-(\d+),?(\d+)?\s+\+(\d+),?(\d+)?\s@@/, chunk],
// [/^-/, del], [/^\+/, add], [/^\\ No newline at end of file$/, eof]];
- private UnifiedDiff parse() throws IOException {
+ private UnifiedDiff parse() throws IOException, UnifiedDiffParserException {
boolean header = true;
String headerTxt = "";
while (READER.ready()) {
@@ -79,13 +86,13 @@ static String[] parseFileNames(String line) {
private static final Logger LOG = Logger.getLogger(UnifiedDiffParser.class.getName());
- public static UnifiedDiff parseUnifiedDiff(InputStream stream) throws IOException {
+ public static UnifiedDiff parseUnifiedDiff(InputStream stream) throws IOException, UnifiedDiffParserException {
UnifiedDiffParser parser = new UnifiedDiffParser(new BufferedReader(new InputStreamReader(stream)));
return parser.parse();
}
- private boolean processLine(boolean header, String line) {
- for (UnifiedDiffLine rule : PARSER_RULES) {
+ private boolean processLine(boolean header, String line) throws UnifiedDiffParserException {
+ for (UnifiedDiffLine rule : MAIN_PARSER_RULES) {
if (header && rule.isStopsHeaderParsing() || !header) {
if (rule.processLine(line)) {
return true;
@@ -108,6 +115,35 @@ public void processDiff(MatchResult match, String line) {
String[] fromTo = parseFileNames(READER.lastLine());
actualFile.setFromFile(fromTo[0]);
actualFile.setToFile(fromTo[1]);
+ actualFile.setDiffCommand(line);
+ }
+
+ public void processChunk(MatchResult match, String chunkStart) {
+ try {
+ List originalTxt = new ArrayList<>();
+ List revisedTxt = new ArrayList<>();
+
+ int old_ln = match.group(1) == null ? 1 : Integer.parseInt(match.group(1));
+ int new_ln = match.group(3) == null ? 1 : Integer.parseInt(match.group(3));
+
+ while (this.READER.ready()) {
+ String line = READER.readLine();
+
+ if (line.startsWith(" ") || line.startsWith("+")) {
+ revisedTxt.add(line.substring(1));
+ }
+ if (line.startsWith(" ") || line.startsWith("-")) {
+ originalTxt.add(line.substring(1));
+ }
+ if (line.equals("")) {
+ break;
+ }
+ }
+
+ } catch (IOException ex) {
+ Logger.getLogger(UnifiedDiffParser.class.getName()).log(Level.SEVERE, null, ex);
+ throw new UnifiedDiffParserException(ex);
+ }
}
public void processIndex(MatchResult match, String line) {
@@ -116,6 +152,20 @@ public void processIndex(MatchResult match, String line) {
actualFile.setIndex(line.substring(6));
}
+ private void processFromFile(MatchResult match, String line) {
+ initFileIfNecessary();
+ actualFile.setFromFile(extractFileName(line));
+ }
+
+ private void processToFile(MatchResult match, String line) {
+ initFileIfNecessary();
+ actualFile.setToFile(extractFileName(line));
+ }
+
+ private String extractFileName(String line) {
+ return line.substring(4).replaceFirst("^(a|b)\\/", "");
+ }
+
class UnifiedDiffLine {
private final Pattern pattern;
@@ -132,7 +182,7 @@ public UnifiedDiffLine(boolean stopsHeaderParsing, String pattern, BiConsumer
Date: Sun, 10 Mar 2019 19:24:09 +0100
Subject: [PATCH 028/262]
From 55e4867e88fdc39e5865f0ef526fb397a7c96ca1 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Sun, 10 Mar 2019 23:36:16 +0100
Subject: [PATCH 029/262]
---
.../unifieddiff/UnifiedDiffParser.java | 64 +++++++++++++++----
.../unifieddiff/UnifiedDiffParserTest.java | 31 +++++++++
2 files changed, 82 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
index 7244169b..d43aae0c 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
@@ -15,6 +15,8 @@
*/
package com.github.difflib.unifieddiff;
+import com.github.difflib.patch.ChangeDelta;
+import com.github.difflib.patch.Chunk;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -35,7 +37,7 @@
*/
public final class UnifiedDiffParser {
- private static final String UNIFIED_DIFF_CHUNK_REGEXP = "^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@$";
+ static final Pattern UNIFIED_DIFF_CHUNK_REGEXP = Pattern.compile("^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
private final UnifiedDiffReader READER;
private final UnifiedDiff data = new UnifiedDiff();
@@ -62,6 +64,7 @@ private UnifiedDiff parse() throws IOException, UnifiedDiffParserException {
String headerTxt = "";
while (READER.ready()) {
String line = READER.readLine();
+ LOG.log(Level.INFO, "parsing line {0}", line);
if (processLine(header, line) == false) {
if (header) {
headerTxt += line + "\n";
@@ -118,25 +121,54 @@ public void processDiff(MatchResult match, String line) {
actualFile.setDiffCommand(line);
}
- public void processChunk(MatchResult match, String chunkStart) {
+ public void processChunk(MatchResult _match, String chunkStart) {
+ MatchResult match = _match;
try {
- List originalTxt = new ArrayList<>();
- List revisedTxt = new ArrayList<>();
- int old_ln = match.group(1) == null ? 1 : Integer.parseInt(match.group(1));
- int new_ln = match.group(3) == null ? 1 : Integer.parseInt(match.group(3));
+ while (true) {
- while (this.READER.ready()) {
- String line = READER.readLine();
+ List originalTxt = new ArrayList<>();
+ List revisedTxt = new ArrayList<>();
- if (line.startsWith(" ") || line.startsWith("+")) {
- revisedTxt.add(line.substring(1));
+ int old_ln = match.group(1) == null ? 1 : Integer.parseInt(match.group(1));
+ int new_ln = match.group(3) == null ? 1 : Integer.parseInt(match.group(3));
+ if (old_ln == 0) {
+ old_ln = 1;
}
- if (line.startsWith(" ") || line.startsWith("-")) {
- originalTxt.add(line.substring(1));
+ if (new_ln == 0) {
+ new_ln = 1;
}
- if (line.equals("")) {
+
+ while (this.READER.ready()) {
+ String line = READER.readLine();
+ LOG.log(Level.INFO, "processing chunk line {0}", line);
+
+ if (line.startsWith(" ") || line.startsWith("+")) {
+ revisedTxt.add(line.substring(1));
+ }
+ if (line.startsWith(" ") || line.startsWith("-")) {
+ originalTxt.add(line.substring(1));
+ }
+ if (line.equals("") || line.startsWith("@@") || line.startsWith("--")) {
+ break;
+ }
+ }
+
+ actualFile.getPatch().addDelta(new ChangeDelta<>(new Chunk<>(
+ old_ln - 1, originalTxt), new Chunk<>(
+ new_ln - 1, revisedTxt)));
+
+ if (READER.lastLine().equals("")
+ || READER.lastLine().startsWith("--")
+ || !READER.lastLine().startsWith("@@")) {
break;
+ } else {
+ Matcher m = UNIFIED_DIFF_CHUNK_REGEXP.matcher(READER.lastLine());
+ if (m.find()) {
+ match = m.toMatchResult();
+ } else {
+ break;
+ }
}
}
@@ -182,6 +214,12 @@ public UnifiedDiffLine(boolean stopsHeaderParsing, String pattern, BiConsumer command) {
+ this.pattern = pattern;
+ this.command = command;
+ this.stopsHeaderParsing = stopsHeaderParsing;
+ }
+
public boolean processLine(String line) throws UnifiedDiffParserException {
Matcher m = pattern.matcher(line);
if (m.find()) {
diff --git a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
index 9eb6e052..e13eb563 100644
--- a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
+++ b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
@@ -16,9 +16,13 @@
package com.github.difflib.unifieddiff;
import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import static org.assertj.core.api.Java6Assertions.assertThat;
import org.junit.After;
import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -53,6 +57,12 @@ public void testSimpleParse() throws IOException {
UnifiedDiff diff = UnifiedDiffParser.parseUnifiedDiff(UnifiedDiffParserTest.class.getResourceAsStream("jsqlparser_patch_1.diff"));
System.out.println(diff);
+
+ assertThat(diff.getFiles().size()).isEqualTo(2);
+
+ UnifiedDiffFile file1 = diff.getFiles().get(0);
+ assertThat(file1.getFromFile()).isEqualTo("src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt");
+ assertThat(file1.getPatch().getDeltas().size()).isEqualTo(3);
}
@Test
@@ -61,4 +71,25 @@ public void testParseDiffBlock() {
assertThat(files).containsExactly("src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java", "src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java");
}
+ @Test
+ public void testChunkHeaderParsing() {
+ Pattern pattern = UnifiedDiffParser.UNIFIED_DIFF_CHUNK_REGEXP;
+ Matcher matcher = pattern.matcher("@@ -189,6 +189,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */");
+
+ assertTrue(matcher.find());
+ assertEquals("189", matcher.group(1));
+ assertEquals("189", matcher.group(3));
+ }
+
+ @Test
+ public void testChunkHeaderParsing2() {
+ //"^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@.*$"
+ Pattern pattern = UnifiedDiffParser.UNIFIED_DIFF_CHUNK_REGEXP;
+ Matcher matcher = pattern.matcher("@@ -189,6 +189,7 @@");
+
+ assertTrue(matcher.find());
+ assertEquals("189", matcher.group(1));
+ assertEquals("189", matcher.group(3));
+ }
+
}
From d2355a8435052f8c508de28835105b822102672d Mon Sep 17 00:00:00 2001
From: wumpz
Date: Tue, 12 Mar 2019 00:15:51 +0100
Subject: [PATCH 030/262]
---
.../difflib/unifieddiff/UnifiedDiff.java | 8 ++
.../unifieddiff/UnifiedDiffParser.java | 126 ++++++++++--------
.../unifieddiff/UnifiedDiffParserTest.java | 2 +
3 files changed, 77 insertions(+), 59 deletions(-)
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
index 76bd2740..42db0aee 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
@@ -26,6 +26,7 @@
public class UnifiedDiff {
private String header;
+ private String tail;
private final List files = new ArrayList<>();
public String getHeader() {
@@ -44,4 +45,11 @@ public List getFiles() {
return Collections.unmodifiableList(files);
}
+ void setTailTxt(String tailTxt) {
+ this.tail = tailTxt;
+ }
+
+ public String getTail() {
+ return tail;
+ }
}
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
index d43aae0c..77aa614f 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
@@ -46,7 +46,10 @@ public final class UnifiedDiffParser {
new UnifiedDiffLine(true, "^index\\s[\\da-zA-Z]+\\.\\.[\\da-zA-Z]+(\\s(\\d+))?$", this::processIndex),
new UnifiedDiffLine(true, "^---\\s", this::processFromFile),
new UnifiedDiffLine(true, "^\\+\\+\\+\\s", this::processToFile),
- new UnifiedDiffLine(true, UNIFIED_DIFF_CHUNK_REGEXP, this::processChunk)
+ new UnifiedDiffLine(false, UNIFIED_DIFF_CHUNK_REGEXP, this::processChunk),
+ new UnifiedDiffLine("^\\s+", this::processNormalLine),
+ new UnifiedDiffLine("^-", this::processDelLine),
+ new UnifiedDiffLine("^+", this::processAddLine)
};
private UnifiedDiffFile actualFile;
@@ -62,20 +65,33 @@ public final class UnifiedDiffParser {
private UnifiedDiff parse() throws IOException, UnifiedDiffParserException {
boolean header = true;
String headerTxt = "";
+ String tailTxt = "";
while (READER.ready()) {
String line = READER.readLine();
- LOG.log(Level.INFO, "parsing line {0}", line);
- if (processLine(header, line) == false) {
- if (header) {
- headerTxt += line + "\n";
+ if (line.matches("^\\-\\-\\s+")) {
+ break;
+ } else {
+ LOG.log(Level.INFO, "parsing line {0}", line);
+ if (processLine(header, line) == false) {
+ if (header) {
+ headerTxt += line + "\n";
+ } else {
+ break;
+ }
} else {
- break;
+ header = false;
+ data.setHeader(headerTxt);
}
- } else {
- header = false;
- data.setHeader(headerTxt);
}
}
+
+ finalizeChunk();
+
+ while (READER.ready()) {
+ tailTxt += READER.readLine() + "\n";
+ }
+ data.setTailTxt(tailTxt);
+
return data;
}
@@ -106,6 +122,10 @@ private boolean processLine(boolean header, String line) throws UnifiedDiffParse
}
private void initFileIfNecessary() {
+ if (!originalTxt.isEmpty() || !revisedTxt.isEmpty()) {
+ finalizeChunk();
+ actualFile = null;
+ }
if (actualFile == null) {
actualFile = new UnifiedDiffFile();
data.addFile(actualFile);
@@ -121,60 +141,48 @@ public void processDiff(MatchResult match, String line) {
actualFile.setDiffCommand(line);
}
- public void processChunk(MatchResult _match, String chunkStart) {
- MatchResult match = _match;
- try {
-
- while (true) {
-
- List originalTxt = new ArrayList<>();
- List revisedTxt = new ArrayList<>();
-
- int old_ln = match.group(1) == null ? 1 : Integer.parseInt(match.group(1));
- int new_ln = match.group(3) == null ? 1 : Integer.parseInt(match.group(3));
- if (old_ln == 0) {
- old_ln = 1;
- }
- if (new_ln == 0) {
- new_ln = 1;
- }
-
- while (this.READER.ready()) {
- String line = READER.readLine();
- LOG.log(Level.INFO, "processing chunk line {0}", line);
+ private List originalTxt = new ArrayList<>();
+ private List revisedTxt = new ArrayList<>();
+ private int old_ln;
+ private int new_ln;
+
+ private void finalizeChunk() {
+ if (!originalTxt.isEmpty() || !revisedTxt.isEmpty()) {
+ actualFile.getPatch().addDelta(new ChangeDelta<>(new Chunk<>(
+ old_ln - 1, originalTxt), new Chunk<>(
+ new_ln - 1, revisedTxt)));
+ old_ln = 0;
+ new_ln = 0;
+ originalTxt.clear();
+ revisedTxt.clear();
+ }
+ }
- if (line.startsWith(" ") || line.startsWith("+")) {
- revisedTxt.add(line.substring(1));
- }
- if (line.startsWith(" ") || line.startsWith("-")) {
- originalTxt.add(line.substring(1));
- }
- if (line.equals("") || line.startsWith("@@") || line.startsWith("--")) {
- break;
- }
- }
+ public void processNormalLine(MatchResult match, String line) {
+ String cline = line.substring(1);
+ originalTxt.add(cline);
+ revisedTxt.add(cline);
+ }
- actualFile.getPatch().addDelta(new ChangeDelta<>(new Chunk<>(
- old_ln - 1, originalTxt), new Chunk<>(
- new_ln - 1, revisedTxt)));
+ public void processAddLine(MatchResult match, String line) {
+ String cline = line.substring(1);
+ revisedTxt.add(cline);
+ }
- if (READER.lastLine().equals("")
- || READER.lastLine().startsWith("--")
- || !READER.lastLine().startsWith("@@")) {
- break;
- } else {
- Matcher m = UNIFIED_DIFF_CHUNK_REGEXP.matcher(READER.lastLine());
- if (m.find()) {
- match = m.toMatchResult();
- } else {
- break;
- }
- }
- }
+ public void processDelLine(MatchResult match, String line) {
+ String cline = line.substring(1);
+ originalTxt.add(cline);
+ }
- } catch (IOException ex) {
- Logger.getLogger(UnifiedDiffParser.class.getName()).log(Level.SEVERE, null, ex);
- throw new UnifiedDiffParserException(ex);
+ public void processChunk(MatchResult match, String chunkStart) {
+ finalizeChunk();
+ old_ln = match.group(1) == null ? 1 : Integer.parseInt(match.group(1));
+ new_ln = match.group(3) == null ? 1 : Integer.parseInt(match.group(3));
+ if (old_ln == 0) {
+ old_ln = 1;
+ }
+ if (new_ln == 0) {
+ new_ln = 1;
}
}
diff --git a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
index e13eb563..6fe916d8 100644
--- a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
+++ b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
@@ -63,6 +63,8 @@ public void testSimpleParse() throws IOException {
UnifiedDiffFile file1 = diff.getFiles().get(0);
assertThat(file1.getFromFile()).isEqualTo("src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt");
assertThat(file1.getPatch().getDeltas().size()).isEqualTo(3);
+
+ assertThat(diff.getTail()).isEqualTo("2.17.1.windows.2\n\n");
}
@Test
From 05b5d80d48b338ceaf95f8b2d32c7e77cbda5f23 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Mon, 18 Mar 2019 22:34:08 +0100
Subject: [PATCH 031/262]
---
.../com/github/difflib/unifieddiff/UnifiedDiff.java | 12 +++++++++++-
.../github/difflib/unifieddiff/UnifiedDiffFile.java | 10 +++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
index 42db0aee..e1a52112 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiff.java
@@ -23,7 +23,7 @@
*
* @author Tobias Warneke (t.warneke@gmx.net)
*/
-public class UnifiedDiff {
+public final class UnifiedDiff {
private String header;
private String tail;
@@ -52,4 +52,14 @@ void setTailTxt(String tailTxt) {
public String getTail() {
return tail;
}
+
+ public static UnifiedDiff from(String header, String tail, UnifiedDiffFile... files) {
+ UnifiedDiff diff = new UnifiedDiff();
+ diff.setHeader(header);
+ diff.setTailTxt(tail);
+ for (UnifiedDiffFile file : files) {
+ diff.addFile(file);
+ }
+ return diff;
+ }
}
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java
index cd49de57..d57b9233 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffFile.java
@@ -21,7 +21,7 @@
*
* @author Tobias Warneke (t.warneke@gmx.net)
*/
-public class UnifiedDiffFile {
+public final class UnifiedDiffFile {
private String diffCommand;
private String fromFile;
@@ -64,4 +64,12 @@ public String getIndex() {
public Patch getPatch() {
return patch;
}
+
+ public static UnifiedDiffFile from(String fromFile, String toFile, Patch patch) {
+ UnifiedDiffFile file = new UnifiedDiffFile();
+ file.setFromFile(fromFile);
+ file.setToFile(toFile);
+ file.patch = patch;
+ return file;
+ }
}
From 983ec680f732dca4f96cf154c2eedddc7405e729 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Mon, 18 Mar 2019 22:36:49 +0100
Subject: [PATCH 032/262]
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 82ccd481..b7ca5ea3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -249,7 +249,7 @@
com.puppycrawl.toolscheckstyle
- 6.19
+ 8.18
From 8c86e0f8d7f6d71fcb22f1588aebd73c308b9060 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Tue, 26 Mar 2019 07:58:25 +0100
Subject: [PATCH 033/262] upgraded checkstyle plugin (security alert from
github)
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 200c4d14..4fec1a65 100644
--- a/pom.xml
+++ b/pom.xml
@@ -243,7 +243,7 @@
com.puppycrawl.toolscheckstyle
- 6.19
+ 8.12
From 4a83032d7e027beaecd106079f8a50427ba080a2 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Tue, 26 Mar 2019 21:14:54 +0100
Subject: [PATCH 034/262]
---
...DiffParser.java => UnifiedDiffReader.java} | 16 +++---
.../unifieddiff/UnifiedDiffWriter.java | 29 ++++++++++
...erTest.java => UnifiedDiffReaderTest.java} | 12 ++--
.../unifieddiff/UnifiedDiffWriterTest.java | 55 +++++++++++++++++++
4 files changed, 98 insertions(+), 14 deletions(-)
rename src/main/java/com/github/difflib/unifieddiff/{UnifiedDiffParser.java => UnifiedDiffReader.java} (95%)
create mode 100644 src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java
rename src/test/java/com/github/difflib/unifieddiff/{UnifiedDiffParserTest.java => UnifiedDiffReaderTest.java} (87%)
create mode 100644 src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java
similarity index 95%
rename from src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
rename to src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java
index 77aa614f..9126ad78 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java
@@ -35,11 +35,11 @@
*
* @author Tobias Warneke (t.warneke@gmx.net)
*/
-public final class UnifiedDiffParser {
+public final class UnifiedDiffReader {
static final Pattern UNIFIED_DIFF_CHUNK_REGEXP = Pattern.compile("^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
- private final UnifiedDiffReader READER;
+ private final InternalUnifiedDiffReader READER;
private final UnifiedDiff data = new UnifiedDiff();
private final UnifiedDiffLine[] MAIN_PARSER_RULES = new UnifiedDiffLine[]{
new UnifiedDiffLine(true, "^diff\\s", this::processDiff),
@@ -54,8 +54,8 @@ public final class UnifiedDiffParser {
private UnifiedDiffFile actualFile;
- UnifiedDiffParser(Reader reader) {
- this.READER = new UnifiedDiffReader(reader);
+ UnifiedDiffReader(Reader reader) {
+ this.READER = new InternalUnifiedDiffReader(reader);
}
// schema = [[/^\s+/, normal], [/^diff\s/, start], [/^new file mode \d+$/, new_file],
@@ -103,10 +103,10 @@ static String[] parseFileNames(String line) {
};
}
- private static final Logger LOG = Logger.getLogger(UnifiedDiffParser.class.getName());
+ private static final Logger LOG = Logger.getLogger(UnifiedDiffReader.class.getName());
public static UnifiedDiff parseUnifiedDiff(InputStream stream) throws IOException, UnifiedDiffParserException {
- UnifiedDiffParser parser = new UnifiedDiffParser(new BufferedReader(new InputStreamReader(stream)));
+ UnifiedDiffReader parser = new UnifiedDiffReader(new BufferedReader(new InputStreamReader(stream)));
return parser.parse();
}
@@ -244,11 +244,11 @@ public boolean isStopsHeaderParsing() {
}
}
-class UnifiedDiffReader extends BufferedReader {
+class InternalUnifiedDiffReader extends BufferedReader {
private String lastLine;
- public UnifiedDiffReader(Reader reader) {
+ public InternalUnifiedDiffReader(Reader reader) {
super(reader);
}
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java
new file mode 100644
index 00000000..4cbf67ff
--- /dev/null
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2019 java-diff-utils.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.difflib.unifieddiff;
+
+import java.io.Writer;
+
+/**
+ *
+ * @author Tobias Warneke (t.warneke@gmx.net)
+ */
+public class UnifiedDiffWriter {
+
+ public static void write(UnifiedDiff diff, Writer writer) {
+
+ }
+}
diff --git a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java
similarity index 87%
rename from src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
rename to src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java
index 6fe916d8..38526a8b 100644
--- a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java
+++ b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java
@@ -31,9 +31,9 @@
*
* @author Tobias Warneke (t.warneke@gmx.net)
*/
-public class UnifiedDiffParserTest {
+public class UnifiedDiffReaderTest {
- public UnifiedDiffParserTest() {
+ public UnifiedDiffReaderTest() {
}
@BeforeClass
@@ -54,7 +54,7 @@ public void tearDown() {
@Test
public void testSimpleParse() throws IOException {
- UnifiedDiff diff = UnifiedDiffParser.parseUnifiedDiff(UnifiedDiffParserTest.class.getResourceAsStream("jsqlparser_patch_1.diff"));
+ UnifiedDiff diff = UnifiedDiffReader.parseUnifiedDiff(UnifiedDiffReaderTest.class.getResourceAsStream("jsqlparser_patch_1.diff"));
System.out.println(diff);
@@ -69,13 +69,13 @@ public void testSimpleParse() throws IOException {
@Test
public void testParseDiffBlock() {
- String[] files = UnifiedDiffParser.parseFileNames("diff --git a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java");
+ String[] files = UnifiedDiffReader.parseFileNames("diff --git a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java");
assertThat(files).containsExactly("src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java", "src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java");
}
@Test
public void testChunkHeaderParsing() {
- Pattern pattern = UnifiedDiffParser.UNIFIED_DIFF_CHUNK_REGEXP;
+ Pattern pattern = UnifiedDiffReader.UNIFIED_DIFF_CHUNK_REGEXP;
Matcher matcher = pattern.matcher("@@ -189,6 +189,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */");
assertTrue(matcher.find());
@@ -86,7 +86,7 @@ public void testChunkHeaderParsing() {
@Test
public void testChunkHeaderParsing2() {
//"^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@.*$"
- Pattern pattern = UnifiedDiffParser.UNIFIED_DIFF_CHUNK_REGEXP;
+ Pattern pattern = UnifiedDiffReader.UNIFIED_DIFF_CHUNK_REGEXP;
Matcher matcher = pattern.matcher("@@ -189,6 +189,7 @@");
assertTrue(matcher.find());
diff --git a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java
new file mode 100644
index 00000000..d73dcb7d
--- /dev/null
+++ b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2019 java-diff-utils.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.github.difflib.unifieddiff;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author Tobias Warneke (t.warneke@gmx.net)
+ */
+public class UnifiedDiffWriterTest {
+
+ public UnifiedDiffWriterTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void testSomeMethod() {
+ // TODO review the generated test code and remove the default call to fail.
+ fail("The test case is a prototype.");
+ }
+
+}
From 61a21cbca91ddda3337d315d8768fc0d31482b26 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Tue, 26 Mar 2019 21:36:31 +0100
Subject: [PATCH 035/262]
---
.../github/difflib/unifieddiff/UnifiedDiffWriterTest.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java
index d73dcb7d..7b8e1576 100644
--- a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java
+++ b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java
@@ -47,9 +47,8 @@ public void tearDown() {
}
@Test
- public void testSomeMethod() {
- // TODO review the generated test code and remove the default call to fail.
- fail("The test case is a prototype.");
+ public void testWrite() {
+
}
}
From 535ecf3e2a55811769a19fbe977bc89fc637168b Mon Sep 17 00:00:00 2001
From: Oliver Kopp
Date: Sun, 31 Mar 2019 14:18:24 +0200
Subject: [PATCH 036/262] Move CHANGELOG to separte file CHANGELOG.md
For more information on that format see http://keepachangelog.com/
---
CHANGELOG.md | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++
README.md | 33 ---------------------
2 files changed, 82 insertions(+), 33 deletions(-)
create mode 100644 CHANGELOG.md
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..dda5b33e
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,82 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
+This project uses a custom versioning scheme (and not [Semantic Versioning](https://semver.org/spec/v2.0.0.html)).
+
+## [Unreleased]
+
+### Changed
+
+* Exchange `0 += 1` for `0 = 1` in UnifiedDiffUtils
+
+## [4.0] – 2019-01-09
+
+### Changed
+
+* moved to organisation **java-diff-utils**
+* changed groupid to **io.github.java-diff-utils** and artifact id to **java-diff-utils**
+
+## [3.0] – 2018-10-18
+
+### Added
+
+* Introduced a process listener to diff algorithms. For long running
+ diffs one could implement some progress information.
+* automatic module name for JDK 9 and higher usage
+
+### Changed
+
+* changed generation of inline diffes, if there are different linefeeds within one diff, then these are excluded from the diff block.
+
+### Removed
+
+* Due to licensing issues Delta.java and DiffAlgorithm.java were removed.
+
+## [2.2] – 2017-11-09
+
+### Added
+
+* released at maven central
+* included checkstyle source code conventions
+* allow configurable splitting of lines to define the blocks to compare (words, characters, phrases).
+
+### Changed
+
+* groupid changed to **com.github.wumpz**, due to maven central releasing
+
+## [2.0] – 2017-08-14
+
+### Added
+
+* support for inline merge
+* integrated JGit (Eclipse Licensed) to provide HistogramDiff to gain speed for large datasets
+
+### Changed
+
+* switch to maven and removed other artifacts
+* changed groupid to **com.github.java-diff-utils** due to different forks at github
+* updated maven plugins
+* JDK 1.8 compatibility, sorry if you have to stick with older versions
+* restructured packages heavily
+* changed API
+* changed Algorithm to provide only cursor positions
+
+### Removed
+
+* removed all kinds of helper classes in favour of new JDK 8 function classes like Predicate
+
+## 1.2
+
+### Added
+
+* JDK 1.5 compatibility
+* Ant build script
+* Generate output in unified diff format (thanks for Bill James)
+
+[Unreleased]: https://github.com/java-diff-utils/java-diff-utils/compare/java-diff-utils-4.0...HEAD
+[4.0]: https://github.com/java-diff-utils/java-diff-utils/compare/diff-utils-3.0...java-diff-utils-4.0
+[3.0]: https://github.com/java-diff-utils/java-diff-utils/compare/diff-utils-2.2...diff-utils-3.0
+[2.2]: https://github.com/java-diff-utils/java-diff-utils/compare/diff-utils-2.0...diff-utils-2.2
+
diff --git a/README.md b/README.md
index c3c335ac..ebc61bd8 100644
--- a/README.md
+++ b/README.md
@@ -52,39 +52,6 @@ This is a test ~senctence~**for diffutils**.
But it can easily replaced by any other which is better for handing your texts. I have plan to add implementation of some in future.
-### Changelog ###
- * Version 4.0-SNAPSHOT
- * moved to organisation **java-diff-utils**
- * changed groupid to **io.github.java-diff-utils** and artifact id to **java-diff-utils**
- * Version 3.0
- * changed generation of inline diffes, if there are different linefeeds within one diff, then these are excluded
- from the diff block.
- * Due to licensing issues Delta.java and DiffAlgorithm.java were removed.
- * Version 2.3-SNAPSHOT
- * Introduced a process listener to diff algorithms. For long running
- diffs one could implement some progress information.
- * automatic module name for JDK 9 and higher usage
- * Version 2.2
- * released at maven central
- * included checkstyle source code conventions
- * groupid changed to **com.github.wumpz**, due to maven central releasing
- * allow configurable splitting of lines to define the blocks to compare (words, characters, phrases).
- * Version 2.0
- * switch to maven and removed other artifacts
- * changed groupid to **com.github.java-diff-utils** due to different forks at github
- * updated maven plugins
- * JDK 1.8 compatibility, sorry if you have to stick with older versions
- * support for inline merge
- * restructured packages heavily
- * changed API
- * changed Algorithm to provide only cursor positions
- * integrated JGit (Eclipse Licensed) to provide HistogramDiff to gain speed for large datasets
- * removed all kinds of helper classes in favour of new JDK 8 function classes like Predicate
- * Version 1.2
- * JDK 1.5 compatibility
- * Ant build script
- * Generate output in unified diff format (thanks for Bill James)
-
## Source Code conventions
Recently a checkstyle process was integrated into the build process. java-diff-utils follows the sun java format convention. There are no TABs allowed. Use spaces.
From a4bb85bab1e9984d2fa996f5d5b9417795aa7d33 Mon Sep 17 00:00:00 2001
From: Oliver Kopp
Date: Sun, 31 Mar 2019 14:29:09 +0200
Subject: [PATCH 037/262] Fix linting issues in README.md
---
README.md | 58 ++++++++++++++++++++++++++++---------------------------
1 file changed, 30 insertions(+), 28 deletions(-)
diff --git a/README.md b/README.md
index c3c335ac..2522bf42 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,22 @@
# java-diff-utils
-## Status ##
+## Status
+
[](https://travis-ci.org/java-diff-utils/java-diff-utils)
[](https://www.codacy.com/app/wumpz/java-diff-utils?utm_source=github.com&utm_medium=referral&utm_content=java-diff-utils/java-diff-utils&utm_campaign=Badge_Grade)
[](http://maven-badges.herokuapp.com/maven-central/io.github.java-diff-utils/java-diff-utils)
+## Intro
-## Intro ##
Diff Utils library is an OpenSource library for performing the comparison operations between texts: computing diffs, applying patches, generating unified diffs or parsing them, generating diff output for easy future displaying (like side-by-side view) and so on.
Main reason to build this library was the lack of easy-to-use libraries with all the usual stuff you need while working with diff files. Originally it was inspired by JRCS library and it's nice design of diff module.
**This is originally a fork of java-diff-utils from Google Code Archive.**
-## Examples ##
+## Examples
-Look [here](https://github.com/wumpz/java-diff-utils/wiki) to find more helpful informations and examples.
+Look [here](https://github.com/wumpz/java-diff-utils/wiki) to find more helpful informations and examples.
These two outputs are generated using this java-diff-utils. The source code can also be found at the *Examples* page:
@@ -23,7 +24,6 @@ These two outputs are generated using this java-diff-utils. The source code can
This is a test ~senctence~**for diffutils**.
-
**Producing a side by side view of computed differences.**
|original|new|
@@ -32,23 +32,22 @@ This is a test ~senctence~**for diffutils**.
|This is the second line.|This is the second line.|
|~And here is the finish.~||
+## Main Features
-## Main Features ##
-
- * computing the difference between two texts.
- * capable to hand more than plain ascci. Arrays or List of any type that implements hashCode() and equals() correctly can be subject to differencing using this library
- * patch and unpatch the text with the given patch
- * parsing the unified diff format
- * producing human-readable differences
- * inline difference construction
- * Algorithms:
- * Myer
- * HistogramDiff using JGit Library
+* computing the difference between two texts.
+* capable to hand more than plain ascci. Arrays or List of any type that implements hashCode() and equals() correctly can be subject to differencing using this library
+* patch and unpatch the text with the given patch
+* parsing the unified diff format
+* producing human-readable differences
+* inline difference construction
+* Algorithms:
+ * Myer
+ * HistogramDiff using JGit Library
-### Algoritms ###
+### Algoritms
* Myer's diff
-* HistogramDiff
+* HistogramDiff
But it can easily replaced by any other which is better for handing your texts. I have plan to add implementation of some in future.
@@ -91,24 +90,26 @@ Recently a checkstyle process was integrated into the build process. java-diff-u
```java
public static Patch diff(List original, List revised,
- BiPredicate equalizer) throws DiffException {
- if (equalizer != null) {
- return DiffUtils.diff(original, revised,
- new MyersDiff<>(equalizer));
- }
- return DiffUtils.diff(original, revised, new MyersDiff<>());
+ BiPredicate equalizer) throws DiffException {
+ if (equalizer != null) {
+ return DiffUtils.diff(original, revised,
+ new MyersDiff<>(equalizer));
+ }
+ return DiffUtils.diff(original, revised, new MyersDiff<>());
}
```
This is a valid piece of source code:
+
* blocks without braces are not allowed
* after control statements (if, while, for) a whitespace is expected
* the opening brace should be in the same line as the control statement
-### To Install ###
+### To Install
Just add the code below to your maven dependencies:
-```
+
+```xml
io.github.java-diff-utilsjava-diff-utils
@@ -118,7 +119,7 @@ Just add the code below to your maven dependencies:
Attention. We changed groupid and artifactid. Starting with version 4 you have to use:
-```
+```xml
io.github.java-diff-utilsjava-diff-utils
@@ -127,7 +128,8 @@ Attention. We changed groupid and artifactid. Starting with version 4 you have t
```
or using gradle:
-```
+
+```groovy
// https://mvnrepository.com/artifact/com.github.wumpz/diffutils
compile group: 'com.github.wumpz', name: 'diffutils', version: '2.2'
```
From 6321d5327c50e8a4516bbd254798035f940e84af Mon Sep 17 00:00:00 2001
From: Oliver Kopp
Date: Sun, 31 Mar 2019 14:33:54 +0200
Subject: [PATCH 038/262] Add support for IntelliJ to .gitignore
---
.gitignore | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index 0643ce7d..54a9c8ca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
-/target/
-/nbproject/
\ No newline at end of file
+.idea/
+build/
+nbproject/
+target/
From 13f2f5ede1aac32a3079836d0451cd03033dd507 Mon Sep 17 00:00:00 2001
From: 0xflotus <0xflotus@gmail.com>
Date: Tue, 2 Apr 2019 18:00:59 +0200
Subject: [PATCH 039/262] fixed Algorithms and Ascii
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 445729c4..03d4d100 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,7 @@ This is a test ~senctence~**for diffutils**.
## Main Features
* computing the difference between two texts.
-* capable to hand more than plain ascci. Arrays or List of any type that implements hashCode() and equals() correctly can be subject to differencing using this library
+* capable to hand more than plain ascii. Arrays or List of any type that implements hashCode() and equals() correctly can be subject to differencing using this library
* patch and unpatch the text with the given patch
* parsing the unified diff format
* producing human-readable differences
@@ -44,7 +44,7 @@ This is a test ~senctence~**for diffutils**.
* Myer
* HistogramDiff using JGit Library
-### Algoritms
+### Algorithms
* Myer's diff
* HistogramDiff
From 4c1a0bc07288b2c5752f2f9ac1dc343cedb3985d Mon Sep 17 00:00:00 2001
From: wumpz
Date: Mon, 15 Apr 2019 00:17:53 +0200
Subject: [PATCH 040/262]
---
.../unifieddiff/UnifiedDiffWriter.java | 25 +++++++++++-
.../unifieddiff/UnifiedDiffReaderTest.java | 23 -----------
.../unifieddiff/UnifiedDiffWriterTest.java | 40 +++++++++----------
3 files changed, 43 insertions(+), 45 deletions(-)
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java
index 4cbf67ff..6c552bc6 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java
@@ -15,6 +15,7 @@
*/
package com.github.difflib.unifieddiff;
+import java.io.IOException;
import java.io.Writer;
/**
@@ -23,7 +24,29 @@
*/
public class UnifiedDiffWriter {
- public static void write(UnifiedDiff diff, Writer writer) {
+ public static void write(UnifiedDiff diff, Writer writer) throws IOException {
+ writer.write(diff.getHeader());
+ for (UnifiedDiffFile file : diff.getFiles()) {
+ writeOrNothing(writer, file.getDiffCommand());
+ if (file.getIndex() != null) {
+ writer.write("index " + file.getIndex() + "\n");
+ }
+ if (file.getFromFile() != null) {
+ writer.write("--- " + file.getFromFile() + "\n");
+ }
+ if (file.getToFile() != null) {
+ writer.write("+++ " + file.getToFile() + "\n");
+ }
+
+ }
+
+ writer.write(diff.getTail());
+ }
+
+ private static void writeOrNothing(Writer writer, String str) throws IOException {
+ if (str != null) {
+ writer.append(str).append("\n");
+ }
}
}
diff --git a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java
index 38526a8b..cd94f2ae 100644
--- a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java
+++ b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java
@@ -19,12 +19,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.assertj.core.api.Java6Assertions.assertThat;
-import org.junit.After;
-import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
/**
@@ -33,25 +29,6 @@
*/
public class UnifiedDiffReaderTest {
- public UnifiedDiffReaderTest() {
- }
-
- @BeforeClass
- public static void setUpClass() {
- }
-
- @AfterClass
- public static void tearDownClass() {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
@Test
public void testSimpleParse() throws IOException {
UnifiedDiff diff = UnifiedDiffReader.parseUnifiedDiff(UnifiedDiffReaderTest.class.getResourceAsStream("jsqlparser_patch_1.diff"));
diff --git a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java
index 7b8e1576..782b35d7 100644
--- a/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java
+++ b/src/test/java/com/github/difflib/unifieddiff/UnifiedDiffWriterTest.java
@@ -15,10 +15,14 @@
*/
package com.github.difflib.unifieddiff;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import org.junit.Test;
/**
@@ -30,25 +34,19 @@ public class UnifiedDiffWriterTest {
public UnifiedDiffWriterTest() {
}
- @BeforeClass
- public static void setUpClass() {
- }
-
- @AfterClass
- public static void tearDownClass() {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
@Test
- public void testWrite() {
+ public void testWrite() throws URISyntaxException, IOException {
+ String str = readFile(UnifiedDiffReaderTest.class.getResource("jsqlparser_patch_1.diff").toURI(), Charset.defaultCharset());
+ UnifiedDiff diff = UnifiedDiffReader.parseUnifiedDiff(new ByteArrayInputStream(str.getBytes()));
+ StringWriter writer = new StringWriter();
+ UnifiedDiffWriter.write(diff, writer);
+ System.out.println(writer.toString());
}
+ static String readFile(URI path, Charset encoding)
+ throws IOException {
+ byte[] encoded = Files.readAllBytes(Paths.get(path));
+ return new String(encoded, encoding);
+ }
}
From 8c6679e2950ffa53ce988e38fa017fa04e2b3451 Mon Sep 17 00:00:00 2001
From: wumpz
Date: Mon, 15 Apr 2019 00:51:14 +0200
Subject: [PATCH 041/262]
---
.../com/github/difflib/unifieddiff/UnifiedDiffWriter.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java
index 6c552bc6..5645e191 100644
--- a/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java
+++ b/src/main/java/com/github/difflib/unifieddiff/UnifiedDiffWriter.java
@@ -40,8 +40,9 @@ public static void write(UnifiedDiff diff, Writer writer) throws IOException {
}
}
-
- writer.write(diff.getTail());
+ if (diff.getTail() != null) {
+ writer.write("--\n" + diff.getTail());
+ }
}
private static void writeOrNothing(Writer writer, String str) throws IOException {
From ecd834f3f53c00f4d55baa75fbada4aa338014db Mon Sep 17 00:00:00 2001
From: wumpz
Date: Tue, 30 Apr 2019 23:55:38 +0200
Subject: [PATCH 042/262]
---
.../java/com/github/difflib/patch/Chunk.java | 10 +-
.../unifieddiff/UnifiedDiffWriter.java | 162 +++++++++++++++++-
.../unifieddiff/UnifiedDiffReaderTest.java | 21 +++
3 files changed, 182 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/github/difflib/patch/Chunk.java b/src/main/java/com/github/difflib/patch/Chunk.java
index 6c1a9918..70b57223 100644
--- a/src/main/java/com/github/difflib/patch/Chunk.java
+++ b/src/main/java/com/github/difflib/patch/Chunk.java
@@ -15,6 +15,7 @@
*/
package com.github.difflib.patch;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@@ -23,9 +24,10 @@
* Holds the information about the part of text involved in the diff process
*
*
- * Text is represented as Object[] because the diff engine is capable of handling more than plain ascci. In
- * fact, arrays or lists of any type that implements {@link java.lang.Object#hashCode hashCode()} and
- * {@link java.lang.Object#equals equals()} correctly can be subject to differencing using this library.
+ * Text is represented as Object[] because the diff engine is capable of handling more
+ * than plain ascci. In fact, arrays or lists of any type that implements
+ * {@link java.lang.Object#hashCode hashCode()} and {@link java.lang.Object#equals equals()}
+ * correctly can be subject to differencing using this library.
*