summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalgorzata Janczarska2012-03-07 10:04:38 (EST)
committer Malgorzata Janczarska2012-03-07 10:04:38 (EST)
commit9dc5b700ad5d2dc49a8ff00037ec8f5763cdc2b4 (patch)
tree425774ada912159bd9a6d8718bbc489aea748cfc
parent37e006cad45d19a55c35dcb0e0123333f8cacb6f (diff)
downloadeclipse.platform.team-9dc5b700ad5d2dc49a8ff00037ec8f5763cdc2b4.zip
eclipse.platform.team-9dc5b700ad5d2dc49a8ff00037ec8f5763cdc2b4.tar.gz
eclipse.platform.team-9dc5b700ad5d2dc49a8ff00037ec8f5763cdc2b4.tar.bz2
Branches from other libs are displayed when checking out from Orbitrefs/changes/75/5175/9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java70
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java105
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java22
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java15
4 files changed, 184 insertions, 28 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java
index 2a082ab..900c939 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,12 +11,9 @@
package org.eclipse.team.internal.ccvs.ui.model;
import java.lang.reflect.InvocationTargetException;
-import com.ibm.icu.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import com.ibm.icu.util.TimeZone;
+import java.util.*;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osgi.util.NLS;
@@ -27,9 +24,13 @@ import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.operations.FetchMembersOperation;
import org.eclipse.team.internal.ccvs.ui.operations.FetchMembersOperation.RemoteFolderFilter;
+import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot;
import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
import org.eclipse.ui.progress.IElementCollector;
+import com.ibm.icu.text.SimpleDateFormat;
+import com.ibm.icu.util.TimeZone;
+
public class CVSTagElement extends CVSModelElement implements IDeferredWorkbenchAdapter {
CVSTag tag;
ICVSRepositoryLocation root;
@@ -114,13 +115,66 @@ public class CVSTagElement extends CVSModelElement implements IDeferredWorkbench
return ((CVSTagElement) o).root;
}
- protected Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException {
+ protected Object[] fetchChildren(Object o, IProgressMonitor monitor)
+ throws TeamException {
+ if (tag.getType() == CVSTag.BRANCH) {
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(NLS.bind(
+ CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren,
+ new String[] { root.toString() }), 100);
+ try {
+ ICVSRemoteResource[] children = CVSUIPlugin
+ .getPlugin()
+ .getRepositoryManager()
+ .getFoldersForTag(root, tag,
+ Policy.subMonitorFor(monitor, 50));
+ if (getWorkingSet() != null)
+ children = CVSUIPlugin.getPlugin().getRepositoryManager()
+ .filterResources(getWorkingSet(), children);
+ return getTopLevelRemoteFolders(children,
+ Policy.subMonitorFor(monitor, 50));
+ } finally {
+ monitor.done();
+ }
+ }
ICVSRemoteResource[] children = CVSUIPlugin.getPlugin().getRepositoryManager().getFoldersForTag(root, tag, monitor);
if (getWorkingSet() != null)
children = CVSUIPlugin.getPlugin().getRepositoryManager().filterResources(getWorkingSet(), children);
return children;
}
-
+
+ private ICVSRemoteResource[] getTopLevelRemoteFolders(
+ ICVSRemoteResource[] children, IProgressMonitor monitor)
+ throws CVSException {
+ Set result = new HashSet();
+ monitor.beginTask(NLS.bind(
+ CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren,
+ new String[] { root.toString() }), children.length);
+ try {
+ RepositoryRoot repositoryRoot = CVSUIPlugin.getPlugin()
+ .getRepositoryManager().getRepositoryRootFor(root);
+ for (int i = 0; i < children.length; i++) {
+ result.add(getTopLevelRemoteFolder(children[i], repositoryRoot,
+ Policy.subMonitorFor(monitor, 1)));
+ }
+ return (ICVSRemoteResource[]) result
+ .toArray(new ICVSRemoteResource[result.size()]);
+ } finally {
+ monitor.done();
+ }
+ }
+
+ private ICVSRemoteResource getTopLevelRemoteFolder(
+ ICVSRemoteResource remoteResource, RepositoryRoot repositoryRoot,
+ IProgressMonitor monitor) throws CVSException {
+ IPath repositoryPath = new Path(
+ remoteResource.getRepositoryRelativePath());
+ if (repositoryPath.segmentCount() == 1)
+ return remoteResource;
+ return repositoryRoot.getRemoteFolder(repositoryPath.segment(0), tag,
+ monitor);
+ }
+
public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor) {
if (tag.getType() == CVSTag.HEAD || tag.getType() == CVSTag.DATE) {
try {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java
index 65c4e78..e5c7946 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,7 +11,11 @@
package org.eclipse.team.internal.ccvs.ui.model;
import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+import java.util.Set;
+
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.osgi.util.NLS;
@@ -20,6 +24,7 @@ import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.operations.FetchMembersOperation;
+import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
@@ -57,7 +62,30 @@ public class RemoteFolderElement extends RemoteResourceElement implements IDefer
public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException {
if (!(o instanceof ICVSRemoteFolder))
return new Object[0];
- return ((ICVSRemoteFolder) o).members(monitor);
+ ICVSRemoteFolder remoteFolder = (ICVSRemoteFolder) o;
+ if (remoteFolder.getTag() != null
+ && remoteFolder.getTag().getType() == CVSTag.BRANCH) {
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(NLS.bind(
+ CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren,
+ new String[] { getLabel(remoteFolder) }), 100);
+ try {
+ ICVSRemoteResource[] cachedFolders = CVSUIPlugin
+ .getPlugin()
+ .getRepositoryManager()
+ .getFoldersForTag(remoteFolder.getRepository(),
+ remoteFolder.getTag(),
+ Policy.subMonitorFor(monitor, 50));
+ if (!hasCachedParent(cachedFolders, remoteFolder)) {
+ return getCachedChildren(cachedFolders, remoteFolder,
+ Policy.subMonitorFor(monitor, 50));
+ }
+ return remoteFolder.members(Policy.subMonitorFor(monitor, 50));
+ } finally {
+ monitor.done();
+ }
+ }
+ return remoteFolder.members(monitor);
}
public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor) {
@@ -67,18 +95,89 @@ public class RemoteFolderElement extends RemoteResourceElement implements IDefer
}
try {
monitor = Policy.monitorFor(monitor);
- monitor.beginTask(NLS.bind(CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, new String[] { getLabel(o) }), 100);
+ ICVSRemoteFolder remoteFolder = (ICVSRemoteFolder) o;
+ if (remoteFolder.getTag() != null
+ && remoteFolder.getTag().getType() == CVSTag.BRANCH) {
+ monitor.beginTask(
+ NLS.bind(
+ CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren,
+ new String[] { getLabel(o) }), 200);
+ ICVSRemoteResource[] cachedFolders = CVSUIPlugin
+ .getPlugin()
+ .getRepositoryManager()
+ .getFoldersForTag(remoteFolder.getRepository(),
+ remoteFolder.getTag(),
+ Policy.subMonitorFor(monitor, 100));
+ if (!hasCachedParent(cachedFolders, remoteFolder)) {
+ collector.add(
+ getCachedChildren(cachedFolders, remoteFolder,
+ Policy.subMonitorFor(monitor, 90)), Policy
+ .subMonitorFor(monitor, 10));
+ return;
+ }
+ } else {
+ monitor.beginTask(
+ NLS.bind(
+ CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren,
+ new String[] { getLabel(o) }), 100);
+ }
FetchMembersOperation operation = new FetchMembersOperation(null, (ICVSRemoteFolder)o, collector);
operation.run(Policy.subMonitorFor(monitor, 100));
} catch (InvocationTargetException e) {
handle(collector, e);
} catch (InterruptedException e) {
// Cancelled by the user;
+ } catch (CVSException e) {
+ handle(collector, e);
} finally {
monitor.done();
}
}
+ private boolean hasCachedParent(ICVSRemoteResource[] cachedFolders,
+ ICVSRemoteFolder remoteFolder) {
+ for (int i = 0; i < cachedFolders.length; i++) {
+ if (remoteFolder.getRepositoryRelativePath().startsWith(
+ cachedFolders[i].getRepositoryRelativePath())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private ICVSRemoteResource[] getCachedChildren(
+ ICVSRemoteResource[] cachedFolders, ICVSRemoteFolder remoteFolder,
+ IProgressMonitor monitor) {
+ Set remoteResources = new HashSet();
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(NLS.bind(
+ CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren,
+ new String[] { getLabel(remoteFolder) }), cachedFolders.length);
+ try {
+ RepositoryRoot repositoryRoot = CVSUIPlugin.getPlugin()
+ .getRepositoryManager()
+ .getRepositoryRootFor(remoteFolder.getRepository());
+ for (int i = 0; i < cachedFolders.length; i++) {
+ if (cachedFolders[i].getRepositoryRelativePath().startsWith(
+ remoteFolder.getRepositoryRelativePath())) {
+ String path = new Path(
+ cachedFolders[i].getRepositoryRelativePath())
+ .uptoSegment(
+ new Path(remoteFolder
+ .getRepositoryRelativePath())
+ .segmentCount() + 1).toString();
+ remoteResources.add(repositoryRoot.getRemoteFolder(path,
+ remoteFolder.getTag(),
+ Policy.subMonitorFor(monitor, 1)));
+ }
+ }
+ return (ICVSRemoteResource[]) remoteResources
+ .toArray(new ICVSRemoteResource[remoteResources.size()]);
+ } finally {
+ monitor.done();
+ }
+ }
+
public ISchedulingRule getRule(Object element) {
ICVSRepositoryLocation location = getRepositoryLocation(element);
return new RepositoryLocationSchedulingRule(location);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java
index b90cc03..cc414ab 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java
@@ -25,7 +25,6 @@ import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation;
import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation.LogEntryCache;
-import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
public class RepositoryRoot extends PlatformObject {
@@ -444,22 +443,15 @@ public class RepositoryRoot extends PlatformObject {
return (CVSTag[])tagSet.toArray(new CVSTag[0]);
}
- /**
- * Return the cache key (path) for the given folder path. For root projects
- * it returns the folder the project is mapped to as the tag source. For
- * non-root projects it returns only the first segment of the path because
- * for the time being tag lists are kept for the remote ancestors of the
- * resource that is a direct child of the remote root.
- *
- * @see TagSource
- * @see #addTags(String, CVSTag[])
- *
- * @param remotePath
- * the remote folder path
- * @return the cache key (path) for the given folder path
+ /*
+ * Return the cache key (path) for the given folder path.
+ * This has been changed to cache the tags directly
+ * with the folder to better support non-root projects.
+ * However, resources in the local workspace use the folder
+ * the project is mapped to as the tag source (see TagSource)
*/
private String getCachePathFor(String remotePath) {
- return new Path(null, remotePath).segment(0);
+ return remotePath;
}
/**
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
index 64e6e17..3e9528d 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
@@ -82,7 +82,6 @@ public class RepositoriesViewTests extends EclipseTest {
// create project
IProject project = getUniqueTestProject("TestBranchSubmoduleChildrenProject");
- buildResources(project, new String[] { "file1.txt" }, true);
// share project under module
shareProject(getRepository(), project,
moduleName + "/" + project.getName(), DEFAULT_MONITOR);
@@ -128,17 +127,29 @@ public class RepositoriesViewTests extends EclipseTest {
// create project
IProject project = getUniqueTestProject("TestTagSubmoduleChildrenProject");
- buildResources(project, new String[] { "file1.txt" }, true);
// share project under module
shareProject(getRepository(), project,
moduleName + "/" + project.getName(), DEFAULT_MONITOR);
assertValidCheckout(project);
+ // make some changes
+ addResources(project, new String[] { "file1.txt" }, true);
+
// tag project
CVSTag tag = new CVSTag(versionName, CVSTag.VERSION);
tagProject(project, tag, true);
+ // refresh branches for module
+ // TODO Remove when Bug 372862 is committed, adding tag for submodule
+ // should automatically add it to module
+ CVSUIPlugin
+ .getPlugin()
+ .getRepositoryManager()
+ .refreshDefinedTags(
+ getRepository().getRemoteFolder(moduleName, null),
+ true, true, DEFAULT_MONITOR);
+
RemoteContentProvider rcp = new RemoteContentProvider();
Object[] categories = rcp.getChildren(getRepositoryRoot());
assertEquals(4, categories.length);