diff options
author | Jeff Schumacher <jeffschu@google.com> | 2010-07-09 15:11:54 -0700 |
---|---|---|
committer | Jeff Schumacher <jeffschu@google.com> | 2010-07-12 12:52:05 -0700 |
commit | 9a48de86d892a3a1f028f4899f34898e58d759b3 (patch) | |
tree | 680ed79384aadf9137600171b9dd2eed6e2fb395 /org.eclipse.jgit.test/tst/org/eclipse/jgit/diff | |
parent | 4c14b7869d47a28aca29e219a3bae10f43083b33 (diff) | |
download | jgit-9a48de86d892a3a1f028f4899f34898e58d759b3.tar.gz jgit-9a48de86d892a3a1f028f4899f34898e58d759b3.zip |
Added file path similarity to scoring metric in rename detection
The scoring method was not taking into account the similarity of
the file paths and file names. I changed the metric so that it is 99%
based on content (which used to be 100% of the old metric), and 1%
based on path similarity. Of that 1%, half (.5% of the total final
score) is based on the actual file names (e.g. "foo.java"), and half
on the directory (e.g. "src/com/foo/bar/").
Change-Id: I94f0c23bf6413c491b10d5625f6ad7d2ecfb4def
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/diff')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java | 12 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java | 8 |
2 files changed, 10 insertions, 10 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java index c4cb600db0..fe0c565d6d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java @@ -124,8 +124,8 @@ public class RenameDetectorTest extends RepositoryTestCase { } public void testInexactRename_OnePair() throws Exception { - ObjectId aId = blob("foo\nbar\nbaz\n"); - ObjectId bId = blob("foo\nbar\nblah\n"); + ObjectId aId = blob("foo\nbar\nbaz\nblarg\n"); + ObjectId bId = blob("foo\nbar\nbaz\nblah\n"); DiffEntry a = DiffEntry.add(PATH_A, aId); DiffEntry b = DiffEntry.delete(PATH_Q, bId); @@ -135,12 +135,12 @@ public class RenameDetectorTest extends RepositoryTestCase { List<DiffEntry> entries = rd.compute(); assertEquals(1, entries.size()); - assertRename(b, a, 61, entries.get(0)); + assertRename(b, a, 66, entries.get(0)); } public void testInexactRename_OneRenameTwoUnrelatedFiles() throws Exception { - ObjectId aId = blob("foo\nbar\nbaz\n"); - ObjectId bId = blob("foo\nbar\nblah\n"); + ObjectId aId = blob("foo\nbar\nbaz\nblarg\n"); + ObjectId bId = blob("foo\nbar\nbaz\nblah\n"); DiffEntry a = DiffEntry.add(PATH_A, aId); DiffEntry b = DiffEntry.delete(PATH_Q, bId); @@ -158,7 +158,7 @@ public class RenameDetectorTest extends RepositoryTestCase { assertEquals(3, entries.size()); assertSame(c, entries.get(0)); assertSame(d, entries.get(1)); - assertRename(b, a, 61, entries.get(2)); + assertRename(b, a, 66, entries.get(2)); } public void testInexactRename_LastByteDifferent() throws Exception { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java index 9ab745fac9..d6915eb872 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java @@ -78,8 +78,8 @@ public class SimilarityIndexTest extends TestCase { assertEquals(8, src.common(dst)); assertEquals(8, dst.common(src)); - assertEquals(100, src.score(dst)); - assertEquals(100, dst.score(src)); + assertEquals(100, src.score(dst, 100)); + assertEquals(100, dst.score(src, 100)); } public void testCommonScore_EmptyFiles() { @@ -102,8 +102,8 @@ public class SimilarityIndexTest extends TestCase { assertEquals(6, src.common(dst)); assertEquals(6, dst.common(src)); - assertEquals(75, src.score(dst)); - assertEquals(75, dst.score(src)); + assertEquals(75, src.score(dst, 100)); + assertEquals(75, dst.score(src, 100)); } private static SimilarityIndex hash(String text) { |