Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-12-12 17:10:45 +0000
committerMichael Valenta2002-12-12 17:10:45 +0000
commit1c6643b0e9cd8f8da2274d8b7119d108e6cf287d (patch)
treea79f6feab705d94bde487af7dba65cfe4442e70d
parenta2afab127c6906300e7d3a1dab77da458ea3858f (diff)
downloadeclipse.platform.team-1c6643b0e9cd8f8da2274d8b7119d108e6cf287d.tar.gz
eclipse.platform.team-1c6643b0e9cd8f8da2274d8b7119d108e6cf287d.tar.xz
eclipse.platform.team-1c6643b0e9cd8f8da2274d8b7119d108e6cf287d.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java53
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java3
2 files changed, 51 insertions, 5 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java
index 4677d1599..21c3b66b1 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/SynchronizerSyncInfoCache.java
@@ -15,6 +15,9 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@@ -30,6 +33,7 @@ import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
/**
@@ -54,7 +58,7 @@ import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
* Convert a FolderSyncInfo into a byte array that can be stored
* in the workspace synchronizer
*/
- private static byte[] getBytes(FolderSyncInfo info) throws CVSException {
+ private byte[] getBytes(FolderSyncInfo info) throws CVSException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(out);
try {
@@ -78,7 +82,7 @@ import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
* Convert a byte array that was created using getBytes(FolderSyncInfo)
* into a FolderSyncInfo
*/
- private static FolderSyncInfo getFolderSyncInfo(byte[] bytes) throws CVSException {
+ private FolderSyncInfo getFolderSyncInfo(byte[] bytes) throws CVSException {
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
DataInputStream dis = new DataInputStream(in);
String root;
@@ -116,11 +120,52 @@ import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
* Convert a byte array that was created using getBytes(Map)
* into a Map of ResourceSyncInfo
*/
- private static byte[][] getResourceSyncInfo(byte[] bytes) throws CVSException {
- return SyncFileWriter.readLines(new ByteArrayInputStream(bytes));
+ private byte[][] getResourceSyncInfo(byte[] bytes) throws CVSException {
+ byte[][] infos = SyncFileWriter.readLines(new ByteArrayInputStream(bytes));
+ // check to make sure the info is not stored in the old format
+ if (infos.length != 0) {
+ byte[] firstLine = infos[0];
+ if (firstLine.length != 0 && (firstLine[0] != (byte)'/' && firstLine[0] != (byte)'D')) {
+ Map oldInfos = getResourceSyncInfoMap(bytes);
+ infos = new byte[oldInfos.size()][];
+ int i = 0;
+ for (Iterator iter = oldInfos.values().iterator(); iter.hasNext();) {
+ ResourceSyncInfo element = (ResourceSyncInfo) iter.next();
+ infos[i++] = element.getBytes();
+ }
+ // We can't convert the info to the new format because the caller
+ // may either not be in a workspace runnable or the resource tree
+ // may be closed for modification
+ }
+ }
+ return infos;
}
/**
+ * ResourceSyncInfo used to be stored as a Map of ResourceSyncInfo.
+ * We need to be able to retrieve that info the way it was and
+ * convert it to the new way.
+ *
+ * Convert a byte array that was created using
+ * getBytes(Map) into a Map of ResourceSyncInfo
+ */
+ private Map getResourceSyncInfoMap(byte[] bytes) throws CVSException {
+ ByteArrayInputStream in = new ByteArrayInputStream(bytes);
+ DataInputStream dis = new DataInputStream(in);
+ Map result = new HashMap();
+ try {
+ int size = dis.readInt();
+ for (int i = 0; i < size; i++) {
+ ResourceSyncInfo info = new ResourceSyncInfo(dis.readUTF(), null, null);
+ result.put(info.getName(), info);
+ }
+ } catch (IOException e) {
+ throw CVSException.wrapException(e);
+ }
+ return result;
+ }
+
+ /**
* Flush any info cahced for the folder
*/
private void flushPhantomInfo(IContainer container) throws CVSException {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java
index ca65ec615..24e8420fb 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/FolderSyncInfo.java
@@ -48,7 +48,8 @@ public class FolderSyncInfo {
Assert.isNotNull(repo);
Assert.isNotNull(root);
this.repository = repo;
- this.root = root;
+ // intern the root so that caching of FolderSyncInfos for folders will use less space
+ this.root = root.intern();
ensureRepositoryRelativeToRoot();
this.isStatic = isStatic;
setTag(tag);

Back to the top