-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(matching): Early return on matching if nodes have different kinds (…
…#35) This is a bug that was discovered thanks to running the tool in jdime repository. Basically, the matching algorithm was running even if the nodes have different kinds, which was introducing incorrect behavior in the merge step: leading into trying merging two nodes that have different kinds, which is logically inconsistent.
- Loading branch information
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.fosd.jdime.artifact; | ||
|
||
import java.security.MessageDigest; | ||
|
||
public abstract class Artifact<T extends Artifact<T>> implements Comparable<T>, StatisticsInterface { | ||
public boolean hasChanges(Revision revision) { | ||
if (this.revision.equals(revision)) { | ||
return false; | ||
} | ||
|
||
if (!hasMatching(revision)) { | ||
return true; | ||
} | ||
|
||
T match = getMatching(revision).getMatchingArtifact(this); | ||
|
||
return getTreeSize() != match.getTreeSize() || Artifacts.bfsStream(self()).anyMatch(a -> { | ||
return !a.hasMatching(revision) || !a.getMatching(revision).getMatchingArtifact(a).hashId().equals(a.hashId()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package de.fosd.jdime.artifact; | ||
|
||
import java.security.MessageDigest; | ||
|
||
public abstract class Artifact<T extends Artifact<T>> implements Comparable<T>, StatisticsInterface { | ||
public boolean hasChanges(Revision revision) { | ||
|
||
if (this.revision.equals(revision)) { | ||
return false; | ||
} | ||
|
||
if (!hasMatching(revision)) { | ||
return true; | ||
} | ||
|
||
T match = getMatching(revision).getMatchingArtifact(this); | ||
|
||
return getTreeSize() != match.getTreeSize() || Artifacts.bfsStream(self()).anyMatch(a -> { | ||
return !a.hasMatching(revision) || !a.getMatching(revision).getMatchingArtifact(a).hashId().equals(a.hashId()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package de . fosd . jdime . artifact ; import java . security . MessageDigest ; public abstract class Artifact < T extends Artifact < T > > implements Comparable < T > , StatisticsInterface { public boolean hasChanges ( Revision revision ) { if ( this . revision . equals ( revision ) ) { return false ; } if ( ! hasMatching ( revision ) ) { return true ; } T match = getMatching ( revision ) . getMatchingArtifact ( this ) ; return getTreeSize ( ) != match . getTreeSize ( ) || ! getTreeHash ( ) . equals ( match . getTreeHash ( ) ) ; } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package de.fosd.jdime.artifact; | ||
|
||
import java.security.MessageDigest; | ||
|
||
public abstract class Artifact<T extends Artifact<T>> implements Comparable<T>, StatisticsInterface { | ||
public boolean hasChanges(Revision revision) { | ||
|
||
if (this.revision.equals(revision)) { | ||
return false; | ||
} | ||
|
||
if (!hasMatching(revision)) { | ||
return true; | ||
} | ||
|
||
T match = getMatching(revision).getMatchingArtifact(this); | ||
|
||
return getTreeSize() != match.getTreeSize() || !getTreeHash().equals(match.getTreeHash()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters