Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-12-03 22:49:27 -0500
committerMichael Valenta2004-12-03 22:49:27 -0500
commit34227771a369a26b60f8e35c75e812e1d4f7f89b (patch)
treef3337ce7175648296b9722eb5dfcb923b75960b7
parent168839af46219ead13295a7f3cb7e5ef575f31a3 (diff)
downloadeclipse.platform.team-branch_20041202_Caching.tar.gz
eclipse.platform.team-branch_20041202_Caching.tar.xz
eclipse.platform.team-branch_20041202_Caching.zip
*** empty log message ***branch_20041202_Caching
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/CacheableReference.java6
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/ICacheSource.java6
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/ICacheableReference.java6
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/LocalReplica.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/LocalTagCache.java7
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/TagCacheSource.java7
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/XMLLocalReplica.java10
9 files changed, 49 insertions, 11 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/CacheableReference.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/CacheableReference.java
index a07409d69..09bf952f6 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/CacheableReference.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/CacheableReference.java
@@ -64,6 +64,12 @@ public class CacheableReference implements ICacheableReference {
// Let ALWAYS_FETCH override DO_NOT_FETCH_IF_ABSENT
return null;
}
+ if ((flags & ONLY_LOAD_REPLICA_IF_ABSENT) > 0 && !source.isLocalReplica()) {
+ // The source is not a local replica so don't load
+ return null;
+ }
+
+ // TODO: should serialize fetch to ensure it doesn't happen concurrently
Object o = fetchObject(flags, Policy.monitorFor(monitor));
setCachedObject(o);
return o;
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/ICacheSource.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/ICacheSource.java
index f0bac9911..4e2227789 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/ICacheSource.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/ICacheSource.java
@@ -35,4 +35,10 @@ public interface ICacheSource {
* @return a cachable object representing the data at he source location
*/
Object fetch(int flags, IProgressMonitor monitor) throws CoreException;
+
+ /**
+ * Return whether the cache source is a local replica of a remote source.
+ * @return whether the cache source is a local replica of a remote source
+ */
+ boolean isLocalReplica();
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/ICacheableReference.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/ICacheableReference.java
index 9b7911d5c..524f2c0f6 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/ICacheableReference.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/ICacheableReference.java
@@ -38,6 +38,12 @@ public interface ICacheableReference {
public static final int ALWAYS_FETCH = 2;
/**
+ * Flag indicating that the object should be loaded
+ * from a local replica if present.
+ */
+ public static final int ONLY_LOAD_REPLICA_IF_ABSENT = 4;
+
+ /**
* This contant provides the beginning flag that can be used by clients
* to provide custom flags for fetching objects.
*/
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/LocalReplica.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/LocalReplica.java
index fcb69379a..17d213190 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/LocalReplica.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/caches/LocalReplica.java
@@ -67,10 +67,10 @@ public abstract class LocalReplica implements ICacheSource {
throw (RuntimeException)e;
}
// Impossible but handle anyway.
- TeamPlugin.log(IStatus.WARNING, "Could no load local replica.", e); //$NON-NLS-1$
+ TeamPlugin.log(IStatus.WARNING, "Could not load local replica.", e); //$NON-NLS-1$
return null;
}
- TeamPlugin.log(IStatus.WARNING, "Could no load local replica. Fetching from the remote source.", e); //$NON-NLS-1$
+ TeamPlugin.log(IStatus.WARNING, "Could not load local replica. Fetching from the remote source.", e); //$NON-NLS-1$
return fetchRemote(flags, monitor);
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/LocalTagCache.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/LocalTagCache.java
index 10f0d3f56..8f778c04e 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/LocalTagCache.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/LocalTagCache.java
@@ -97,4 +97,11 @@ public class LocalTagCache extends XMLLocalReplica {
public void dispose() {
getFile().delete();
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.core.caches.ICacheSource#isLocalReplica()
+ */
+ public boolean isLocalReplica() {
+ return true;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java
index 0f845e9a3..1073156d8 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java
@@ -97,8 +97,10 @@ public class RepositoriesViewContentHandler extends DefaultHandler {
ignoreElements = false;
} else if (elementName.equals(MODULE_TAG)) {
if (! ignoreElements && currentRepositoryRoot != null) {
- currentRepositoryRoot.addTags(currentRemotePath,
- (CVSTag[]) tags.toArray(new CVSTag[tags.size()]));
+ if (!tags.isEmpty()) {
+ currentRepositoryRoot.addTags(currentRemotePath,
+ (CVSTag[]) tags.toArray(new CVSTag[tags.size()]));
+ }
if (lastAccessTime > 0)
currentRepositoryRoot.setLastAccessedTime(currentRemotePath, lastAccessTime);
currentRepositoryRoot.setAutoRefreshFiles(currentRemotePath,
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 c1b0e64f0..70e549e0a 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
@@ -56,7 +56,7 @@ public class RepositoryRoot extends PlatformObject {
String fileName;
public TagCacheEntry(RepositoryRoot repo, String remotePath) {
this.repo = repo;
- this.cache = new CacheableReference(createTagCacheSource(remotePath));;
+ this.cache = new CacheableReference(createTagCacheSource(remotePath));
accessed();
}
public boolean isExpired() {
@@ -129,7 +129,7 @@ public class RepositoryRoot extends PlatformObject {
}
private CVSTag[] getTags() {
try {
- return (CVSTag[])getReference().getObject(ICacheableReference.DO_NOT_FETCH_IF_ABSENT, null);
+ return (CVSTag[])getReference().getObject(ICacheableReference.ONLY_LOAD_REPLICA_IF_ABSENT, null);
} catch (CoreException e) {
CVSUIPlugin.log(e);
} catch (ClassCastException e) {
@@ -145,7 +145,7 @@ public class RepositoryRoot extends PlatformObject {
HashMap attributes = new HashMap();
attributes.put(RepositoriesViewContentHandler.PATH_ATTRIBUTE, fileName);
attributes.put(RepositoriesViewContentHandler.LAST_ACCESS_TIME_ATTRIBUTE, Long.toString(lastAccessTime));
- writer.startTag(RepositoriesViewContentHandler.TAG_REPLICA_TAG, attributes, true);
+ writer.startAndEndTag(RepositoriesViewContentHandler.TAG_REPLICA_TAG, attributes, true);
}
}
@@ -634,7 +634,7 @@ public class RepositoryRoot extends PlatformObject {
entry.accessed();
CVSTag[] tags1;
try {
- tags1 = (CVSTag[]) entry.getReference().getObject(ICacheableReference.DO_NOT_FETCH_IF_ABSENT, null);
+ tags1 = (CVSTag[]) entry.getReference().getObject(ICacheableReference.ONLY_LOAD_REPLICA_IF_ABSENT, null);
} catch (CoreException e) {
// Log and continue
CVSUIPlugin.log(e);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/TagCacheSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/TagCacheSource.java
index 29024fc1c..848ed9840 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/TagCacheSource.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/TagCacheSource.java
@@ -73,4 +73,11 @@ public class TagCacheSource implements ICacheSource {
public String getRemotePath() {
return remoteFolderPath;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.internal.core.caches.ICacheSource#isLocalReplica()
+ */
+ public boolean isLocalReplica() {
+ return false;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/XMLLocalReplica.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/XMLLocalReplica.java
index e2b36d591..e132d86d1 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/XMLLocalReplica.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/XMLLocalReplica.java
@@ -40,13 +40,17 @@ public abstract class XMLLocalReplica extends LocalReplica {
XMLMemento memento = XMLMemento.createWriteRoot(getType());
save(o, memento, monitor);
Writer writer = null;
+ File file = getFile();
+ File parentDir = file.getParentFile();
+ if (!parentDir.exists())
+ parentDir.mkdirs();
try {
- writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(getFile())));
+ writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
memento.save(writer);
} catch (FileNotFoundException e) {
- throw new TeamException("Could not create file " + getFile().getAbsolutePath(), e);
+ throw new TeamException("Could not create file " + file.getAbsolutePath(), e);
} catch (IOException e) {
- throw new TeamException("Could not write to file " + getFile().getAbsolutePath(), e);
+ throw new TeamException("Could not write to file " + file.getAbsolutePath(), e);
} finally {
if (writer != null) {
try {

Back to the top