Skip to content

Commit

Permalink
Merge pull request #105 from VariantSync/as-fixed-history
Browse files Browse the repository at this point in the history
Revised: Fix issues #97, #98, and #102, and improve time-aware patch tracking
  • Loading branch information
pmbittner authored Oct 24, 2023
2 parents 4de2860 + bf57d91 commit aa468f0
Show file tree
Hide file tree
Showing 86 changed files with 6,294 additions and 288 deletions.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pkgs.stdenv.mkDerivation rec {
dontConfigure = true;
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "sha256-qIKFqNwooJ0iqzkv6TTS5GM4bA6iYkVa35zqE+q5izY=";
outputHash = "sha256-Kc8kQiC7qzAk3SFmbuUFzoBqxImkHl7RjXMYMJ6SgCg=";
};

buildPhase = ''
Expand Down
3 changes: 3 additions & 0 deletions local-maven-repo/deploy-functjonal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# A simple script for deploying an update of the functjonal library to the local maven repository
mvn deploy:deploy-file -DgroupId=org.variantsync -DartifactId=functjonal -Dversion=1.0-SNAPSHOT -Durl=file:../local-maven-repo/ -DrepositoryId=local-maven-repo -DupdateReleaseInfo=true -Dfile=../src/main/resources/lib/functjonal-1.0-SNAPSHOT.jar
rm -rf ~/.m2/repository/org/variantsync/functjonal/

This file was deleted.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9c298528d8baeeccd664e5c06f881265
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
98de1b4bfa2aa9f4e9eaa8c547922f41c59e6e4f
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
<metadata modelVersion="1.1.0">
<groupId>org.variantsync</groupId>
<artifactId>functjonal</artifactId>
<version>1.0-SNAPSHOT</version>
<versioning>
<lastUpdated>20230616172827</lastUpdated>
<snapshot>
<timestamp>20230308.125347</timestamp>
<buildNumber>1</buildNumber>
<timestamp>20230616.172827</timestamp>
<buildNumber>4</buildNumber>
</snapshot>
<lastUpdated>20230308125347</lastUpdated>
<snapshotVersions>
<snapshotVersion>
<extension>jar</extension>
<value>1.0-20230308.125347-1</value>
<updated>20230308125347</updated>
<value>1.0-20230616.172827-4</value>
<updated>20230616172827</updated>
</snapshotVersion>
<snapshotVersion>
<extension>pom</extension>
<value>1.0-20230308.125347-1</value>
<updated>20230308125347</updated>
<value>1.0-20230616.172827-4</value>
<updated>20230616172827</updated>
</snapshotVersion>
</snapshotVersions>
</versioning>
<version>1.0-SNAPSHOT</version>
</metadata>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cc732baa0478a9c6f2d21fdeb08f6a82
409dc289b1020047cbbd30802a354ba7
Original file line number Diff line number Diff line change
@@ -1 +1 @@
feb03041c908b3f11611fb2380e6bb9424ff2e63
7e20f40901ae2691c36c164a4306d0c3567d7edc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<versions>
<version>1.0-SNAPSHOT</version>
</versions>
<lastUpdated>20230308125347</lastUpdated>
<lastUpdated>20230616172827</lastUpdated>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a9a0be7eec34faf063b51a34b7fed4a7
a374a3f90764d4507ada7e4ff0d8f0f6
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d53c3d14023e9052bda58ce2fdcc5580efda1a0b
834afd5cf8d0319105bad448138bf311e9734b1e
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@
</descriptorRefs>
</configuration>
</plugin>

<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.9.3</version>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -192,5 +205,11 @@
<artifactId>slf4j-simple</artifactId>
<version>2.0.5</version>
</dependency>

<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
<version>4.12.0</version>
</dependency>
</dependencies>
</project>
20 changes: 20 additions & 0 deletions scripts/generateANTLRClasses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# Call this script from the repository's root directory './scripts/generateANTLRClasses.sh'

# Define the paths and package information
GRAMMAR_DIR="src/main/resources/grammars"
GRAMMAR_FILE="CExpression.g4"
PACKAGE="org.variantsync.diffdetective.feature.antlr"
OUTPUT_DIR="$(pwd)/src/main/java/org/variantsync/diffdetective/feature/antlr"

cd $GRAMMAR_DIR

# Call ANTLR to generate the lexer and parser
antlr4 -o $OUTPUT_DIR -package "$PACKAGE" "$GRAMMAR_FILE"

# Provide feedback to the user
if [ $? -eq 0 ]; then
echo "ANTLR Lexer and Parser generated successfully in '$OUTPUT_DIR/$PACKAGE'."
else
echo "ANTLR generation and compilation failed."
fi
20 changes: 17 additions & 3 deletions src/main/java/org/variantsync/diffdetective/analysis/Analysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
import org.variantsync.diffdetective.diff.git.GitDiffer;
import org.variantsync.diffdetective.diff.git.PatchDiff;
import org.variantsync.diffdetective.diff.result.CommitDiffResult;
import org.variantsync.diffdetective.diff.result.DiffError;
import org.variantsync.diffdetective.metadata.Metadata;
import org.variantsync.diffdetective.parallel.ScheduledTasksIterator;
import org.variantsync.diffdetective.util.Assert;
import org.variantsync.diffdetective.util.Clock;
import org.variantsync.diffdetective.util.Diagnostics;
import org.variantsync.diffdetective.util.InvocationCounter;
import org.variantsync.diffdetective.variation.DiffLinesLabel;
import org.variantsync.diffdetective.variation.diff.Time;
import org.variantsync.diffdetective.variation.diff.VariationDiff;
import org.variantsync.functjonal.iteration.ClusteredIterator;
import org.variantsync.functjonal.iteration.MappedIterator;
Expand Down Expand Up @@ -204,11 +206,16 @@ default void initializeResults(Analysis analysis) {}
default void beginBatch(Analysis analysis) throws Exception {}
default boolean beginCommit(Analysis analysis) throws Exception { return true; }
/**
* Signals a parsing failure of some patch in the current commit.
* Signals a parsing failure of all patches in the current commit.
* Called at most once during the commit phase. If this hook is called {@link
* onParsedCommit} and the following patch phase invocations are skipped.
*/
default void onFailedCommit(Analysis analysis) throws Exception {}
/**
* Signals a parsing failure of some patch in the current commit.
* Called at most once during the commit phase.
*/
default void onFailedParse(Analysis analysis) throws Exception {}
/**
* Signals the completion of the commit diff extraction.
* Called exactly once during the commit phase before the patch phase begins.
Expand Down Expand Up @@ -316,7 +323,8 @@ public static void forSinglePatch(final String commitHash, final String fileName
final Hooks filterPatchHook = new Hooks() {
@Override
public boolean beginPatch(Analysis analysis) {
return fileName.equals(analysis.getCurrentPatch().getFileName());
return fileName.equals(analysis.getCurrentPatch().getFileName(Time.AFTER))
|| fileName.equals(analysis.getCurrentPatch().getFileName(Time.BEFORE));
}
};

Expand Down Expand Up @@ -496,6 +504,12 @@ protected void processCommit() throws Exception {

// report any errors that occurred and exit in case no VariationDiff could be parsed.
getResult().reportDiffErrors(commitDiffResult.errors());
if (!commitDiffResult.errors().isEmpty()) {
StringBuilder sb = new StringBuilder();
commitDiffResult.errors().forEach(e -> sb.append(e).append("\n"));
Logger.debug("found commit for which at least one patch could not be parsed because:\n{}", sb);
runHook(hooks.listIterator(), Hooks::onFailedParse);
}
if (commitDiffResult.diff().isEmpty()) {
Logger.debug("found commit that failed entirely because:\n{}", commitDiffResult.errors());
runHook(hooks.listIterator(), Hooks::onFailedCommit);
Expand All @@ -520,7 +534,7 @@ protected void processCommit() throws Exception {

processPatch();
} catch (Throwable t) {
Logger.error("error during {} {}", currentPatch.getFileName(), currentPatch.getCommitHash());
Logger.error("error during {} {}", currentPatch.getFileName(Time.AFTER), currentPatch.getCommitHash());
throw t;
} finally {
runReverseHook(patchHook, Hooks::endPatch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.variantsync.diffdetective.util.CSV;
import org.variantsync.diffdetective.util.FileUtils;
import org.variantsync.diffdetective.util.StringUtils;
import org.variantsync.diffdetective.variation.diff.Time;

public class EditClassOccurenceAnalysis implements Analysis.Hooks {
public static final String PATCH_STATISTICS_EXTENSION = ".patchStatistics.csv";
Expand Down Expand Up @@ -66,7 +67,7 @@ public boolean analyzeVariationDiff(Analysis analysis) throws IOException {
Stream.concat(
Stream.of(
analysis.getCurrentPatch().getCommitHash(),
analysis.getCurrentPatch().getFileName()
analysis.getCurrentPatch().getFileName(Time.AFTER)
),
editClassCounts.values().stream())
.map(Object::toString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ public void end() {

/**
* Appends the given linegraph string at the end of the given file.
* @param outputPath File to which the linegraph string should be appended.
* @param linegraph String to append to the given file.
*/
private void flush() {
try (var output = IO.newBufferedOutputStream(outputPath, StandardOpenOption.CREATE, StandardOpenOption.APPEND)) {
Expand Down
Loading

0 comments on commit aa468f0

Please sign in to comment.