Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2015-03-29 21:52:27 +0000
committerAndrey Loskutov2015-03-31 18:27:03 +0000
commit02f9ebaa09f8559bdc6731d975d735d4bbe4c67e (patch)
tree9db9d1d791a6ff7a321167ed56e58d52dc4cd599 /org.eclipse.egit.core.test
parentc03d8cba3d23966e6d87b2c9ead76b24a3b8165b (diff)
downloadegit-02f9ebaa09f8559bdc6731d975d735d4bbe4c67e.tar.gz
egit-02f9ebaa09f8559bdc6731d975d735d4bbe4c67e.tar.xz
egit-02f9ebaa09f8559bdc6731d975d735d4bbe4c67e.zip
Optimizations for GitResourceDeltaVisitor visit()
Follow up discussion on the bug 463296: * don't look into unrelated projects * don't look inside linked folders * simplified code a little bit Bug: 463296 Change-Id: If717a5efc8146cfa336c59e4e45298487a5b1524 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java14
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheEntryTest.java15
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java9
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java39
4 files changed, 54 insertions, 23 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java
index b163a05182..389d0476f0 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/GitMoveDeleteHookTest.java
@@ -146,8 +146,9 @@ public class GitMoveDeleteHookTest {
"some text");
testUtils.addFileToProject(project.getProject(), "file2.txt",
"some more text");
+ IFile file = project.getProject().getFile("file.txt");
AddToIndexOperation addToIndexOperation = new AddToIndexOperation(
- new IResource[] { project.getProject().getFile("file.txt"),
+ new IResource[] { file,
project.getProject().getFile("file2.txt") });
addToIndexOperation.execute(null);
@@ -158,9 +159,12 @@ public class GitMoveDeleteHookTest {
assertNotNull(dirCache.getEntry("file.txt"));
assertNotNull(dirCache.getEntry("file2.txt"));
// Modify the content before the move
- testUtils.changeContentOfFile(project.getProject(), project
- .getProject().getFile("file.txt"), "other text");
- project.getProject().getFile("file.txt").delete(true, null);
+ testUtils.changeContentOfFile(project.getProject(), file, "other text");
+ testUtils.waitForJobs(10000, 1000, JobFamilies.INDEX_DIFF_CACHE_UPDATE);
+
+ file.delete(true, null);
+
+ testUtils.waitForJobs(10000, 1000, JobFamilies.INDEX_DIFF_CACHE_UPDATE);
// Check index for the deleted file
dirCache.read();
@@ -168,7 +172,7 @@ public class GitMoveDeleteHookTest {
assertNull(dirCache.getEntry("file.txt"));
assertNotNull(dirCache.getEntry("file2.txt"));
// Actual file is deleted
- assertFalse(project.getProject().getFile("file.txt").exists());
+ assertFalse(file.exists());
// But a non-affected file remains
assertTrue(project.getProject().getFile("file2.txt").exists());
}
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheEntryTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheEntryTest.java
index 650abf5d0e..0bc4156052 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheEntryTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheEntryTest.java
@@ -20,8 +20,6 @@ import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.JobFamilies;
import org.eclipse.egit.core.test.GitTestCase;
@@ -177,18 +175,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase {
*/
private void waitForJobs(long maxWaitTime, Object family)
throws InterruptedException {
- Thread.sleep(50);
- long start = System.currentTimeMillis();
- IJobManager jobManager = Job.getJobManager();
-
- Job[] jobs = jobManager.find(family);
- while (jobs.length > 0) {
- Thread.sleep(100);
- jobs = jobManager.find(family);
- if (System.currentTimeMillis() - start > maxWaitTime) {
- return;
- }
- }
+ testUtils.waitForJobs(maxWaitTime, family);
}
private void cleanEntryFlags() {
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java
index 24e2eccd8b..aa713e2131 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java
@@ -130,16 +130,17 @@ public class LinkedResourcesTest {
.getLocation(), 0, null);
// Make sure linked folder is refreshed
folder.refreshLocal(IResource.DEPTH_INFINITE, null);
+ project2.getFile("project2folder1/project2folder1file1.txt")
+ .touch(null);
// Links are written to the .project file
resourceDeltaTestHelper1
.assertChangedResources(new String[] { "/project1/.project" });
+
+
// Changes to linked resources are reported against their repository
resourceDeltaTestHelper2.assertChangedResources(new String[] {
- "/project1/link2project2/project2folder1",
- "/project1/link2project2/.project",
- "/project1/link2project2/project2folder1/project2folder1file1.txt",
- "/project1/link2project2" });
+ "/project2/project2folder1/project2folder1file1.txt" });
}
@Test
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java
index c3c19cb5b6..22272de74d 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java
@@ -33,6 +33,8 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.treewalk.TreeWalk;
@@ -300,6 +302,43 @@ public class TestUtils {
}
}
+ /**
+ * Waits at least 50 milliseconds until no jobs of given family are running
+ *
+ * @param maxWaitTime
+ * @param family
+ * @throws InterruptedException
+ */
+ public void waitForJobs(long maxWaitTime, Object family)
+ throws InterruptedException {
+ waitForJobs(maxWaitTime, 50, family);
+ }
+
+ /**
+ * Waits at least <code>minWaitTime</code> milliseconds until no jobs of
+ * given family are running
+ *
+ * @param maxWaitTime
+ * @param minWaitTime
+ * @param family
+ * @throws InterruptedException
+ */
+ public void waitForJobs(long maxWaitTime, long minWaitTime, Object family)
+ throws InterruptedException {
+ Thread.sleep(minWaitTime);
+ long start = System.currentTimeMillis();
+ IJobManager jobManager = Job.getJobManager();
+
+ Job[] jobs = jobManager.find(family);
+ while (jobs.length > 0) {
+ Thread.sleep(100);
+ jobs = jobManager.find(family);
+ if (System.currentTimeMillis() - start > maxWaitTime) {
+ return;
+ }
+ }
+ }
+
private static HashMap<String, String> mkmap(String... args) {
if ((args.length % 2) > 0)
throw new IllegalArgumentException("needs to be pairs");

Back to the top