Skip to content

Commit 8c575b6

Browse files
committed
long running test succeeds using HistogramDiff from jgit
1 parent 295f37e commit 8c575b6

File tree

3 files changed

+208
-165
lines changed

3 files changed

+208
-165
lines changed

pom.xml

Lines changed: 187 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,200 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
<groupId>com.github.java-diff-utils</groupId>
5-
<artifactId>diffutils</artifactId>
6-
<packaging>jar</packaging>
7-
<version>1.4.0-SNAPSHOT</version>
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.github.java-diff-utils</groupId>
5+
<artifactId>diffutils</artifactId>
6+
<packaging>jar</packaging>
7+
<version>1.4.0-SNAPSHOT</version>
88

9-
<name>java-diff-utils</name>
10-
<description>The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.</description>
11-
<url>https://github.com/wumpz/java-diff-utils</url>
12-
<inceptionYear>2009</inceptionYear>
13-
<parent>
14-
<groupId>org.sonatype.oss</groupId>
15-
<artifactId>oss-parent</artifactId>
16-
<version>9</version>
17-
</parent>
18-
<scm>
19-
<connection>scm:git:https://github.com/wumpz/java-diff-utils.git</connection>
20-
<developerConnection>scm:git:ssh://git@github.com:wumpz/java-diff-utils.git</developerConnection>
21-
<url>https://github.com/wumpz/java-diff-utils.git</url>
22-
</scm>
9+
<name>java-diff-utils</name>
10+
<description>The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java.</description>
11+
<url>https://github.com/wumpz/java-diff-utils</url>
12+
<inceptionYear>2009</inceptionYear>
13+
<parent>
14+
<groupId>org.sonatype.oss</groupId>
15+
<artifactId>oss-parent</artifactId>
16+
<version>9</version>
17+
</parent>
18+
<scm>
19+
<connection>scm:git:https://github.com/wumpz/java-diff-utils.git</connection>
20+
<developerConnection>scm:git:ssh://git@github.com:wumpz/java-diff-utils.git</developerConnection>
21+
<url>https://github.com/wumpz/java-diff-utils.git</url>
22+
</scm>
2323

24-
<issueManagement>
25-
<system>GitHub Issues</system>
26-
<url>https://github.com/wumpz/java-diff-utils/issues</url>
27-
</issueManagement>
24+
<issueManagement>
25+
<system>GitHub Issues</system>
26+
<url>https://github.com/wumpz/java-diff-utils/issues</url>
27+
</issueManagement>
2828

29-
<organization>
30-
<name>java-diff-utils</name>
31-
</organization>
29+
<organization>
30+
<name>java-diff-utils</name>
31+
</organization>
3232

33-
<developers>
34-
<developer>
35-
<name>Tobias Warneke</name>
36-
<email>t.warneke@gmx.net</email>
37-
</developer>
38-
<developer>
39-
<name>Dmitry Naumenko</name>
40-
<email>dm.naumenko@gmail.com</email>
41-
</developer>
42-
<developer>
43-
<name>Juanco Anez</name>
44-
<email>juanco@suigeneris.org</email>
45-
</developer>
46-
</developers>
33+
<developers>
34+
<developer>
35+
<name>Tobias Warneke</name>
36+
<email>t.warneke@gmx.net</email>
37+
</developer>
38+
<developer>
39+
<name>Dmitry Naumenko</name>
40+
<email>dm.naumenko@gmail.com</email>
41+
</developer>
42+
<developer>
43+
<name>Juanco Anez</name>
44+
<email>juanco@suigeneris.org</email>
45+
</developer>
46+
</developers>
4747

48-
<licenses>
49-
<license>
50-
<name>The Apache Software License, Version 2.0</name>
51-
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
52-
<distribution>repo</distribution>
53-
<comments>A business-friendly OSS license</comments>
54-
</license>
55-
</licenses>
48+
<licenses>
49+
<license>
50+
<name>The Apache Software License, Version 2.0</name>
51+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
52+
<distribution>repo</distribution>
53+
<comments>A business-friendly OSS license</comments>
54+
</license>
55+
</licenses>
5656

57-
<properties>
58-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
59-
</properties>
57+
<properties>
58+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
59+
</properties>
6060

61-
<dependencies>
62-
<dependency>
63-
<groupId>junit</groupId>
64-
<artifactId>junit</artifactId>
65-
<version>4.12</version>
66-
<type>jar</type>
67-
<scope>test</scope>
68-
</dependency>
69-
<dependency>
70-
<groupId>org.eclipse.jgit</groupId>
71-
<artifactId>org.eclipse.jgit</artifactId>
72-
<version>4.4.1.201607150455-r</version>
73-
</dependency>
74-
</dependencies>
61+
<dependencies>
62+
<dependency>
63+
<groupId>junit</groupId>
64+
<artifactId>junit</artifactId>
65+
<version>4.12</version>
66+
<type>jar</type>
67+
<scope>test</scope>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.eclipse.jgit</groupId>
71+
<artifactId>org.eclipse.jgit</artifactId>
72+
<version>4.4.1.201607150455-r</version>
73+
<exclusions>
74+
<exclusion>
75+
<groupId>com.googlecode.javaewah</groupId>
76+
<artifactId>JavaEWAH</artifactId>
77+
</exclusion>
78+
<exclusion>
79+
<groupId>commons-codec</groupId>
80+
<artifactId>commons-codec</artifactId>
81+
</exclusion>
82+
<exclusion>
83+
<groupId>commons-logging</groupId>
84+
<artifactId>commons-logging</artifactId>
85+
</exclusion>
86+
<exclusion>
87+
<groupId>org.apache.httpcomponents</groupId>
88+
<artifactId>httpclient</artifactId>
89+
</exclusion>
90+
<exclusion>
91+
<groupId>com.jcraft</groupId>
92+
<artifactId>jsch</artifactId>
93+
</exclusion>
94+
<exclusion>
95+
<groupId>org.slf4j</groupId>
96+
<artifactId>slf4j-api</artifactId>
97+
</exclusion>
98+
</exclusions>
99+
</dependency>
100+
</dependencies>
75101

76-
<build>
77-
<plugins>
102+
<build>
103+
<plugins>
78104

79-
<plugin>
80-
<groupId>org.apache.maven.plugins</groupId>
81-
<artifactId>maven-compiler-plugin</artifactId>
82-
<version>3.6.1</version>
83-
<configuration>
84-
<source>1.8</source>
85-
<target>1.8</target>
86-
<encoding>UTF-8</encoding>
87-
</configuration>
88-
</plugin>
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-compiler-plugin</artifactId>
108+
<version>3.6.1</version>
109+
<configuration>
110+
<source>1.8</source>
111+
<target>1.8</target>
112+
<encoding>UTF-8</encoding>
113+
</configuration>
114+
</plugin>
89115

90-
<!-- Make this JAR OSGi ready -->
91-
<!-- We want to keep packaging type as jar. Therefore we need to customize the MANIFEST.MF.
92-
See http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
93-
-->
94-
<plugin>
95-
<artifactId>maven-jar-plugin</artifactId>
96-
<version>3.0.2</version>
97-
<configuration>
98-
<archive>
99-
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
100-
</archive>
101-
</configuration>
102-
</plugin>
103-
<plugin>
104-
<groupId>org.apache.felix</groupId>
105-
<artifactId>maven-bundle-plugin</artifactId>
106-
<version>3.3.0</version>
107-
<executions>
108-
<execution>
109-
<id>bundle-manifest</id>
110-
<phase>process-classes</phase>
111-
<goals>
112-
<goal>manifest</goal>
113-
</goals>
114-
</execution>
115-
</executions>
116-
</plugin>
117-
<plugin>
118-
<groupId>org.apache.maven.plugins</groupId>
119-
<artifactId>maven-javadoc-plugin</artifactId>
120-
<version>2.10.4</version>
121-
<configuration>
122-
<additionalparam>${javadoc.opts}</additionalparam>
123-
</configuration>
124-
<executions>
125-
<execution>
126-
<id>attach-javadocs</id>
127-
<goals>
128-
<goal>jar</goal>
129-
</goals>
130-
</execution>
131-
</executions>
132-
</plugin>
133-
<!--
134-
<plugin>
135-
<groupId>org.codehaus.mojo</groupId>
136-
<artifactId>license-maven-plugin</artifactId>
137-
<version>1.12</version>
138-
<configuration>
139-
<verbose>false</verbose>
140-
<addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
141-
<canUpdateDescription>false</canUpdateDescription>
142-
</configuration>
143-
<executions>
144-
<execution>
145-
<id>first</id>
146-
<goals>
147-
<goal>update-file-header</goal>
148-
</goals>
149-
<phase>process-sources</phase>
150-
<configuration>
151-
<licenseName>apache_v2</licenseName>
152-
<roots>
153-
<root>src/main/java</root>
154-
</roots>
155-
</configuration>
156-
</execution>
157-
</executions>
158-
</plugin>
159-
-->
160-
</plugins>
161-
</build>
162-
<profiles>
163-
<profile>
164-
<id>doclint-java8-disable</id>
165-
<activation>
166-
<jdk>[1.8,)</jdk>
167-
</activation>
168-
<properties>
169-
<javadoc.opts>-Xdoclint:none</javadoc.opts>
170-
</properties>
171-
</profile>
172-
</profiles>
116+
<!-- Make this JAR OSGi ready -->
117+
<!-- We want to keep packaging type as jar. Therefore we need to customize the MANIFEST.MF.
118+
See http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
119+
-->
120+
<plugin>
121+
<artifactId>maven-jar-plugin</artifactId>
122+
<version>3.0.2</version>
123+
<configuration>
124+
<archive>
125+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
126+
</archive>
127+
</configuration>
128+
</plugin>
129+
<plugin>
130+
<groupId>org.apache.felix</groupId>
131+
<artifactId>maven-bundle-plugin</artifactId>
132+
<version>3.3.0</version>
133+
<executions>
134+
<execution>
135+
<id>bundle-manifest</id>
136+
<phase>process-classes</phase>
137+
<goals>
138+
<goal>manifest</goal>
139+
</goals>
140+
</execution>
141+
</executions>
142+
</plugin>
143+
<plugin>
144+
<groupId>org.apache.maven.plugins</groupId>
145+
<artifactId>maven-javadoc-plugin</artifactId>
146+
<version>2.10.4</version>
147+
<configuration>
148+
<additionalparam>${javadoc.opts}</additionalparam>
149+
</configuration>
150+
<executions>
151+
<execution>
152+
<id>attach-javadocs</id>
153+
<goals>
154+
<goal>jar</goal>
155+
</goals>
156+
</execution>
157+
</executions>
158+
</plugin>
159+
<!--
160+
<plugin>
161+
<groupId>org.codehaus.mojo</groupId>
162+
<artifactId>license-maven-plugin</artifactId>
163+
<version>1.12</version>
164+
<configuration>
165+
<verbose>false</verbose>
166+
<addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
167+
<canUpdateDescription>false</canUpdateDescription>
168+
</configuration>
169+
<executions>
170+
<execution>
171+
<id>first</id>
172+
<goals>
173+
<goal>update-file-header</goal>
174+
</goals>
175+
<phase>process-sources</phase>
176+
<configuration>
177+
<licenseName>apache_v2</licenseName>
178+
<roots>
179+
<root>src/main/java</root>
180+
</roots>
181+
</configuration>
182+
</execution>
183+
</executions>
184+
</plugin>
185+
-->
186+
</plugins>
187+
</build>
188+
<profiles>
189+
<profile>
190+
<id>doclint-java8-disable</id>
191+
<activation>
192+
<jdk>[1.8,)</jdk>
193+
</activation>
194+
<properties>
195+
<javadoc.opts>-Xdoclint:none</javadoc.opts>
196+
</properties>
197+
</profile>
198+
</profiles>
173199
</project>
174200

src/main/java/difflib/algorithm/jgit/JGitDiff.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
import org.eclipse.jgit.diff.SequenceComparator;
3131

3232
/**
33-
*
33+
* HistorgramDiff using JGit - Library. This one is much more performant than the
34+
* orginal Myers implementation.
35+
*
3436
* @author toben
3537
*/
3638
public class JGitDiff<T> implements DiffAlgorithm<T> {
@@ -41,8 +43,6 @@ public Patch diff(List<T> original, List<T> revised) throws DiffException {
4143
diffList.addAll(new HistogramDiff().diff(new DataListComparator<>(), new DataList<>(original), new DataList<>(revised)));
4244
Patch<T> patch = new Patch<>();
4345
for (Edit edit : diffList) {
44-
System.out.println(edit);
45-
4646
Chunk<T> orgChunk = new Chunk<>(edit.getBeginA(), original.subList(edit.getBeginA(), edit.getEndA()));
4747
Chunk<T> revChunk = new Chunk<>(edit.getBeginA(), revised.subList(edit.getBeginB(), edit.getEndB()));
4848
switch (edit.getType()) {

0 commit comments

Comments
 (0)