Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-08-22 17:56:04 +0000
committerMichael Valenta2003-08-22 17:56:04 +0000
commit12122570c66669bbb5243c31f7d44ddcfd0a34d7 (patch)
tree8137199e9d754ed7830adea055406587fc326afb
parente4ffe8579699a0985a9cdc081d22dea9fa1dd767 (diff)
downloadeclipse.platform.team-12122570c66669bbb5243c31f7d44ddcfd0a34d7.tar.gz
eclipse.platform.team-12122570c66669bbb5243c31f7d44ddcfd0a34d7.tar.xz
eclipse.platform.team-12122570c66669bbb5243c31f7d44ddcfd0a34d7.zip
Refactored to properly detect cases where the sync info for
the parent remote resource is needed.
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java1
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSWorkspaceSubscriber.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/OptimizedRemoteSynchronizer.java31
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteSynchronizer.java71
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/RemoteTagSynchronizer.java47
5 files changed, 89 insertions, 63 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 9f500aca3..94ea0d771 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
@@ -40,7 +40,6 @@ 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;
-import org.eclipse.team.internal.ccvs.core.Policy;
/**
* A CVSMergeSubscriber is responsible for maintaining the remote trees for a merge into
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 f7a88ac90..1ecf1b4bc 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
@@ -215,6 +215,6 @@ public class CVSWorkspaceSubscriber extends CVSSyncTreeSubscriber implements IRe
}
private boolean hasIncomingChange(IResource resource) throws CVSException {
- return remoteSynchronizer.getRemoteBytes(resource) != null;
+ return remoteSynchronizer.isRemoteKnown(resource);
}
}
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 9550e1589..954398ffc 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
@@ -12,6 +12,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.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.util.Util;
@@ -24,19 +25,20 @@ public class OptimizedRemoteSynchronizer extends RemoteTagSynchronizer {
// The local synchronizer is used for cases where the remote is unknown
private BaseSynchronizer baseSynchronizer = new BaseSynchronizer();
- /**
- * @param id
- */
public OptimizedRemoteSynchronizer(String id) {
- super(id, null /* use the tag in the local workspace resources */);
+ this(id, null /* use the tag in the local workspace resources */);
+ }
+
+ public OptimizedRemoteSynchronizer(String id, CVSTag tag) {
+ super(id, tag);
}
/* (non-Javadoc)
* @see org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSynchronizer#getSyncBytes(org.eclipse.core.resources.IResource)
*/
public byte[] getSyncBytes(IResource resource) throws CVSException {
- byte[] bytes = getRemoteBytes(resource);
- if ((bytes == null) && !hasRemoteBytesFor(resource)) {
+ byte[] bytes = internalGetSyncBytes(resource);
+ if ((bytes == null) && !isRemoteKnown(resource)) {
// The remote was never known so use the base
bytes = baseSynchronizer.getSyncBytes(resource);
}
@@ -56,34 +58,27 @@ public class OptimizedRemoteSynchronizer extends RemoteTagSynchronizer {
}
}
- /**
- * @return
- */
public BaseSynchronizer getBaseSynchronizer() {
return baseSynchronizer;
}
- /**
+ /*
* Return the bytes for the remote resource if there is a remote that differs
* from the local.
- *
- * @param resource
- * @return
- * @throws CVSException
*/
- public byte[] getRemoteBytes(IResource resource) throws CVSException {
+ private byte[] internalGetSyncBytes(IResource resource) throws CVSException {
return super.getSyncBytes(resource);
}
/* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.core.syncinfo.RemoteTagSynchronizer#getRemoteBytes(org.eclipse.core.resources.IResource, org.eclipse.team.internal.ccvs.core.ICVSRemoteResource)
+ * @see org.eclipse.team.internal.ccvs.core.syncinfo.RemoteTagSynchronizer#getRemoteSyncBytes(org.eclipse.core.resources.IResource, org.eclipse.team.internal.ccvs.core.ICVSRemoteResource)
*/
- protected byte[] getRemoteBytes(IResource local, ICVSRemoteResource remote) throws CVSException {
+ protected byte[] getRemoteSyncBytes(IResource local, ICVSRemoteResource remote) throws CVSException {
if (remote == null && local.getType() == IResource.FOLDER) {
// If there is no remote, use the local sync for the folder
return baseSynchronizer.getSyncBytes(local);
}
- return super.getRemoteBytes(local, remote);
+ return super.getRemoteSyncBytes(local, remote);
}
}
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
index 033a789b3..7958d7437 100644
--- 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
@@ -20,7 +20,9 @@ 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;
/**
@@ -29,6 +31,8 @@ import org.eclipse.team.internal.ccvs.core.util.Util;
*/
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();
@@ -53,19 +57,37 @@ public class RemoteSynchronizer extends ResourceSynchronizer {
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 = getSyncBytes(resource);
if (oldBytes != null && Util.equals(oldBytes, bytes)) return;
try {
- if (!parentHasSyncBytes(resource)) {
+ 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);
@@ -75,11 +97,22 @@ public class RemoteSynchronizer extends ResourceSynchronizer {
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 {
@@ -92,4 +125,38 @@ public class RemoteSynchronizer extends ResourceSynchronizer {
}
}
}
+
+ /**
+ * 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 7a837c15a..288220750 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
@@ -34,16 +34,13 @@ import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.core.util.Util;
/**
* This RemoteSynchronizr uses a CVS Tag to fetch the remote tree
*/
public class RemoteTagSynchronizer extends RemoteSynchronizer {
- private static final byte[] NO_REMOTE = new byte[0];
private CVSTag tag;
public RemoteTagSynchronizer(String id, CVSTag tag) {
@@ -52,9 +49,12 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
}
public void collectChanges(IResource local, ICVSRemoteResource remote, int depth, IProgressMonitor monitor) throws TeamException {
- byte[] remoteBytes = getRemoteBytes(local, remote);
- if (remoteBytes == null) return;
- setSyncBytes(local, remoteBytes);
+ byte[] remoteBytes = getRemoteSyncBytes(local, remote);
+ if (remoteBytes == null) {
+ setRemoteDoesNotExist(local);
+ } else {
+ setSyncBytes(local, remoteBytes);
+ }
if (depth == IResource.DEPTH_ZERO) return;
Map children = mergedMembers(local, remote, monitor);
for (Iterator it = children.keySet().iterator(); it.hasNext();) {
@@ -76,14 +76,6 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
}
}
- protected byte[] getRemoteBytes(IResource local, ICVSRemoteResource remote) throws CVSException {
- if (remote != null) {
- return ((RemoteResource)remote).getSyncBytes();
- } else {
- return NO_REMOTE;
- }
- }
-
protected Map mergedMembers(IResource local, IRemoteResource remote, IProgressMonitor progress) throws TeamException {
// {IResource -> IRemoteResource}
@@ -211,33 +203,6 @@ public class RemoteTagSynchronizer extends RemoteSynchronizer {
return ((IContainer) parent).getFile(new Path(childName));
}
}
-
- /**
- * Return true if remote bytes for the resource have been fetched during
- * a refresh. This will also return true for remote resources that do not exist
- * (i.e. they have no sync bytes but did not exist remotely at the time of the
- * last refresh.
- *
- * @param resource
- * @return
- */
- public boolean hasRemoteBytesFor(IResource resource) throws CVSException {
- return super.getSyncBytes(resource) != null;
- }
-
- /**
- * This method will return null in both cases when the remote has never been fetched
- * or when the remote does not exist. Use <code>hasRemoteBytesFor</code> to
- * differentiate these 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;
- }
/**
* @return

Back to the top