diff options
author | Thomas Wolf | 2016-03-22 19:24:02 +0000 |
---|---|---|
committer | Matthias Sohn | 2016-05-09 22:48:47 +0000 |
commit | a27199f6dabc2951f2b27300d075b780ef75f884 (patch) | |
tree | 5496e020a510301986c50bc48d0bab0bf0d9be94 /org.eclipse.egit.core.test/src | |
parent | 9a819d041d1253ed286653bbe9cb8b6c31835807 (diff) | |
download | egit-a27199f6dabc2951f2b27300d075b780ef75f884.tar.gz egit-a27199f6dabc2951f2b27300d075b780ef75f884.tar.xz egit-a27199f6dabc2951f2b27300d075b780ef75f884.zip |
Handle linked resources in the same repository
This already worked kind of if both the link source and the link target
were in EGit-managed projects. It didn't work if the link target was in
the same repository, but not in a project.
* ResourceUtil.getRepository(IPath): don't even try the
RepositoryMapping. If one only needs the repository, going through the
RepositoryCache is sufficient, and assuming there are less
repositories than projects and RepositoryMappings, which in my
experience is usually the case, also faster.
* Add a new operation to ResourceUtil to get the repository-relative
path.
* Make GitResourceDeltaVisitor handle linked resources.
Bug: 489657
Change-Id: I7006339d9fc380988305c7530a4cdb71e0aff0f3
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-rw-r--r-- | org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/LinkedResourcesTest.java | 41 |
1 files changed, 39 insertions, 2 deletions
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 670057ed8a..11451f6497 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 @@ -16,6 +16,9 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.File; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.Arrays; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -24,6 +27,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; import org.eclipse.egit.core.Activator; import org.eclipse.egit.core.GitProvider; import org.eclipse.egit.core.IteratorService; @@ -43,6 +47,10 @@ public class LinkedResourcesTest { File project2Dir; + File otherFolder; + + File rootFile; + TestRepository repository1; TestRepository repository2; @@ -63,14 +71,27 @@ public class LinkedResourcesTest { public void setUp() throws Exception { testUtils = new TestUtils(); // Create first repo and project - project1 = testUtils.createProjectInLocalFileSystem(project1Name); + File rootDir = testUtils.createTempDir("FirstRepository"); + project1 = testUtils.createProjectInLocalFileSystem(rootDir, + project1Name); project1Dir = project1.getRawLocation().toFile(); - repository1 = new TestRepository(new File(project1Dir, + otherFolder = new File(rootDir, "other_folder"); + assertTrue(otherFolder.mkdirs()); + File otherFile = new File(otherFolder, "otherFile.txt"); + rootFile = new File(rootDir, "rootFile.txt"); + Files.write(otherFile.toPath(), + Arrays.<String> asList("Hello", "otherFile"), + Charset.defaultCharset()); + Files.write(rootFile.toPath(), Arrays.<String> asList("Hi", "rootFile"), + Charset.defaultCharset()); + repository1 = new TestRepository(new File(rootDir, Constants.DOT_GIT)); testUtils.addFileToProject(project1, "project1folder1/project1folder1file1.txt", "Hello world"); repository1.connect(project1); repository1.trackAllFiles(project1); + repository1.track(otherFile); + repository1.track(rootFile); repository1.commit("Initial commit"); // Create 2nd repo and project project2 = testUtils.createProjectInLocalFileSystem(project2Name); @@ -144,6 +165,22 @@ public class LinkedResourcesTest { } @Test + public void testLinkTargetsInSameRepositoryNotIgnoredByGitResourceDeltaVisitor() + throws Exception { + IFile file = project1.getFile("link2rootFile"); + file.createLink(Path.fromOSString(rootFile.getAbsolutePath()), 0, null); + IFolder folder = project1.getFolder("link2otherFolder"); + folder.createLink(Path.fromOSString(otherFolder.getAbsolutePath()), 0, + null); + project1.refreshLocal(IResource.DEPTH_INFINITE, null); + project1.getFile("link2rootFile").touch(null); + project1.getFile("link2otherFolder/otherFile.txt").touch(null); + resourceDeltaTestHelper1.assertChangedResources( + new String[] { "/project1/.project", "/project1/link2rootFile", + "/project1/link2otherFolder/otherFile.txt" }); + } + + @Test public void testLinkedResourcesIgnoredByIteratorService() throws Exception { // Create linked folder in project1 that points to project2 IFolder folder = project1.getFolder("link2project2"); |