Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-09-10 13:53:57 -0400
committerMichael Valenta2003-09-10 13:53:57 -0400
commit3139f347a7006419b4b7d94c2234e71187124879 (patch)
tree5c5e9aa2e9dfd21b2411805ba8107a08befe7c12
parent89e7e21e84a69f35233d9e92f47c4c19f67ef841 (diff)
downloadeclipse.platform.team-3139f347a7006419b4b7d94c2234e71187124879.tar.gz
eclipse.platform.team-3139f347a7006419b4b7d94c2234e71187124879.tar.xz
eclipse.platform.team-3139f347a7006419b4b7d94c2234e71187124879.zip
Generalized RemoteSynchronizersRoot_branch_20030910_RepositoryProviderLocking
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java18
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java17
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java22
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaseSynchronizer.java26
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSRemoteSynchronizer.java (renamed from bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSynchronizer.java)65
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MergedSynchronizer.java31
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/OptimizedRemoteSynchronizer.java10
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteSynchronizer.java162
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java15
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java2
10 files changed, 127 insertions, 241 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
index f3354bd3b..24fa52a51 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
@@ -31,14 +31,14 @@ import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.ContentComparisonCriteria;
import org.eclipse.team.core.subscribers.ITeamResourceChangeListener;
+import org.eclipse.team.core.subscribers.RemoteBytesSynchronizer;
+import org.eclipse.team.core.subscribers.RemoteSynchronizer;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.core.subscribers.TeamDelta;
import org.eclipse.team.core.subscribers.TeamSubscriber;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.internal.ccvs.core.syncinfo.MergedSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.RemoteSynchronizer;
import org.eclipse.team.internal.ccvs.core.syncinfo.RemoteTagSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSynchronizer;
import org.eclipse.team.internal.core.SaveContext;
/**
@@ -63,7 +63,7 @@ public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResour
private CVSTag start, end;
private List roots;
private RemoteTagSynchronizer remoteSynchronizer;
- private RemoteSynchronizer mergedSynchronizer;
+ private RemoteBytesSynchronizer mergedSynchronizer;
private RemoteTagSynchronizer baseSynchronizer;
private static final byte[] NO_REMOTE = new byte[0];
@@ -75,7 +75,7 @@ public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResour
return remoteChanges;
}
- private void adjustMergedResources(IResource[] remoteChanges) throws CVSException {
+ private void adjustMergedResources(IResource[] remoteChanges) throws TeamException {
for (int i = 0; i < remoteChanges.length; i++) {
IResource resource = remoteChanges[i];
mergedSynchronizer.removeSyncBytes(resource, IResource.DEPTH_ZERO, false /* not silent */);
@@ -125,7 +125,7 @@ public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResour
return new CVSMergeSyncInfo(local, base, remote, this, monitor);
}
- public void merged(IResource[] resources) throws CVSException {
+ public void merged(IResource[] resources) throws TeamException {
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
byte[] remoteBytes = remoteSynchronizer.getSyncBytes(resource);
@@ -167,14 +167,14 @@ public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResour
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getRemoteSynchronizer()
*/
- protected ResourceSynchronizer getRemoteSynchronizer() {
+ protected RemoteSynchronizer getRemoteSynchronizer() {
return remoteSynchronizer;
}
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getBaseSynchronizer()
*/
- protected ResourceSynchronizer getBaseSynchronizer() {
+ protected RemoteSynchronizer getBaseSynchronizer() {
return baseSynchronizer;
}
@@ -182,7 +182,7 @@ public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResour
* @see org.eclipse.team.core.sync.TeamSubscriber#isSupervised(org.eclipse.core.resources.IResource)
*/
public boolean isSupervised(IResource resource) throws TeamException {
- return getBaseSynchronizer().getSyncBytes(resource) != null || getRemoteSynchronizer().getSyncBytes(resource) != null;
+ return getBaseSynchronizer().hasRemote(resource) || getRemoteSynchronizer().hasRemote(resource);
}
/* (non-Javadoc)
@@ -301,7 +301,7 @@ public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResour
}
}
- public boolean isMerged(IResource resource) throws CVSException {
+ public boolean isMerged(IResource resource) throws TeamException {
return mergedSynchronizer.getSyncBytes(resource) != null;
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java
index 2d5aba96e..15924780a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncTreeSubscriber.java
@@ -27,13 +27,12 @@ import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.ComparisonCriteria;
import org.eclipse.team.core.subscribers.ContentComparisonCriteria;
+import org.eclipse.team.core.subscribers.RemoteSynchronizer;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.core.subscribers.TeamSubscriber;
import org.eclipse.team.core.subscribers.TeamDelta;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSynchronizer;
-import org.eclipse.team.internal.ccvs.core.Policy;
/**
* This class provides common funtionality for three way sychronizing
@@ -122,7 +121,7 @@ public abstract class CVSSyncTreeSubscriber extends TeamSubscriber {
// TODO: consider that there may be several sync states on this resource. There
// should instead be a method to check for the existance of a set of sync types on
// a resource.
- if(member.isPhantom() && getRemoteSynchronizer().getSyncBytes(member) == null) {
+ if(member.isPhantom() && !getRemoteSynchronizer().hasRemote(member)) {
continue;
}
@@ -159,11 +158,11 @@ public abstract class CVSSyncTreeSubscriber extends TeamSubscriber {
/**
* Return the synchronizer that provides the remote resources
*/
- protected abstract ResourceSynchronizer getRemoteSynchronizer();
+ protected abstract RemoteSynchronizer getRemoteSynchronizer();
/**
* Return the synchronizer that provides the base resources
*/
- protected abstract ResourceSynchronizer getBaseSynchronizer();
+ protected abstract RemoteSynchronizer getBaseSynchronizer();
/* (non-Javadoc)
* @see org.eclipse.team.core.sync.ISyncTreeSubscriber#getSyncInfo(org.eclipse.core.resources.IResource)
@@ -215,7 +214,7 @@ public abstract class CVSSyncTreeSubscriber extends TeamSubscriber {
int baseWork = getCacheFileContentsHint() ? 10 : 30;
int remoteWork = 100;
monitor.beginTask(null, baseWork + remoteWork);
- IResource[] baseChanges = getBaseSynchronizer().refresh(resources, depth, getCacheFileContentsHint(), Policy.subMonitorFor(monitor, baseWork));
+ IResource[] baseChanges = refreshBase(resources, depth, Policy.subMonitorFor(monitor, baseWork));
IResource[] remoteChanges = refreshRemote(resources, depth, Policy.subMonitorFor(monitor, remoteWork));
Set allChanges = new HashSet();
@@ -228,6 +227,10 @@ public abstract class CVSSyncTreeSubscriber extends TeamSubscriber {
}
}
+ protected IResource[] refreshBase(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
+ return getBaseSynchronizer().refresh(resources, depth, getCacheFileContentsHint(), monitor);
+ }
+
protected IResource[] refreshRemote(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
return getRemoteSynchronizer().refresh(resources, depth, getCacheFileContentsHint(), monitor);
}
@@ -271,7 +274,7 @@ public abstract class CVSSyncTreeSubscriber extends TeamSubscriber {
ICVSResource cvsThing = CVSWorkspaceRoot.getCVSResourceFor(resource);
if (cvsThing.isIgnored()) {
// An ignored resource could have an incoming addition (conflict)
- return getRemoteSynchronizer().getSyncBytes(resource) != null;
+ return getRemoteSynchronizer().hasRemote(resource);
}
return true;
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java
index 9a7512b61..cc0a06cdf 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java
@@ -19,14 +19,15 @@ import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.subscribers.RemoteSynchronizer;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.core.subscribers.TeamDelta;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.OptimizedRemoteSynchronizer;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSynchronizer;
/**
* CVSWorkspaceSubscriber
@@ -90,11 +91,11 @@ public class CVSWorkspaceSubscriber extends CVSSyncTreeSubscriber implements IRe
remoteSynchronizer.removeSyncBytes(resource, IResource.DEPTH_ZERO, true /* silent */);
} else if (resource.getType() == IResource.FOLDER) {
// If the base has sync info for the folder, purge the remote bytes
- if (getBaseSynchronizer().getSyncBytes(resource) != null) {
+ if (getBaseSynchronizer().hasRemote(resource)) {
remoteSynchronizer.removeSyncBytes(resource, IResource.DEPTH_ZERO, true /* silent */);
}
}
- } catch (CVSException e) {
+ } catch (TeamException e) {
CVSProviderPlugin.log(e);
}
}
@@ -128,7 +129,7 @@ public class CVSWorkspaceSubscriber extends CVSSyncTreeSubscriber implements IRe
public void projectDeconfigured(IProject project) {
try {
remoteSynchronizer.removeSyncBytes(project, IResource.DEPTH_INFINITE, false /* not silent */);
- } catch (CVSException e) {
+ } catch (TeamException e) {
CVSProviderPlugin.log(e);
}
TeamDelta delta = new TeamDelta(this, TeamDelta.PROVIDER_DECONFIGURED, project);
@@ -138,14 +139,14 @@ public class CVSWorkspaceSubscriber extends CVSSyncTreeSubscriber implements IRe
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getRemoteSynchronizer()
*/
- protected ResourceSynchronizer getRemoteSynchronizer() {
+ protected RemoteSynchronizer getRemoteSynchronizer() {
return remoteSynchronizer;
}
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber#getBaseSynchronizer()
*/
- protected ResourceSynchronizer getBaseSynchronizer() {
+ protected RemoteSynchronizer getBaseSynchronizer() {
return remoteSynchronizer.getBaseSynchronizer();
}
@@ -159,6 +160,10 @@ public class CVSWorkspaceSubscriber extends CVSSyncTreeSubscriber implements IRe
IResource resource = resources[i];
final IProgressMonitor infinite = Policy.infiniteSubMonitorFor(monitor, 100);
try {
+ // We need to do a scheduling rule on the project because
+ // the EclipseSynchronizer currently obtains rules which causes
+ // many workers to be created (see bug 41979).
+ Platform.getJobManager().beginRule(resource);
infinite.beginTask(null, 512);
resource.accept(new IResourceVisitor() {
public boolean visit(IResource innerResource) throws CoreException {
@@ -179,6 +184,7 @@ public class CVSWorkspaceSubscriber extends CVSSyncTreeSubscriber implements IRe
} catch (CoreException e) {
throw CVSException.wrapException(e);
} finally {
+ Platform.getJobManager().endRule();
infinite.done();
}
}
@@ -186,7 +192,7 @@ public class CVSWorkspaceSubscriber extends CVSSyncTreeSubscriber implements IRe
return (SyncInfo[]) result.toArray(new SyncInfo[result.size()]);
}
- /* internal use only */ boolean isOutOfSync(IResource resource, IProgressMonitor monitor) throws CVSException {
+ /* internal use only */ boolean isOutOfSync(IResource resource, IProgressMonitor monitor) throws TeamException {
return (hasIncomingChange(resource) || hasOutgoingChange(CVSWorkspaceRoot.getCVSResourceFor(resource), monitor));
}
@@ -212,7 +218,7 @@ public class CVSWorkspaceSubscriber extends CVSSyncTreeSubscriber implements IRe
return false;
}
- private boolean hasIncomingChange(IResource resource) throws CVSException {
+ private boolean hasIncomingChange(IResource resource) throws TeamException {
return remoteSynchronizer.isRemoteKnown(resource);
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaseSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaseSynchronizer.java
index 51c04bdd1..bb4a3a814 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaseSynchronizer.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/BaseSynchronizer.java
@@ -15,15 +15,18 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.subscribers.RemoteSynchronizer;
+import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
/**
* A base sychronizer provides access to the base sync bytes for the
* resources in the local workspace
*/
-public class BaseSynchronizer extends ResourceSynchronizer {
+public class BaseSynchronizer extends RemoteSynchronizer {
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSynchronizer#getSyncBytes(org.eclipse.core.resources.IResource)
@@ -67,6 +70,25 @@ public class BaseSynchronizer extends ResourceSynchronizer {
throws TeamException {
// TODO Ensure that file contents are cached for modified local files
- return super.refresh(resources, depth, cacheFileContentsHint, monitor);
+ try {
+ monitor.beginTask(null, 100);
+ return new IResource[0];
+ } finally {
+ monitor.done();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSynchronizer#getRemoteResource(org.eclipse.core.resources.IResource)
+ */
+ public IRemoteResource getRemoteResource(IResource resource) throws TeamException {
+ return CVSWorkspaceRoot.getRemoteResourceFor(resource);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.subscribers.RemoteSynchronizer#hasRemote(org.eclipse.core.resources.IResource)
+ */
+ public boolean hasRemote(IResource resource) throws TeamException {
+ return getSyncBytes(resource) != null;
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSRemoteSynchronizer.java
index 2e42a5f71..861fc90fa 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSynchronizer.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/CVSRemoteSynchronizer.java
@@ -10,26 +10,29 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core.syncinfo;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.subscribers.RemoteBytesSynchronizer;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
/**
- * A resource synchronizer is responsible for managing synchronization information for
- * CVS resources.
+ * CVS specific remote synchronizer behavior
*/
-public abstract class ResourceSynchronizer {
-
- protected abstract QualifiedName getSyncName();
+public abstract class CVSRemoteSynchronizer extends RemoteBytesSynchronizer {
+
+ public static final String SYNC_KEY_QUALIFIER = "org.eclipse.team.cvs"; //$NON-NLS-1$
+ public CVSRemoteSynchronizer(String id) {
+ super(new QualifiedName(SYNC_KEY_QUALIFIER, id));
+ }
+
public IRemoteResource getRemoteResource(IResource resource) throws TeamException {
byte[] remoteBytes = getSyncBytes(resource);
if (remoteBytes == null) {
@@ -48,32 +51,42 @@ public abstract class ResourceSynchronizer {
}
return RemoteFile.fromBytes(resource, remoteBytes, parentBytes);
} else {
- return RemoteFolder.fromBytes((IContainer)resource, remoteBytes);
+ return RemoteFolder.fromBytes(resource, remoteBytes);
}
}
}
- public abstract byte[] getSyncBytes(IResource resource) throws CVSException;
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.ccvs.core.syncinfo.RemoteSynchronizer#setSyncBytes(org.eclipse.core.resources.IResource, byte[])
+ */
+ public void setSyncBytes(IResource resource, byte[] bytes) throws TeamException {
+ super.setSyncBytes(resource, bytes);
+ if (getSyncBytes(resource) != null && !parentHasSyncBytes(resource)) {
+ // Log a warning if there is no sync bytes available for the resource's
+ // parent but there is valid sync bytes for the child
+ CVSProviderPlugin.log(new TeamException(Policy.bind("ResourceSynchronizer.missingParentBytesOnSet", getSyncName().toString(), resource.getFullPath().toString()))); //$NON-NLS-1$
+ }
+ }
/**
- * Refreshes the contents of the resource synchronizer and returns the list
- * of resources whose remote sync state changed. The <code>cacheFileContentsHint</code>
- * indicates that the user of this synchronizer will be using the file contents. Subclasses can decide
- * whether to cache file contents during the refresh or to allow them to be fetched when request.
- * @param resources
- * @param depth
- * @param cacheFileContentsHint a hint which indicates whether file contents will be used
- * @param monitor
- * @return
- * @throws TeamException
+ * Indicates whether the parent of the given local resource has sync bytes for its
+ * corresponding remote resource. The parent bytes of a remote resource are required
+ * (by CVS) to create a handle to the remote resource.
*/
- public IResource[] refresh(IResource[] resources, int depth, boolean cacheFileContentsHint, IProgressMonitor monitor) throws TeamException {
- try {
- monitor.beginTask(null, 100);
- return new IResource[0];
- } finally {
- monitor.done();
+ protected boolean parentHasSyncBytes(IResource resource) throws TeamException {
+ if (resource.getType() == IResource.PROJECT) return true;
+ return (getSyncBytes(resource.getParent()) != null);
+ }
+
+ /**
+ * Return the sync bytes associated with the remote resource. A return
+ * value of <code>null</code> indicates that the remote resource does not exist.
+ */
+ protected byte[] getRemoteSyncBytes(IResource local, IRemoteResource remote) throws TeamException {
+ if (remote != null) {
+ return ((RemoteResource)remote).getSyncBytes();
+ } else {
+ return null;
}
}
-
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MergedSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MergedSynchronizer.java
index 950f82915..3ed783c07 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MergedSynchronizer.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/MergedSynchronizer.java
@@ -11,34 +11,39 @@
package org.eclipse.team.internal.ccvs.core.syncinfo;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.subscribers.RemoteBytesSynchronizer;
import org.eclipse.team.core.sync.IRemoteResource;
-import org.eclipse.team.internal.ccvs.core.CVSException;
/**
- * Override RemoteSynchronizer to allow unparented remote resource sync info
- * since the CVSMergeSubscriber only needs to know if the resource sync info
- * of the incoming change differs from the last merge. The parenting is used
- * to create IRemoteResources which this synchronizer is not used to do
+ * This synchronizer keeps track of which resources have been merged.
+ * It is to be used only by the CVSMergeSubscriber.
*/
-public class MergedSynchronizer extends RemoteSynchronizer {
+public class MergedSynchronizer extends RemoteBytesSynchronizer {
public MergedSynchronizer(String id) {
- super(id);
+ super(new QualifiedName(CVSRemoteSynchronizer.SYNC_KEY_QUALIFIER, id));
}
/* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.syncinfo.RemoteSynchronizer#parentHasSyncBytes(org.eclipse.core.resources.IResource)
+ * @see org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSynchronizer#getRemoteResource(org.eclipse.core.resources.IResource)
*/
- protected boolean parentHasSyncBytes(IResource resource) throws CVSException {
- return true;
+ public IRemoteResource getRemoteResource(IResource resource) throws TeamException {
+ throw new UnsupportedOperationException();
}
/* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSynchronizer#getRemoteResource(org.eclipse.core.resources.IResource)
+ * @see org.eclipse.team.core.sync.ResourceSynchronizer#refresh(org.eclipse.core.resources.IResource[], int, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/
- public IRemoteResource getRemoteResource(IResource resource) throws TeamException {
- throw new UnsupportedOperationException();
+ public IResource[] refresh(IResource[] resources, int depth, boolean cacheFileContentsHint, IProgressMonitor monitor) throws TeamException {
+ try {
+ monitor.beginTask(null, 100);
+ return new IResource[0];
+ } finally {
+ monitor.done();
+ }
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/OptimizedRemoteSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/OptimizedRemoteSynchronizer.java
index 954398ffc..e27050a65 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/OptimizedRemoteSynchronizer.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/OptimizedRemoteSynchronizer.java
@@ -11,7 +11,7 @@
package org.eclipse.team.internal.ccvs.core.syncinfo;
import org.eclipse.core.resources.IResource;
-import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.util.Util;
@@ -36,7 +36,7 @@ public class OptimizedRemoteSynchronizer extends RemoteTagSynchronizer {
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSynchronizer#getSyncBytes(org.eclipse.core.resources.IResource)
*/
- public byte[] getSyncBytes(IResource resource) throws CVSException {
+ public byte[] getSyncBytes(IResource resource) throws TeamException {
byte[] bytes = internalGetSyncBytes(resource);
if ((bytes == null) && !isRemoteKnown(resource)) {
// The remote was never known so use the base
@@ -48,7 +48,7 @@ public class OptimizedRemoteSynchronizer extends RemoteTagSynchronizer {
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.core.syncinfo.RemoteSynchronizer#setSyncBytes(org.eclipse.core.resources.IResource, byte[])
*/
- public void setSyncBytes(IResource resource, byte[] bytes) throws CVSException {
+ public void setSyncBytes(IResource resource, byte[] bytes) throws TeamException {
byte[] baseBytes = baseSynchronizer.getSyncBytes(resource);
if (baseBytes != null && Util.equals(baseBytes, bytes)) {
// Remove the existing bytes so the base will be used (thus saving space)
@@ -66,14 +66,14 @@ public class OptimizedRemoteSynchronizer extends RemoteTagSynchronizer {
* Return the bytes for the remote resource if there is a remote that differs
* from the local.
*/
- private byte[] internalGetSyncBytes(IResource resource) throws CVSException {
+ private byte[] internalGetSyncBytes(IResource resource) throws TeamException {
return super.getSyncBytes(resource);
}
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.core.syncinfo.RemoteTagSynchronizer#getRemoteSyncBytes(org.eclipse.core.resources.IResource, org.eclipse.team.internal.ccvs.core.ICVSRemoteResource)
*/
- protected byte[] getRemoteSyncBytes(IResource local, ICVSRemoteResource remote) throws CVSException {
+ protected byte[] getRemoteSyncBytes(IResource local, ICVSRemoteResource remote) throws TeamException {
if (remote == null && local.getType() == IResource.FOLDER) {
// If there is no remote, use the local sync for the folder
return baseSynchronizer.getSyncBytes(local);
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteSynchronizer.java
deleted file mode 100644
index 0d3b85862..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteSynchronizer.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ISynchronizer;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
-import org.eclipse.team.internal.ccvs.core.util.Util;
-
-/**
- * A remote resource sychronizer caches the remote sync bytes that can be
- * used to create remote handles
- */
-public class RemoteSynchronizer extends ResourceSynchronizer {
-
- private static final byte[] NO_REMOTE = new byte[0];
-
- public static final String SYNC_KEY_QUALIFIER = "org.eclipse.team.cvs"; //$NON-NLS-1$
- protected QualifiedName syncName;
- protected Set changedResources = new HashSet();
-
- public RemoteSynchronizer(String id) {
- syncName = new QualifiedName(SYNC_KEY_QUALIFIER, id);
- getSynchronizer().add(syncName);
- }
-
- /**
- * Dispose of any cached remote sync info.
- */
- public void dispose() {
- getSynchronizer().remove(getSyncName());
- }
-
- protected ISynchronizer getSynchronizer() {
- return ResourcesPlugin.getWorkspace().getSynchronizer();
- }
-
- protected QualifiedName getSyncName() {
- return syncName;
- }
-
- /**
- * Return the remote sync bytes cached for the given local resource.
- * A return value of <code>null</code> can mean either that the
- * remote has never been fetched or that it doesn't exist. The method
- * <code>isRemoteKnown(IResource)</code> should be used to differentiate
- * these two cases.
- */
- public byte[] getSyncBytes(IResource resource) throws CVSException {
- byte[] syncBytes = internalGetSyncBytes(resource);
- if (syncBytes != null && Util.equals(syncBytes, NO_REMOTE)) {
- // If it is known that there is no remote, return null
- return null;
- }
- return syncBytes;
- }
-
- private byte[] internalGetSyncBytes(IResource resource) throws CVSException {
- try {
- return getSynchronizer().getSyncInfo(getSyncName(), resource);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
-
- public void setSyncBytes(IResource resource, byte[] bytes) throws CVSException {
- byte[] oldBytes = internalGetSyncBytes(resource);
- if (oldBytes != null && Util.equals(oldBytes, bytes)) return;
- try {
- if (!parentHasSyncBytes(resource) && !Util.equals(bytes, NO_REMOTE)) {
- // Log a warning if there is no sync bytes available for the resource's
- // parent but there is valid sync bytes for the child
- CVSProviderPlugin.log(new CVSException(Policy.bind("ResourceSynchronizer.missingParentBytesOnSet", getSyncName().toString(), resource.getFullPath().toString()))); //$NON-NLS-1$
- }
- getSynchronizer().setSyncInfo(getSyncName(), resource, bytes);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- changedResources.add(resource);
- }
-
- /**
- * Indicates whether the parent of the given local resource has sync bytes for its
- * corresponding remote resource. The parent bytes of a remote resource are required
- * (by CVS) to create a handle to the remote resource.
- */
- protected boolean parentHasSyncBytes(IResource resource) throws CVSException {
- if (resource.getType() == IResource.PROJECT) return true;
- return (getSyncBytes(resource.getParent()) != null);
- }
-
- /**
- * Remove the remote bytes cached for the given local resource. After this
- * operation <code>isRemoteKnown(resource)</code> will return <code>false</code>
- * and <code>getSyncBytes(resource)</code> will return <code>null</code> for the
- * resource (and potentially it's children depending on the value of the depth parameter.
- */
- public void removeSyncBytes(IResource resource, int depth, boolean silent) throws CVSException {
- if (resource.exists() || resource.isPhantom()) {
- try {
- getSynchronizer().flushSyncInfo(getSyncName(), resource, depth);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- if(silent == false) {
- changedResources.add(resource);
- }
- }
- }
-
- /**
- * Return true if the remote resources associated with the given local
- * resource has been fetched. This method is useful for those cases when
- * there are no sync bytes for a remote resource and the client wants to
- * know if this means that the remote does exist (i.e. this method returns
- * <code>true</code>) or the remote has not been fetched (i.e. this method returns
- * <code>false</code>).
- */
- public boolean isRemoteKnown(IResource resource) throws CVSException {
- return internalGetSyncBytes(resource) != null;
- }
-
- /**
- * This method should be invoked by a client to indicate that it is known that
- * there is no remote resource associated with the local resource. After this method
- * is invoked, <code>isRemoteKnown(resource)</code> will return <code>true</code> and
- * <code>getSyncBytes(resource)</code> will return <code>null</code>.
- */
- protected void setRemoteDoesNotExist(IResource resource) throws CVSException {
- setSyncBytes(resource, NO_REMOTE);
- }
-
- /**
- * Return the sync bytes associated with the remote resource. A return
- * value of <code>null</code> indicates that the remote resource does not exist.
- */
- protected byte[] getRemoteSyncBytes(IResource local, ICVSRemoteResource remote) throws CVSException {
- if (remote != null) {
- return ((RemoteResource)remote).getSyncBytes();
- } else {
- return null;
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java
index e45403fa6..9046b4f78 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java
@@ -39,7 +39,7 @@ import org.eclipse.team.internal.ccvs.core.util.Assert;
/**
* This RemoteSynchronizr uses a CVS Tag to fetch the remote tree
*/
-public class RemoteTagSynchronizer extends RemoteSynchronizer {
+public class RemoteTagSynchronizer extends CVSRemoteSynchronizer {
private CVSTag tag;
@@ -48,7 +48,7 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
this.tag = tag;
}
- public void collectChanges(IResource local, ICVSRemoteResource remote, int depth, IProgressMonitor monitor) throws TeamException {
+ public void collectChanges(IResource local, IRemoteResource remote, int depth, IProgressMonitor monitor) throws TeamException {
byte[] remoteBytes = getRemoteSyncBytes(local, remote);
if (remoteBytes == null) {
setRemoteDoesNotExist(local);
@@ -59,7 +59,7 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
Map children = mergedMembers(local, remote, monitor);
for (Iterator it = children.keySet().iterator(); it.hasNext();) {
IResource localChild = (IResource) it.next();
- ICVSRemoteResource remoteChild = (ICVSRemoteResource)children.get(localChild);
+ IRemoteResource remoteChild = (IRemoteResource)children.get(localChild);
collectChanges(localChild, remoteChild,
depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO,
monitor);
@@ -86,7 +86,6 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
IResource[] localChildren = getLocalChildren(local);
if (remoteChildren.length > 0 || localChildren.length > 0) {
- List syncChildren = new ArrayList(10);
Set allSet = new HashSet(20);
Map localSet = null;
Map remoteSet = null;
@@ -186,7 +185,7 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
return new IResource[0];
}
- private byte[] internalGetSyncBytes(IResource resource) throws CVSException {
+ private byte[] internalGetSyncBytes(IResource resource) throws TeamException {
return super.getSyncBytes(resource);
}
@@ -231,12 +230,12 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
resetChanges();
try {
for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ IResource resource = resources[i];
monitor.setTaskName(Policy.bind("RemoteTagSynchronizer.0", resource.getFullPath().makeRelative().toString())); //$NON-NLS-1$
// build the remote tree only if an initial tree hasn't been provided
- ICVSRemoteResource tree = buildRemoteTree(resource, depth, cacheFileContentsHint, Policy.subMonitorFor(monitor, 70));
+ IRemoteResource tree = buildRemoteTree(resource, depth, cacheFileContentsHint, Policy.subMonitorFor(monitor, 70));
// update the known remote handles
IProgressMonitor sub = Policy.infiniteSubMonitorFor(monitor, 30);
@@ -255,7 +254,7 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
resetChanges();
return changes;
}
-
+
/**
* Build a remote tree for the given parameters.
*/
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java
index 7cc011337..ece2c308f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeUpdateAction.java
@@ -60,7 +60,7 @@ public class MergeUpdateAction extends SafeUpdateAction {
});
}
- protected void updated(IResource[] resources) throws CVSException {
+ protected void updated(IResource[] resources) throws TeamException {
// Mark all succesfully updated resources as merged
((CVSMergeSubscriber)getSubscriber()).merged(resources);
}

Back to the top