Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2005-02-04 12:20:35 -0500
committerMichael Valenta2005-02-04 12:20:35 -0500
commit2379fe026923dc5b48ea5eaa195747a84283ad31 (patch)
treeebd8f5c1140b763a7a6ce6358ec762c61a8384d6
parentd69823bff0bda691a85cf52bee4ec5af044016c6 (diff)
downloadeclipse.platform.team-2379fe026923dc5b48ea5eaa195747a84283ad31.tar.gz
eclipse.platform.team-2379fe026923dc5b48ea5eaa195747a84283ad31.tar.xz
eclipse.platform.team-2379fe026923dc5b48ea5eaa195747a84283ad31.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java87
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java9
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceMappingScope.java8
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SubscriberTraversalContext.java2
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SyncInfoSetTraveralContext.java2
7 files changed, 99 insertions, 17 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java
index 070f6d48b..c241058d3 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberResourceMappingContext.java
@@ -15,6 +15,8 @@ import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.resources.mapping.ResourceTraversal;
import org.eclipse.core.runtime.*;
import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.core.synchronize.SyncInfoFilter;
+import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.internal.core.TeamPlugin;
/**
@@ -25,42 +27,107 @@ import org.eclipse.team.internal.core.TeamPlugin;
public class SubscriberResourceMappingContext extends ResourceMappingContext {
Subscriber subscriber;
+ private final SyncInfoFilter contentDiffFilter;
+
+ /**
+ * Return a resource mapping context suitable for a replace operations.
+ * @return a resource mapping context suitable for a replace operations
+ */
+ public static ResourceMappingContext getReplaceContext(Subscriber subscriber) {
+ return new SubscriberResourceMappingContext(subscriber, new SyncInfoFilter() {
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ if (info != null) {
+ int direction = info.getKind() & SyncInfo.DIRECTION_MASK;
+ // When replacing, both incoming and outgoing changes are needed
+ return direction != 0;
+ }
+ return false;
+ }
+
+ });
+ }
+
+ /**
+ * Return a resource mapping context suitable for a update operations.
+ * That is, operations that fetch the latest remote changes from the
+ * server to update the local workspace resources.
+ * @return a resource mapping context suitable for a update operations
+ */
+ public static ResourceMappingContext getUpdateContext(Subscriber subscriber) {
+ return new SubscriberResourceMappingContext(subscriber, new SyncInfoFilter() {
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ if (info != null) {
+ int direction = info.getKind() & SyncInfo.DIRECTION_MASK;
+ // When updating, only outgoing and conflicting changes are needed
+ return direction == SyncInfo.INCOMING || direction == SyncInfo.CONFLICTING ;
+ }
+ return false;
+ }
+
+ });
+ }
/**
- * Create a resource mappin context for the given subscriber
+ * Create a resource mapping context for the given subscriber
* @param subscriber the subscriber
+ * @param contentDiffFilter filter that is used to determine if the remote contents differ
+ * from the local contents
*/
- public SubscriberResourceMappingContext(Subscriber subscriber) {
+ public SubscriberResourceMappingContext(Subscriber subscriber, SyncInfoFilter contentDiffFilter) {
this.subscriber = subscriber;
+ this.contentDiffFilter = contentDiffFilter;
}
/* (non-Javadoc)
- * @see org.eclipse.core.resources.mapping.ITraversalContext#contentDiffers(org.eclipse.core.resources.IFile, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.core.resources.mapping.ResourceMappingContext#contentDiffers(org.eclipse.core.resources.IFile, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean contentDiffers(IFile file, IProgressMonitor monitor) throws CoreException {
SyncInfo syncInfo = subscriber.getSyncInfo(file);
- return syncInfo != null && syncInfo.getKind() != SyncInfo.IN_SYNC;
+ validateRemote(file, syncInfo);
+ return syncInfo != null && contentDiffFilter.select(syncInfo, monitor);
}
/* (non-Javadoc)
- * @see org.eclipse.core.resources.mapping.ITraversalContext#fetchContents(org.eclipse.core.resources.IFile, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.core.resources.mapping.ResourceMappingContext#fetchContents(org.eclipse.core.resources.IFile, org.eclipse.core.runtime.IProgressMonitor)
*/
public IStorage fetchContents(IFile file, IProgressMonitor monitor) throws CoreException {
SyncInfo syncInfo = subscriber.getSyncInfo(file);
- if (syncInfo == null) {
- throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_NOT_FOUND, "File {0} does not have a corresponding remote" + file.getFullPath().toString(), null));
+ IResourceVariant remote = validateRemote(file, syncInfo);
+ if (remote == null) {
+ return null;
+ }
+ return remote.getStorage(monitor);
+ }
+
+ private IResourceVariant validateRemote(IResource resource, SyncInfo syncInfo) throws CoreException {
+ if (syncInfo == null) return null;
+ IResourceVariant remote = syncInfo.getRemote();
+ if (syncInfo == null) return null;
+ boolean containerExpected = resource.getType() != IResource.FILE;
+ if (remote.isContainer() && !containerExpected) {
+ throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, "Remote conterpart of {0} is a container" + resource.getFullPath().toString(), null));
+ } else if (!remote.isContainer() && containerExpected) {
+ throw new CoreException(new Status(IStatus.ERROR, TeamPlugin.ID, IResourceStatus.RESOURCE_WRONG_TYPE, "Remote conterpart of {0} is not a container" + resource.getFullPath().toString(), null));
}
- return syncInfo.getRemote().getStorage(monitor);
+ return remote;
}
/* (non-Javadoc)
- * @see org.eclipse.core.resources.mapping.ITraversalContext#fetchMembers(org.eclipse.core.resources.IContainer, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.core.resources.mapping.ResourceMappingContext#fetchMembers(org.eclipse.core.resources.IContainer, org.eclipse.core.runtime.IProgressMonitor)
*/
public IResource[] fetchMembers(IContainer container, IProgressMonitor monitor) throws CoreException {
+ SyncInfo syncInfo = subscriber.getSyncInfo(container);
+ if (validateRemote(container, syncInfo) == null) {
+ // There is no remote so return null to indicate this
+ return null;
+ }
return subscriber.members(container);
}
- public void refresh(ResourceTraversal[] traversals, IProgressMonitor monitor) throws CoreException {
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.mapping.ResourceMappingContext#refresh(org.eclipse.core.resources.mapping.ResourceTraversal[], int, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException {
// TODO For now, refresh for each traversal.
for (int i = 0; i < traversals.length; i++) {
ResourceTraversal traversal = traversals[i];
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java
index 9de5fb43e..e60c075c4 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UncommittedChangesDialog.java
@@ -16,11 +16,13 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.subscribers.SubscriberResourceMappingContext;
+import org.eclipse.team.core.synchronize.*;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
@@ -98,7 +100,12 @@ public abstract class UncommittedChangesDialog extends MappingSelectionDialog {
boolean matchesFilter(ResourceMapping mapping) {
try {
- mapping.visit(new SubscriberResourceMappingContext(subscriber), new IResourceVisitor() {
+ mapping.accept(new SubscriberResourceMappingContext(subscriber, new SyncInfoFilter() {
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ return info != null && info.getKind() != SyncInfo.IN_SYNC;
+ }
+
+ }), new IResourceVisitor() {
public boolean visit(IResource resource) throws CoreException {
SyncInfo info = subscriber.getSyncInfo(resource);
if (info != null && resourceFilter.select(info)) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
index df53b8216..27ff87460 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java
@@ -145,7 +145,9 @@ public class UpdateOperation extends SingleCommandOperation {
}
protected ResourceMappingContext getResourceMappingContext() {
- SubscriberResourceMappingContext context = new SubscriberResourceMappingContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber());
- return context;
+ if (Update.IGNORE_LOCAL_CHANGES.isElementOf(getLocalOptions(false))) {
+ return SubscriberResourceMappingContext.getReplaceContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber());
+ }
+ return SubscriberResourceMappingContext.getUpdateContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber());
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java
index 5da73bd22..54520c949 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java
@@ -333,7 +333,7 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
}
private void buildFilteredResourceMap(final ResourceMapping mapping, final ResourceTraversal traversal, IProgressMonitor monitor, final Map result) throws CoreException {
- traversal.visit(new IResourceVisitor() {
+ traversal.accept(new IResourceVisitor() {
public boolean visit(IResource resource) throws CoreException {
if (filter.select(resource, mapping, traversal)) {
// Add the resource to the result
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceMappingScope.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceMappingScope.java
index d303f0bf2..4e4bbb636 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceMappingScope.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/ResourceMappingScope.java
@@ -17,6 +17,8 @@ import org.eclipse.core.resources.mapping.*;
import org.eclipse.core.runtime.*;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.subscribers.SubscriberResourceMappingContext;
+import org.eclipse.team.core.synchronize.SyncInfo;
+import org.eclipse.team.core.synchronize.SyncInfoFilter;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.ui.model.IWorkbenchAdapter;
@@ -101,7 +103,11 @@ public class ResourceMappingScope extends AbstractSynchronizeScope {
}
private ResourceMappingContext getMappingContext() {
- return new SubscriberResourceMappingContext(subscriber);
+ return new SubscriberResourceMappingContext(subscriber, new SyncInfoFilter() {
+ public boolean select(SyncInfo info, IProgressMonitor monitor) {
+ return true;
+ }
+ });
}
private IWorkbenchAdapter getWorkbenchAdapter(Object modelObject) {
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SubscriberTraversalContext.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SubscriberTraversalContext.java
index 34ad11627..483b4cb32 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SubscriberTraversalContext.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SubscriberTraversalContext.java
@@ -56,7 +56,7 @@ public class SubscriberTraversalContext extends ResourceMappingContext {
return subscriber.members(container);
}
- public void refresh(ResourceTraversal[] traversals, IProgressMonitor monitor) throws CoreException {
+ public void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException {
Set result = new HashSet();
for (int i = 0; i < traversals.length; i++) {
ResourceTraversal traversal = traversals[i];
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SyncInfoSetTraveralContext.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SyncInfoSetTraveralContext.java
index 2e2c50c02..e25fd2824 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SyncInfoSetTraveralContext.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SyncInfoSetTraveralContext.java
@@ -69,7 +69,7 @@ public class SyncInfoSetTraveralContext extends ResourceMappingContext {
return (IResource[]) members.toArray(new IResource[members.size()]);
}
- public void refresh(ResourceTraversal[] traversals, IProgressMonitor monitor) throws CoreException {
+ public void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException {
// Do nothing
}

Back to the top