Index: src/org/tigris/subversion/subclipse/core/client/OperationManager.java
===================================================================
--- src/org/tigris/subversion/subclipse/core/client/OperationManager.java (revision 2827)
+++ src/org/tigris/subversion/subclipse/core/client/OperationManager.java (working copy)
@@ -18,7 +18,6 @@
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -29,6 +28,7 @@
import org.tigris.subversion.subclipse.core.Policy;
import org.tigris.subversion.subclipse.core.SVNException;
import org.tigris.subversion.subclipse.core.SVNProviderPlugin;
+import org.tigris.subversion.subclipse.core.resources.SVNWorkspaceRoot;
import org.tigris.subversion.subclipse.core.util.ReentrantLock;
import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
import org.tigris.subversion.svnclientadapter.ISVNNotifyListener;
@@ -130,22 +130,19 @@
}
public void onNotify(File path, SVNNodeKind kind) {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IWorkspaceRoot workspaceRoot = workspace.getRoot();
-
IPath pathEclipse = new Path(path.getAbsolutePath());
if (kind == SVNNodeKind.UNKNOWN) { // delete, revert
IPath pathEntries = pathEclipse.removeLastSegments(1).append(
SVNProviderPlugin.getPlugin().getAdminDirectoryName());
- IResource entries = workspaceRoot.getContainerForLocation(pathEntries);
+ IResource entries = SVNWorkspaceRoot.getResourceFor(pathEntries);
if (entries != null) //probably the pathEclipse was project itself
{
changedResources.add(entries);
}
if (path.isDirectory()) {
- IResource resource = workspaceRoot.getContainerForLocation(pathEclipse);
+ IResource resource = SVNWorkspaceRoot.getResourceFor(pathEclipse);
if (resource != null && resource.getType() != IResource.ROOT) {
IResource svnDir = ((IContainer) resource).getFolder(new Path(
SVNProviderPlugin.getPlugin().getAdminDirectoryName()));
@@ -161,7 +158,7 @@
// when the resource is a directory, two .svn directories can
// potentially
// be modified
- resource = workspaceRoot.getContainerForLocation(pathEclipse);
+ resource = SVNWorkspaceRoot.getResourceFor(pathEclipse);
if (resource != null && resource.getType() != IResource.ROOT) {
if (resource.getProject() != resource) {
// if resource is a project. We can't refresh ../.svn
@@ -174,7 +171,7 @@
changedResources.add(svnDir);
}
} else if (kind == SVNNodeKind.FILE) {
- resource = workspaceRoot.getFileForLocation(pathEclipse);
+ resource = SVNWorkspaceRoot.getResourceFor(pathEclipse);
if (resource != null) {
svnDir = resource.getParent().getFolder(
Index: src/org/tigris/subversion/subclipse/core/resources/SVNWorkspaceRoot.java
===================================================================
--- src/org/tigris/subversion/subclipse/core/resources/SVNWorkspaceRoot.java (revision 2827)
+++ src/org/tigris/subversion/subclipse/core/resources/SVNWorkspaceRoot.java (working copy)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.tigris.subversion.subclipse.core.resources;
+import java.io.File;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
@@ -199,6 +200,11 @@
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < projects.length; i++) {
IProject project = projects[i];
+
+ // Map only to projects, which are managed by subclipse.
+ if (RepositoryProvider.getProvider(project, SVNProviderPlugin.getTypeId()) == null)
+ continue;
+
IPath projectLocation = project.getLocation();
if (projectLocation != null && projectLocation.isPrefixOf(location)) {
int segmentsToRemove = projectLocation.segmentCount();
@@ -447,7 +453,46 @@
return root.getFolder(resourcePath);
}
+
+ /**
+ * Gets the resource to which the path
is corresponding to.
+ * The resource does not need to exists (yet)
+ * @return IResource
+ */
+ public static IResource getResourceFor(IPath path)
+ {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IPath resourcePath = pathForLocation(path.makeAbsolute());
+ if (resourcePath == null)
+ return null;
+
+ int kind = getResourceType(resourcePath);
+
+ if (kind == IResource.FILE)
+ {
+ return root.getFile(resourcePath);
+ }
+ else if(kind == IResource.FOLDER)
+ {
+ return root.getFolder(resourcePath);
+ }
+ else if ((kind == IResource.PROJECT) || (resourcePath.segmentCount() == 1))
+ {
+ return root.getProject(resourcePath.segment(0));
+ }
+ else if ((kind == IResource.ROOT) || (resourcePath.isRoot()))
+ {
+ return root;
+ }
+
+ File file = path.toFile();
+ if (file.isFile())
+ return root.getFile(resourcePath);
+
+ return root.getFolder(resourcePath);
+ }
+
/**
* Gets the resource to which the status
is corresponding to.
* Use either ResourceInfo.getType() or getNodeKind() to determine the proper kind of resource.
Index: src/org/tigris/subversion/subclipse/core/SVNTeamProviderType.java
===================================================================
--- src/org/tigris/subversion/subclipse/core/SVNTeamProviderType.java (revision 2827)
+++ src/org/tigris/subversion/subclipse/core/SVNTeamProviderType.java (working copy)
@@ -273,6 +273,11 @@
if (!isProject)
return; // Nothing more to do, all remaining operations are on projects
+ // Examine whether this project is a nested project. If yes, we don't
+ // share it automatically.
+ if (isNestedProject(project))
+ return;
+
if (isSvnProject) {
// It's a project and has toplevel .svn directory, lets share it!
getAutoShareJob().share(project);
@@ -294,5 +299,22 @@
return SVNWorkspaceSubscriber.getInstance();
}
-
+ private boolean isNestedProject(IProject testProject)
+ {
+ IPath testProjectLocation = testProject.getLocation();
+
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+
+ if (project.equals(testProject))
+ continue;
+
+ IPath projectLocation = project.getLocation();
+ if ((projectLocation != null) && projectLocation.isPrefixOf(testProjectLocation))
+ return true;
+ }
+
+ return false;
+ }
}