Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDariusz Luksza2010-08-09 16:39:42 -0400
committerChris Aniszczyk2010-08-11 20:45:12 -0400
commita15eaffd115ba8de82c44ffca066375fa149209a (patch)
treea6ab12096d4c0cdcde592e8edf0f9d45815bdfd1 /org.eclipse.egit.core.test
parentb0620c8d074ac5c676172bf2b4de7beeb77bff73 (diff)
downloadegit-a15eaffd115ba8de82c44ffca066375fa149209a.tar.gz
egit-a15eaffd115ba8de82c44ffca066375fa149209a.tar.xz
egit-a15eaffd115ba8de82c44ffca066375fa149209a.zip
Improve GitResourceVariant performance
Recursive TreeWalk's for obtaining objectId were replaced by additional onstructor parameter, this change should improve performance of synchronize action. Change-Id: I6c221ee7a1f754262d008bffe5103d37082773dc Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java52
1 files changed, 29 insertions, 23 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
index 80f0fd1f5..31b6b4a35 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/synchronize/GitResourceVariantComparatorTest.java
@@ -38,6 +38,7 @@ import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.team.core.variants.IResourceVariant;
import org.junit.After;
import org.junit.Before;
@@ -152,7 +153,7 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
String path = Repository.stripWorkDir(repo.getWorkTree(), file);
GitFolderResourceVariant remote = new GitFolderResourceVariant(repo,
- commit, path);
+ commit.getTree(), path);
// then
assertFalse(grvc.compare(local, remote));
@@ -186,8 +187,8 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
expect(local.getFullPath()).andReturn(iPath).anyTimes();
replay(local);
- GitFolderResourceVariant remote = new GitFolderResourceVariant(repo,
- commit, path);
+ GitFolderResourceVariant remote = new GitFolderResourceVariant(repo,
+ commit.getTree(), path);
// then
assertTrue(grvc.compare(local, remote));
@@ -482,9 +483,9 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
String path = Repository.stripWorkDir(repo.getWorkTree(), file);
GitBlobResourceVariant base = new GitBlobResourceVariant(repo,
- baseCommit, path);
+ baseCommit.getTree(), path);
GitBlobResourceVariant remote = new GitBlobResourceVariant(repo,
- remoteCommit, path);
+ remoteCommit.getTree(), path);
// then
assertFalse(grvc.compare(base, remote));
@@ -514,9 +515,9 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
String path = Repository.stripWorkDir(repo.getWorkTree(), file);
GitBlobResourceVariant base = new GitBlobResourceVariant(repo,
- baseCommit, path);
+ baseCommit.getTree(), path);
GitBlobResourceVariant remote = new GitBlobResourceVariant(repo,
- remoteCommit, path);
+ remoteCommit.getTree(), path);
// then
assertFalse(grvc.compare(base, remote));
@@ -545,9 +546,9 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
String folderPath = Repository.stripWorkDir(repo.getWorkTree(),
new File(file.getParent()));
GitBlobResourceVariant base = new GitBlobResourceVariant(repo,
- commit, filePath);
+ commit.getTree(), filePath);
GitFolderResourceVariant remote = new GitFolderResourceVariant(repo,
- commit, folderPath);
+ commit.getTree(), folderPath);
// then
assertFalse(grvc.compare(base, remote));
@@ -577,9 +578,9 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
new File(file.getParent()));
GitFolderResourceVariant base = new GitFolderResourceVariant(repo,
- commit, folderPath);
+ commit.getTree(), folderPath);
GitBlobResourceVariant remote = new GitBlobResourceVariant(repo,
- commit, filePath);
+ commit.getTree(), filePath);
// then
assertFalse(grvc.compare(base, remote));
@@ -610,15 +611,18 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
testRepo.addToIndex(testRepo.getIFile(iProject, file2));
RevCommit commit = testRepo.commit("initial commit");
- String path1 = Repository.stripWorkDir(repo.getWorkTree(), new File(
- file1.getParent()));
- String path2 = Repository.stripWorkDir(repo.getWorkTree(), new File(
- file2.getParent()));
+ TreeWalk tw = new TreeWalk(repo);
+ int nth = tw.addTree(commit.getTree());
+ tw.next();
+ tw.enterSubtree(); // enter project node
+ tw.next();
GitFolderResourceVariant base = new GitFolderResourceVariant(repo,
- commit, path1);
+ tw.getObjectId(nth), tw.getNameString());
+
+ tw.next();
GitFolderResourceVariant remote = new GitFolderResourceVariant(repo,
- commit, path2);
+ tw.getObjectId(nth), tw.getNameString());
// then
assertFalse(grvc.compare(base, remote));
@@ -648,9 +652,9 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
file1.getParent()));
GitFolderResourceVariant base = new GitFolderResourceVariant(repo,
- commit, path1);
+ commit.getTree(), path1);
GitFolderResourceVariant remote = new GitFolderResourceVariant(repo,
- commit, path1);
+ commit.getTree(), path1);
// then
assertTrue(grvc.compare(base, remote));
@@ -678,10 +682,10 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
String path = Repository.stripWorkDir(repo.getWorkTree(), file);
GitBlobResourceVariant base = new GitBlobResourceVariant(repo,
- baseCommit, path);
+ baseCommit.getTree(), path);
GitBlobResourceVariant remote = new GitBlobResourceVariant(repo,
- remoteCommit, path);
+ remoteCommit.getTree(), path);
// then
assertFalse(grvc.compare(base, remote));
@@ -705,9 +709,11 @@ public class GitResourceVariantComparatorTest extends GitTestCase {
"a", "initial commit");
String path = Repository.stripWorkDir(repo.getWorkTree(), file);
- GitBlobResourceVariant base = new GitBlobResourceVariant(repo, commit, path);
+ GitBlobResourceVariant base = new GitBlobResourceVariant(repo,
+ commit.getTree(), path);
- GitBlobResourceVariant remote = new GitBlobResourceVariant(repo, commit, path);
+ GitBlobResourceVariant remote = new GitBlobResourceVariant(repo,
+ commit.getTree(), path);
// then
assertTrue(grvc.compare(base, remote));

Back to the top