Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-01-03 15:36:09 -0500
committerMichael Valenta2003-01-03 15:36:09 -0500
commit4312282c35046b763428d513db6bb5ffafc42eaa (patch)
tree4bd03bc99ff6c4d4d6563e027634ca6bea201f88
parentcf22978826d9f4eb56d039d4a2827b246ecc6254 (diff)
downloadeclipse.platform.team-MV_ResoureSyncInfo.tar.gz
eclipse.platform.team-MV_ResoureSyncInfo.tar.xz
eclipse.platform.team-MV_ResoureSyncInfo.zip
Converted most uses of sync info into sync bytesMV_ResoureSyncInfo
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java23
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java3
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java13
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java36
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java18
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java10
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java22
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java12
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java16
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java15
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java22
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java30
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java230
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AddDeleteMoveListener.java28
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java23
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java66
20 files changed, 445 insertions, 150 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
index e40829bcf..145fe6198 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java
@@ -706,12 +706,11 @@ public class CVSTeamProvider extends RepositoryProvider {
CVSWorkspaceRoot.getCVSResourceFor(resources[i]).accept(new ICVSResourceVisitor() {
public void visitFile(ICVSFile file) throws CVSException {
monitor.worked(1);
- ResourceSyncInfo info = file.getSyncInfo();
- if (info != null) {
- monitor.subTask(Policy.bind("CVSTeamProvider.updatingFile", info.getName())); //$NON-NLS-1$
- MutableResourceSyncInfo newInfo = info.cloneMutable();
- newInfo.setTag(tag);
- file.setSyncInfo(newInfo);
+ //ResourceSyncInfo info = file.getSyncInfo();
+ byte[] syncBytes = file.getSyncBytes();
+ if (syncBytes != null) {
+ monitor.subTask(Policy.bind("CVSTeamProvider.updatingFile", file.getName())); //$NON-NLS-1$
+ file.setSyncBytes(ResourceSyncInfo.setTag(syncBytes, tag));
}
};
public void visitFolder(ICVSFolder folder) throws CVSException {
@@ -965,20 +964,18 @@ public class CVSTeamProvider extends RepositoryProvider {
if (! mFile.isManaged()) continue;
// only set keyword substitution if new differs from actual
- ResourceSyncInfo info = mFile.getSyncInfo();
- KSubstOption fromKSubst = info.getKeywordMode();
+ byte[] syncBytes = mFile.getSyncBytes();
+ KSubstOption fromKSubst = ResourceSyncInfo.getKeywordMode(syncBytes);
if (toKSubst.equals(fromKSubst)) continue;
// change resource sync info immediately for an outgoing addition
- if (info.isAdded()) {
- MutableResourceSyncInfo newInfo = info.cloneMutable();
- newInfo.setKeywordMode(toKSubst);
- mFile.setSyncInfo(newInfo);
+ if (ResourceSyncInfo.isAddition(syncBytes)) {
+ mFile.setSyncBytes(ResourceSyncInfo.setKeywordMode(syncBytes, toKSubst));
continue;
}
// nothing do to for deletions
- if (info.isDeleted()) continue;
+ if (ResourceSyncInfo.isDeletion(syncBytes)) continue;
// file exists remotely so we'll have to commit it
if (fromKSubst.isBinary() && ! toKSubst.isBinary()) {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java
index 983d85b29..477d82ce8 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java
@@ -147,11 +147,11 @@ abstract class AbstractStructureVisitor implements ICVSResourceVisitor {
sendFolder(mFile.getParent());
// Send the file's entry line to the server
- ResourceSyncInfo info = mFile.getSyncInfo();
- boolean isManaged = info != null;
+ byte[] syncBytes = mFile.getSyncBytes();
+ boolean isManaged = syncBytes != null;
if (isManaged) {
sendPendingNotification(mFile);
- session.sendEntry(info.getServerEntryLine(mFile.getTimeStamp()));
+ session.sendEntry(syncBytes, ResourceSyncInfo.getTimestampToServer(syncBytes, mFile.getTimeStamp()));
} else {
// If the file is not managed, send a questionable to the server if the file exists locally
// A unmanaged, locally non-existant file results from the explicit use of the file name as a command argument
@@ -167,7 +167,7 @@ abstract class AbstractStructureVisitor implements ICVSResourceVisitor {
// If the file exists, send the appropriate indication to the server
if (mFile.exists()) {
if (mFile.isModified()) {
- boolean binary = info != null && info.getKeywordMode().isBinary();
+ boolean binary = ResourceSyncInfo.isBinary(syncBytes);
if (sendModifiedContents) {
session.sendModified(mFile, binary, monitor);
} else {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java
index 3e2a098c6..c1510a15b 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Commit.java
@@ -17,7 +17,6 @@ import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
-import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
public class Commit extends Command {
/*** Local options: specific to commit ***/
@@ -88,7 +87,7 @@ public class Commit extends Command {
}
protected IStatus clearModifiedState(ICVSFile cvsFile) throws CVSException {
- ResourceSyncInfo info = cvsFile.getSyncInfo();
+ byte[] info = cvsFile.getSyncBytes();
if (info == null) {
// There should be sync info. Log the problem
return new Status(IStatus.WARNING, CVSProviderPlugin.ID, 0, Policy.bind("Commit.syncInfoMissing", cvsFile.getIResource().getFullPath().toString()), null); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java
index 2a4447c47..acba6bf84 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java
@@ -28,8 +28,7 @@ class DiffStructureVisitor extends FileStructureVisitor {
* Send unmanaged files as modified with a default entry line.
*/
protected void sendFile(ICVSFile mFile) throws CVSException {
- KSubstOption ksubst;
- ResourceSyncInfo info = mFile.getSyncInfo();
+ byte[] info = mFile.getSyncBytes();
boolean addedFile = (info==null);
// Send the parent folder if it hasn't been sent already
@@ -38,6 +37,7 @@ class DiffStructureVisitor extends FileStructureVisitor {
Policy.checkCanceled(monitor);
if (addedFile) {
+ KSubstOption ksubst;
if (mFile instanceof EclipseFile) {
EclipseFile file = (EclipseFile)mFile;
ksubst = KSubstOption.fromFile(file.getIFile());
@@ -46,19 +46,16 @@ class DiffStructureVisitor extends FileStructureVisitor {
}
MutableResourceSyncInfo newInfo = new MutableResourceSyncInfo(mFile.getName(), null);
newInfo.setKeywordMode(ksubst);
- info = newInfo;
- } else {
- // existing file
- ksubst = info.getKeywordMode();
+ info = newInfo.getBytes();
}
- session.sendEntry(info.getServerEntryLine(null));
+ session.sendEntry(info, null);
if (!mFile.exists()) {
return;
}
if (mFile.isModified() || addedFile) {
- session.sendModified(mFile, ksubst.isBinary(), monitor);
+ session.sendModified(mFile, ResourceSyncInfo.isBinary(info), monitor);
} else {
session.sendUnchanged(mFile);
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
index c74f24512..b7c25c4f7 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java
@@ -562,7 +562,7 @@ public class Session {
// of the object, we can simpy reset the info for each moved resource
desiredFolder.accept(new ICVSResourceVisitor() {
public void visitFile(ICVSFile file) throws CVSException {
- file.setSyncInfo(file.getSyncInfo());
+ file.setSyncBytes(file.getSyncBytes());
}
public void visitFolder(ICVSFolder folder) throws CVSException {
folder.setFolderSyncInfo(folder.getFolderSyncInfo());
@@ -756,8 +756,29 @@ public class Session {
*
* @param entryLine the formatted entry line of the managed file.
*/
- public void sendEntry(String entryLine) throws CVSException {
- connection.writeLine("Entry " + entryLine); //$NON-NLS-1$
+ public void sendEntry(byte[] syncBytes, String serverTimestamp) throws CVSException {
+ connection.write("Entry "); //$NON-NLS-1$
+ if (serverTimestamp == null) {
+ connection.writeLine(syncBytes, 0, syncBytes.length);
+ } else {
+ int start = Util.getOffsetOfDelimeter(syncBytes, (byte)'/', 0, 3);
+ if (start == -1) {
+ // something is wrong with the entry line so just send it as is
+ // and let the server report the error.
+ connection.writeLine(syncBytes, 0, syncBytes.length);
+ return;
+ }
+ int end = Util.getOffsetOfDelimeter(syncBytes, (byte)'/', start + 1, 1);
+ if (end == -1) {
+ // something is wrong with the entry line so just send it as is
+ // and let the server report the error.
+ connection.writeLine(syncBytes, 0, syncBytes.length);
+ return;
+ }
+ connection.write(syncBytes, 0, start + 1);
+ connection.write(serverTimestamp);
+ connection.writeLine(syncBytes, end, syncBytes.length - end);
+ }
}
/**
@@ -857,13 +878,8 @@ public class Session {
String filename = file.getName();
connection.writeLine("Modified " + filename); //$NON-NLS-1$
- ResourceSyncInfo info = file.getSyncInfo();
- if (info != null) {
- connection.writeLine(info.getPermissions());
- } else {
- // for new resources send the default permissions
- connection.writeLine(ResourceSyncInfo.getDefaultPermissions());
- }
+ // send the default permissions for now
+ connection.writeLine(ResourceSyncInfo.getDefaultPermissions());
sendFile(file, isBinary, monitor);
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java
index 1c1c16db4..c8e4b5417 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java
@@ -9,7 +9,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
/**
@@ -28,21 +27,18 @@ class TagFileSender extends FileStructureVisitor {
*/
protected void sendFile(ICVSFile mFile) throws CVSException {
Policy.checkCanceled(monitor);
- if (mFile.isManaged()) {
+ byte[] syncBytes = mFile.getSyncBytes();
+ if (syncBytes != null) {
// Send the parent folder if it hasn't been sent already
sendFolder(mFile.getParent());
// Send the file if appropriate
- ResourceSyncInfo info = mFile.getSyncInfo();
- if (info.isDeleted()) {
+ if (ResourceSyncInfo.isDeletion(syncBytes)) {
// makes this resource sync undeleted
- MutableResourceSyncInfo undeletedInfo = info.cloneMutable();
- undeletedInfo.setDeleted(false);
- info = undeletedInfo;
+ syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes);
}
- if (!info.isAdded()) {
- session.sendEntry(info.getServerEntryLine(mFile.getTimeStamp()));
- boolean binary = info != null && info.getKeywordMode().isBinary();
- session.sendIsModified(mFile, binary, monitor);
+ if (!ResourceSyncInfo.isAddition(syncBytes)) {
+ session.sendEntry(syncBytes, ResourceSyncInfo.getTimestampToServer(syncBytes, mFile.getTimeStamp()));
+ session.sendIsModified(mFile, ResourceSyncInfo.isBinary(syncBytes), monitor);
}
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java
index 0f9a4a673..d0ca35bdb 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java
@@ -18,7 +18,6 @@ import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
/**
@@ -69,12 +68,11 @@ public class AdminKSubstListener extends CommandOutputListener {
rcsFilePath = rcsFilePath.removeFirstSegments(remoteRootPath.segmentCount());
try {
ICVSFile file = commandRoot.getFile(rcsFilePath.toString());
- ResourceSyncInfo info = file.getSyncInfo();
- if (info != null) {
+ //ResourceSyncInfo info = file.getSyncInfo();
+ byte[] syncBytes = file.getSyncBytes();
+ if (syncBytes != null) {
// only update sync info if we have it locally
- MutableResourceSyncInfo newInfo = info.cloneMutable();
- newInfo.setKeywordMode(ksubstMode);
- file.setSyncInfo(newInfo);
+ file.setSyncBytes(ResourceSyncInfo.setKeywordMode(syncBytes, ksubstMode));
}
} catch (CVSException e) {
return new CVSStatus(CVSStatus.ERROR,
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java
index 3e68d7ce0..8901d36b9 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java
@@ -169,28 +169,40 @@ public class Connection {
* Sends the given string to the server.
*/
public void write(String s) throws CVSException {
- write(s, false);
+ write(s.getBytes(), 0, s.length(), false);
+ }
+ /**
+ * Sends the given bytes to the server.
+ */
+ public void write(byte[] b, int off, int len) throws CVSException {
+ write(b, off, len, false);
}
/**
* Sends the given string and a newline to the server.
*/
public void writeLine(String s) throws CVSException {
- write(s, true);
+ write(s.getBytes(), 0, s.length(), true);
+ }
+ /**
+ * Sends the given bytes and a newline to the server.
+ */
+ public void writeLine(byte[] b, int off, int len) throws CVSException {
+ write(b, off, len, true);
}
/**
* Low level method to write a string to the server. All write* methods are
* funneled through this method.
*/
- void write(String s, boolean newline) throws CVSException {
+ void write(byte[] b, int off, int len, boolean newline) throws CVSException {
if (!isEstablished())
throw new CVSCommunicationException(Policy.bind("Connection.writeUnestablishedConnection"));//$NON-NLS-1$
if (Policy.DEBUG_CVS_PROTOCOL)
- System.out.print(s + (newline ? "\n" : ""));//$NON-NLS-1$ //$NON-NLS-2$
+ System.out.print(new String(b) + (newline ? "\n" : ""));//$NON-NLS-1$ //$NON-NLS-2$
try {
OutputStream out= getOutputStream();
- out.write(s.getBytes());
+ out.write(b, off, len);
if (newline)
out.write(NEWLINE);
out.flush();
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java
index 9750c95d6..6393ce862 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java
@@ -17,8 +17,8 @@ import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor;
import org.eclipse.team.internal.ccvs.core.Policy;
@@ -420,14 +420,14 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
}
ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)e1);
try {
- ResourceSyncInfo info1 = cvsFile.getSyncInfo();
- ResourceSyncInfo info2 = ((ICVSRemoteResource)e2).getSyncInfo();
+ byte[] syncBytes1 = cvsFile.getSyncBytes();
+ byte[] syncBytes2 = ((ICVSRemoteFile)e2).getSyncBytes();
- if(info1 != null) {
- if(info1.isDeleted() || info1.isMerged() || cvsFile.isModified()) {
+ if(syncBytes1 != null) {
+ if(ResourceSyncInfo.isDeletion(syncBytes1) || ResourceSyncInfo.isMerge(syncBytes1) || cvsFile.isModified()) {
return false;
}
- return info1.getRevision().equals(info2.getRevision());
+ return ResourceSyncInfo.getRevision(syncBytes1).equals(ResourceSyncInfo.getRevision(syncBytes2));
}
return false;
} catch(CVSException e) {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
index c98651768..abe08fc67 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java
@@ -675,9 +675,9 @@ public class CVSWorkspaceRoot {
return cvsResource.isManaged();
}
} else {
- ResourceSyncInfo info = cvsResource.getSyncInfo();
- if(info!=null) {
- return !info.isAdded();
+ byte[] syncBytes = ((ICVSFile)cvsResource).getSyncBytes();
+ if(syncBytes!=null) {
+ return !ResourceSyncInfo.isAddition(syncBytes);
} else {
return false;
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
index 6742211a3..b54ffc0d7 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
@@ -246,8 +246,8 @@ public class EclipseFile extends EclipseResource implements ICVSFile {
* @see ICVSFile#getLogEntries(IProgressMonitor)
*/
public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException {
- ResourceSyncInfo info = getSyncInfo();
- if(isManaged(info) && !info.isAdded()) {
+ byte[] syncBytes = getSyncBytes();
+ if(syncBytes != null && !ResourceSyncInfo.isAddition(syncBytes)) {
ICVSRemoteResource remoteFile = CVSWorkspaceRoot.getRemoteResourceFor(resource);
return ((ICVSRemoteFile)remoteFile).getLogEntries(monitor);
}
@@ -302,8 +302,8 @@ public class EclipseFile extends EclipseResource implements ICVSFile {
*/
public void edit(int notifications, IProgressMonitor monitor) throws CVSException {
if (!isReadOnly()) return;
- ResourceSyncInfo info = getSyncInfo();
- if (info == null || info.isAdded()) return;
+ byte[] syncBytes = getSyncBytes();
+ if (syncBytes == null || ResourceSyncInfo.isAddition(syncBytes)) return;
// convert the notifications to internal form
char[] internalFormat;
@@ -332,7 +332,7 @@ public class EclipseFile extends EclipseResource implements ICVSFile {
// Only record the base if the file is not modified
if (!isModified()) {
EclipseSynchronizer.getInstance().copyFileToBaseDirectory(getIFile(), monitor);
- setBaserevInfo(new BaserevInfo(getName(), info.getRevision()));
+ setBaserevInfo(new BaserevInfo(getName(), ResourceSyncInfo.getRevision(syncBytes)));
}
// allow editing
@@ -550,12 +550,6 @@ public class EclipseFile extends EclipseResource implements ICVSFile {
}
/**
- * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getSyncBytes()
- */
- public byte[] getSyncBytes() throws CVSException {
- return EclipseSynchronizer.getInstance().getSyncBytes(getIFile());
- }
- /**
* @see org.eclipse.team.internal.ccvs.core.ICVSFile#setSyncBytes(byte[])
*/
public void setSyncBytes(byte[] syncBytes) throws CVSException {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
index 0a3ea0a55..5ee0a8bb0 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseResource.java
@@ -178,14 +178,14 @@ abstract class EclipseResource implements ICVSResource, Comparable {
* @see ICVSResource#isManaged()
*/
public boolean isManaged() throws CVSException {
- return isManaged(getSyncInfo());
+ return isManaged(getSyncBytes());
}
/*
* Helper method that captures the sematics of isManaged given a ResourceSyncInfo
*/
- public boolean isManaged(ResourceSyncInfo info) {
- return info != null;
+ public boolean isManaged(byte[] syncBytes) {
+ return syncBytes != null;
}
/**
@@ -214,7 +214,14 @@ abstract class EclipseResource implements ICVSResource, Comparable {
public boolean isFolder() {
return false;
}
-
+
+ /*
+ * @see org.eclipse.team.internal.ccvs.core.ICVSFile#getSyncBytes()
+ */
+ public byte[] getSyncBytes() throws CVSException {
+ return EclipseSynchronizer.getInstance().getSyncBytes(getIResource());
+ }
+
/*
* @see ICVSResource#getSyncInfo()
*/
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
index a01b31c9e..bc8957e7e 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java
@@ -479,8 +479,10 @@ public class EclipseSynchronizer {
if (resource.getType() == IResource.FILE) {
byte[] syncBytes = getSyncBytes(resource);
if (syncBytes != null) {
- syncBytes = convertToDeletion(syncBytes);
- synchronizerCache.setCachedSyncBytes(resource, syncBytes);
+ if (!ResourceSyncInfo.isAddition(syncBytes)) {
+ syncBytes = convertToDeletion(syncBytes);
+ synchronizerCache.setCachedSyncBytes(resource, syncBytes);
+ }
changedResources.add(resource);
}
} else {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
index be6eb7126..61d4c1032 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
@@ -81,12 +81,12 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
* even if the resource does exists remotely (e.g. created by another party).
*/
public static RemoteFile getBase(RemoteFolder parent, ICVSFile managed) throws CVSException {
- ResourceSyncInfo info = managed.getSyncInfo();
- if ((info == null) || info.isAdded()) {
+ byte[] syncBytes = managed.getSyncBytes();
+ if ((syncBytes == null) || ResourceSyncInfo.isAddition(syncBytes)) {
// Either the file is unmanaged or has just been added (i.e. doesn't necessarily have a remote)
return null;
}
- RemoteFile file = new RemoteFile(parent, managed.getSyncInfo());
+ RemoteFile file = new RemoteFile(parent, syncBytes);
parent.setChildren(new ICVSRemoteResource[] {file});
return file;
}
@@ -108,14 +108,20 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
newInfo.setTag(tag);
info = newInfo;
}
-
- public RemoteFile(RemoteFolder parent, ResourceSyncInfo info) {
- this(parent, Update.STATE_NONE, info);
+
+ public RemoteFile(RemoteFolder parent, byte[] syncBytes) {
+ this(parent, Update.STATE_NONE, syncBytes);
}
- public RemoteFile(RemoteFolder parent, int workspaceSyncState, ResourceSyncInfo newInfo) {
+ public RemoteFile(RemoteFolder parent, int workspaceSyncState, byte[] syncBytes) {
this.parent = parent;
- info = newInfo;
+ if (syncBytes == null)
+ info = null;
+ else
+ try {
+ info = new ResourceSyncInfo(syncBytes);
+ } catch (CVSException e) {
+ }
setWorkspaceSyncState(workspaceSyncState);
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
index db7539de2..f7a0a7c65 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java
@@ -38,7 +38,6 @@ import org.eclipse.team.internal.ccvs.core.client.listeners.UpdateListener;
import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Util;
@@ -280,10 +279,11 @@ public class RemoteFolderTreeBuilder {
if (deltas == null || deltas.isEmpty()) {
// If the file is an addition, return null as the remote
// Note: If there was a conflicting addition, the delta would not be empty
- if ( ! file.isManaged() || file.getSyncInfo().isAdded()) {
+ byte[] syncBytes = file.getSyncBytes();
+ if ( syncBytes == null || ResourceSyncInfo.isAddition(syncBytes)) {
return null;
}
- remoteFile = new RemoteFile(remoteRoot, file.getSyncInfo());
+ remoteFile = new RemoteFile(remoteRoot, syncBytes);
} else {
DeltaNode d = (DeltaNode)deltas.get(file.getName());
if (d.getRevision() == DELETED) {
@@ -344,20 +344,18 @@ public class RemoteFolderTreeBuilder {
ICVSResource[] files = local.members(ICVSFolder.FILE_MEMBERS);
for (int i=0;i<files.length;i++) {
ICVSFile file = (ICVSFile)files[i];
- ResourceSyncInfo info = file.getSyncInfo();
+ byte[] syncBytes = file.getSyncBytes();
// if there is no sync info then there is no base
- if (info==null)
+ if (syncBytes==null)
continue;
// There is no remote if the file was added
- if (info.isAdded())
+ if (ResourceSyncInfo.isAddition(syncBytes))
continue;
// If the file was deleted locally, we need to generate a new sync info without the delete flag
- if (info.isDeleted()) {
- MutableResourceSyncInfo undeletedInfo = info.cloneMutable();
- undeletedInfo.setDeleted(false);
- info = undeletedInfo;
+ if (ResourceSyncInfo.isDeletion(syncBytes)) {
+ syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes);
}
- children.add(new RemoteFile(remote, info));
+ children.add(new RemoteFile(remote, syncBytes));
monitor.worked(1);
}
@@ -414,20 +412,20 @@ public class RemoteFolderTreeBuilder {
ICVSFile file = (ICVSFile)files[i];
DeltaNode d = (DeltaNode)deltas.get(file.getName());
- ResourceSyncInfo info = file.getSyncInfo();
+ byte[] syncBytes = file.getSyncBytes();
// if there is no sync info then there isn't a remote file for this local file on the
// server.
- if (info==null)
+ if (syncBytes==null)
continue;
// There is no remote if the file was added and we didn't get a conflict (C) indicator from the server
- if (info.isAdded() && d==null)
+ if (ResourceSyncInfo.isAddition(syncBytes) && d==null)
continue;
// There is no remote if the file was deleted and we didn;t get a remove (R) indicator from the server
- if (info.isDeleted() && d==null)
+ if (ResourceSyncInfo.isDeletion(syncBytes) && d==null)
continue;
int type = d==null ? Update.STATE_NONE : d.getSyncState();
- children.put(file.getName(), new RemoteFile(remote, type, info));
+ children.put(file.getName(), new RemoteFile(remote, type, syncBytes));
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java
index 9ef0ebc62..a9e3bbb73 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java
@@ -551,6 +551,49 @@ public class ResourceSyncInfo {
}
/**
+ * Method getKeywordMode.
+ * @param syncBytes
+ * @return String
+ */
+ public static KSubstOption getKeywordMode(byte[] syncBytes) throws CVSException {
+ String mode = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 4, false);
+ if (mode == null) {
+ throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes)));
+ }
+ return KSubstOption.fromMode(mode);
+ }
+
+ /**
+ * Method getKeywordMode.
+ * @param syncBytes
+ * @return String
+ */
+ public static byte[] setKeywordMode(byte[] syncBytes, KSubstOption mode) throws CVSException {
+ return setKeywordMode(syncBytes, mode.toMode().getBytes());
+ }
+
+ /**
+ * Method getKeywordMode.
+ * @param syncBytes
+ * @return String
+ */
+ public static byte[] setKeywordMode(byte[] syncBytes, byte[] modeBytes) throws CVSException {
+ return setSlot(syncBytes, 4, modeBytes);
+ }
+
+ /**
+ * Return whether the provided syncBytes represent a binary file.
+ * @param syncBytes
+ * @return boolean
+ * @throws CVSException
+ */
+ public static boolean isBinary(byte[] syncBytes) throws CVSException {
+ // todo: can be optimized
+ if (syncBytes == null) return false;
+ return getKeywordMode(syncBytes).isBinary();
+ }
+
+ /**
* Method isFolder.
* @param syncBytes
* @return boolean
@@ -558,13 +601,39 @@ public class ResourceSyncInfo {
public static boolean isFolder(byte[] syncBytes) {
return syncBytes.length > 0 && syncBytes[0] == 'D';
}
+
+ /**
+ * Method isAddition.
+ * @param syncBytes
+ * @return boolean
+ */
+ public static boolean isAddition(byte[] syncBytes) throws CVSException {
+ int start = startOfSlot(syncBytes, 2);
+ if (start == -1 || start >= syncBytes.length) {
+ throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes)));
+ }
+ return syncBytes[start + 1] == '0';
+ }
/**
+ * Method isDeleted.
+ * @param syncBytes
+ * @return boolean
+ */
+ public static boolean isDeletion(byte[] syncBytes) throws CVSException {
+ int start = startOfSlot(syncBytes, 2);
+ if (start == -1 || start >= syncBytes.length) {
+ throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes)));
+ }
+ return syncBytes[start + 1] == DELETED_PREFIX_BYTE;
+ }
+
+ /**
* Method convertToDeletion.
* @param syncBytes
* @return byte[]
*/
- public static byte[] convertToDeletion(byte[] syncBytes) throws CVSException {
+ public static byte[] convertToDeletion(byte[] syncBytes) throws CVSException {
int index = startOfSlot(syncBytes, 2);
if (index == -1) {
throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes)));
@@ -574,6 +643,7 @@ public class ResourceSyncInfo {
System.arraycopy(syncBytes, 0, newSyncBytes, 0, index + 1);
newSyncBytes[index + 1] = DELETED_PREFIX_BYTE;
System.arraycopy(syncBytes, index + 1, newSyncBytes, index + 2, syncBytes.length - index - 1);
+ return newSyncBytes;
}
return syncBytes;
}
@@ -592,6 +662,7 @@ public class ResourceSyncInfo {
byte[] newSyncBytes = new byte[syncBytes.length - 1];
System.arraycopy(syncBytes, 0, newSyncBytes, 0, index + 1);
System.arraycopy(syncBytes, index + 2, newSyncBytes, index + 1, newSyncBytes.length - index - 1);
+ return newSyncBytes;
}
return syncBytes;
}
@@ -615,4 +686,161 @@ public class ResourceSyncInfo {
}
return -1;
}
+
+ /**
+ * Method setSlot.
+ * @param syncBytes
+ * @param i
+ * @param b
+ * @return byte[]
+ */
+ private static byte[] setSlot(byte[] syncBytes, int slot, byte[] newBytes) throws CVSException {
+ int start = startOfSlot(syncBytes, slot);
+ if (start == -1) {
+ throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes)));
+ }
+ int end = startOfSlot(syncBytes, slot + 1);
+ int totalLength = start + 1 + newBytes.length;
+ if (end != -1) {
+ totalLength += syncBytes.length - end;
+ }
+ byte[] result = new byte[totalLength];
+ System.arraycopy(syncBytes, 0, result, 0, start + 1);
+ System.arraycopy(newBytes, 0, result, start + 1, newBytes.length);
+ if (end != -1) {
+ System.arraycopy(syncBytes, end, result, start + 1 + newBytes.length, syncBytes.length - end);
+ }
+ return result;
+ }
+
+ /**
+ * Return the timestamp portion of the sync info that is to be sent to the
+ * server.
+ *
+ * @param syncBytes
+ * @param fileTimestamp
+ * @return String
+ */
+ public static String getTimestampToServer(byte[] syncBytes, Date fileTimestamp) {
+ if(fileTimestamp != null) {
+ String syncTimestamp = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 3, false);
+ int syncType = getSyncType(syncTimestamp);
+ if (syncType == TYPE_MERGED_WITH_CONFLICTS && fileTimestamp.equals(getTimestamp(syncTimestamp))) {
+ return TIMESTAMP_SERVER_MERGED_WITH_CONFLICT;
+ } else {
+ return TIMESTAMP_SERVER_MERGED;
+ }
+ }
+ return null;
+ }
+ /**
+ * Method getTimestamp.
+ * @param syncTimestamp
+ * @return Object
+ */
+ private static Date getTimestamp(String syncTimestamp) {
+ String dateString= syncTimestamp;
+ if(syncTimestamp.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED) != -1) {
+ dateString = null;
+ } else if(syncTimestamp.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED_WITH_CONFLICT) != -1) {
+ dateString = null;
+ } else if(syncTimestamp.indexOf(TIMESTAMP_MERGED_WITH_CONFLICT)!=-1) {
+ dateString = syncTimestamp.substring(syncTimestamp.indexOf("+") + 1); //$NON-NLS-1$
+ } else if(syncTimestamp.indexOf(TIMESTAMP_MERGED)!=-1) {
+ dateString = null;
+ }
+
+ if(dateString==null || "".equals(dateString)) { //$NON-NLS-1$
+ return null;
+ } else {
+ try {
+ return CVSDateFormatter.entryLineToDate(dateString);
+ } catch(ParseException e) {
+ // something we don't understand, just make this sync have no timestamp and
+ // never be in sync with the server.
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Method getSyncType.
+ * @param syncTimestamp
+ * @return int
+ */
+ private static int getSyncType(String date) {
+ if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED) != -1) {
+ return TYPE_MERGED;
+ } else if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED_WITH_CONFLICT) != -1) {
+ return TYPE_MERGED_WITH_CONFLICTS;
+ } else if(date.indexOf(TIMESTAMP_MERGED_WITH_CONFLICT)!=-1) {
+ return TYPE_MERGED_WITH_CONFLICTS;
+ } else if(date.indexOf(TIMESTAMP_MERGED)!=-1) {
+ return TYPE_MERGED;
+ }
+ return TYPE_REGULAR;
+ }
+
+ /**
+ * Method getTag.
+ * @param syncBytes
+ * @return String
+ */
+ public static byte[] getTagBytes(byte[] syncBytes) throws CVSException {
+ byte[] tag = Util.getBytesForSlot(syncBytes, SEPARATOR_BYTE, 5, true);
+ if (tag == null) {
+ throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes)));
+ }
+ return tag;
+ }
+
+ /**
+ * Method setTag.
+ * @param syncBytes
+ * @param tagString
+ * @return byte[]
+ */
+ public static byte[] setTag(byte[] syncBytes, byte[] tagBytes) throws CVSException {
+ return setSlot(syncBytes, 5, tagBytes);
+ }
+
+ /**
+ * Method setTag.
+ * @param syncBytes
+ * @param tag
+ * @return ResourceSyncInfo
+ */
+ public static byte[] setTag(byte[] syncBytes, CVSTag tag) throws CVSException {
+ CVSEntryLineTag entryTag;
+ if (tag instanceof CVSEntryLineTag) {
+ entryTag = (CVSEntryLineTag)tag;
+ } else {
+ entryTag = new CVSEntryLineTag(tag);
+ }
+ return setTag(syncBytes, entryTag.toEntryLineFormat(true).getBytes());
+ }
+
+ /**
+ * Method getRevision.
+ * @param syncBytes
+ */
+ public static String getRevision(byte[] syncBytes) throws CVSException {
+ String revision = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 2, false);
+ if (revision == null) {
+ throw new CVSException(Policy.bind("ResourceSyncInfo.malformedSyncBytes", new String(syncBytes)));
+ }
+ return revision;
+ }
+
+ /**
+ * Method isMerge.
+ * @param syncBytes1
+ * @return boolean
+ */
+ public static boolean isMerge(byte[] syncBytes) {
+ String timestamp = Util.getSubstring(syncBytes, SEPARATOR_BYTE, 3, false);
+ int syncType = getSyncType(timestamp);
+ return syncType == TYPE_MERGED || syncType == TYPE_MERGED_WITH_CONFLICTS;
+ }
+
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AddDeleteMoveListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AddDeleteMoveListener.java
index d8212ad55..abcb78362 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AddDeleteMoveListener.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/AddDeleteMoveListener.java
@@ -35,7 +35,6 @@ import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
import org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
/**
@@ -124,14 +123,12 @@ public class AddDeleteMoveListener implements IResourceDeltaVisitor, IResourceCh
private void handleDeletedFile(IFile resource) {
try {
ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
- if (mFile.isManaged()) {
- ResourceSyncInfo info = mFile.getSyncInfo();
- if (info.isAdded()) {
+ byte[] syncBytes = mFile.getSyncBytes();
+ if (syncBytes != null) {
+ if (ResourceSyncInfo.isAddition(syncBytes)) {
mFile.unmanage(null);
- } else if ( ! info.isDeleted()) {
- MutableResourceSyncInfo deletedInfo = info.cloneMutable();
- deletedInfo.setDeleted(true);
- mFile.setSyncInfo(deletedInfo);
+ } else if ( ! ResourceSyncInfo.isDeletion(syncBytes)) {
+ mFile.setSyncBytes(ResourceSyncInfo.convertToDeletion(syncBytes));
}
}
} catch (CVSException e) {
@@ -147,20 +144,18 @@ public class AddDeleteMoveListener implements IResourceDeltaVisitor, IResourceCh
try {
CVSProviderPlugin.getPlugin().getFileModificationManager().created(resource);
ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
- if (mFile.isManaged()) {
- ResourceSyncInfo info = mFile.getSyncInfo();
- if (info.isDeleted()) {
+ byte[] syncBytes = mFile.getSyncBytes();
+ if (syncBytes != null) {
+ if (ResourceSyncInfo.isDeletion(syncBytes)) {
// Handle a replaced deletion
- MutableResourceSyncInfo undeletedInfo = info.cloneMutable();
- undeletedInfo.setDeleted(false);
- mFile.setSyncInfo(undeletedInfo);
+ mFile.setSyncBytes(ResourceSyncInfo.convertFromDeletion(syncBytes));
try {
IMarker marker = getDeletionMarker(resource);
if (marker != null) marker.delete();
} catch (CoreException e) {
CVSProviderPlugin.log(e.getStatus());
}
- } else if (info.isDirectory()) {
+ } else if (ResourceSyncInfo.isFolder(syncBytes)) {
// This is a gender change against the server!
// We will allow it but the user will get an error if they try to commit
mFile.unmanage(null);
@@ -267,7 +262,8 @@ public class AddDeleteMoveListener implements IResourceDeltaVisitor, IResourceCh
root.accept(new ICVSResourceVisitor() {
public void visitFile(ICVSFile file) throws CVSException {
if (file.getParent().isCVSFolder()) {
- if (file.isManaged() && file.getSyncInfo().isDeleted()) {
+ byte[] syncBytes = file.getSyncBytes();
+ if (syncBytes != null && ResourceSyncInfo.isDeletion(syncBytes)) {
createDeleteMarker(project.getFile(file.getRelativePath(root)));
} else if ( ! file.isManaged() && ! file.isIgnored()) {
createAdditonMarker(project.getFile(file.getRelativePath(root)));
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java
index bbd539ea3..21dec2555 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/PrepareForReplaceVisitor.java
@@ -40,16 +40,16 @@ public class PrepareForReplaceVisitor implements ICVSResourceVisitor {
* @see ICVSResourceVisitor#visitFile(ICVSFile)
*/
public void visitFile(ICVSFile file) throws CVSException {
- ResourceSyncInfo info = file.getSyncInfo();
- if (info == null) {
+ byte[] syncBytes = file.getSyncBytes();
+ if (syncBytes == null) {
// Delete unmanaged files if the user wants them deleted
if (CVSProviderPlugin.getPlugin().isReplaceUnmanaged()) {
file.delete();
}
- } else if (info.isAdded()) {
+ } else if (ResourceSyncInfo.isAddition(syncBytes)) {
file.delete();
file.unmanage(null);
- } else if (info.isDeleted()) {
+ } else if (ResourceSyncInfo.isDeletion(syncBytes)) {
// If deleted, null the sync info so the file will be refetched
file.unmanage(null);
} else if (file.isModified()) {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java
index cdd0eaf85..cab58ac22 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ReplaceWithBaseVisitor.java
@@ -28,7 +28,6 @@ import org.eclipse.team.internal.ccvs.core.client.Update;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
public class ReplaceWithBaseVisitor implements ICVSResourceVisitor {
@@ -40,23 +39,22 @@ public class ReplaceWithBaseVisitor implements ICVSResourceVisitor {
* @see ICVSResourceVisitor#visitFile(ICVSFile)
*/
public void visitFile(final ICVSFile file) throws CVSException {
- ResourceSyncInfo info = file.getSyncInfo();
- if (info == null) {
+ byte[] syncBytes = file.getSyncBytes();
+ if (syncBytes == null) {
// Delete unmanaged files if the user wants them deleted
if (CVSProviderPlugin.getPlugin().isReplaceUnmanaged()) {
file.delete();
}
- } else if (info.isAdded()) {
+ } else if (ResourceSyncInfo.isAddition(syncBytes)) {
file.delete();
file.unmanage(null);
} else {
- CVSTag tag = info.getTag();
+ byte[] tagBytes = ResourceSyncInfo.getTagBytes(syncBytes);
boolean isModified = file.isModified();
- if (info.isDeleted()) {
+ if (ResourceSyncInfo.isDeletion(syncBytes)) {
// If deleted, null the sync info so the file will be refetched
- MutableResourceSyncInfo mutable = info.cloneMutable();
- mutable.setDeleted(false);
- file.setSyncInfo(mutable);
+ syncBytes = ResourceSyncInfo.convertFromDeletion(syncBytes);
+ file.setSyncBytes(syncBytes);
isModified = true;
}
// Fetch the file from the server
@@ -72,10 +70,9 @@ public class ReplaceWithBaseVisitor implements ICVSResourceVisitor {
}, Policy.subMonitorFor(monitor, 1));
// Set the tag to be the original tag
- info = file.getSyncInfo();
- MutableResourceSyncInfo mutable = info.cloneMutable();
- mutable.setTag(tag);
- file.setSyncInfo(mutable);
+ syncBytes = file.getSyncBytes();
+ syncBytes = ResourceSyncInfo.setTag(syncBytes, tagBytes);
+ file.setSyncBytes(syncBytes);
}
}
monitor.worked(1);
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
index a5e757b5e..ad943667e 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
@@ -241,15 +241,67 @@ public class Util {
return (String[]) result.toArray(new String[result.size()]);
}
+ /**
+ * Return the substring at the given index (starting at 0) where each
+ * element is delimited by the provided delimiter.
+ *
+ * @param bytes
+ * @param delimiter
+ * @param index
+ * @param includeRest
+ * @return String
+ */
public static String getSubstring(byte[] bytes, byte delimiter, int index, boolean includeRest) {
- String string = new String(bytes);
- int start = 0;
- for (int i = 0; i < index; i++) {
- start = string.indexOf(delimiter, start);
+ return new String(getBytesForSlot(bytes, delimiter, index, includeRest));
+ }
+
+ /**
+ * Return the offset the the Nth delimeter from the given start index.
+ * @param bytes
+ * @param delimiter
+ * @param start
+ * @param n
+ * @return int
+ */
+ public static int getOffsetOfDelimeter(byte[] bytes, byte delimiter, int start, int n) {
+ int count = 0;
+ for (int i = start; i < bytes.length; i++) {
+ if (bytes[i] == delimiter) count++;
+ if (count == n) return i;
+ }
+ // the Nth delimeter was not found
+ return -1;
+ }
+
+ /**
+ * Method getBytesForSlot.
+ * @param syncBytes
+ * @param SEPARATOR_BYTE
+ * @param i
+ * @param b
+ * @return byte[]
+ */
+ public static byte[] getBytesForSlot(byte[] bytes, byte delimiter, int index, boolean includeRest) {
+ // Find the starting index
+ int start;
+ if (index == 0) {
+ // make start -1 so that end determination will start at offset 0.
+ start = -1;
+ } else {
+ start = getOffsetOfDelimeter(bytes, delimiter, 0, index);
if (start == -1) return null;
}
- int end = string.indexOf(delimiter, start + 1);
- if (end == -1 || includeRest) return string.substring(start + 1);
- return string.substring(start + 1, end);
+ // Find the ending index
+ int end = getOffsetOfDelimeter(bytes, delimiter, start + 1, 1);
+ // Calculate the length
+ int length;
+ if (end == -1 || includeRest) {
+ length = bytes.length - start - 1;
+ } else {
+ length = end - start - 1;
+ }
+ byte[] result = new byte[length];
+ System.arraycopy(bytes, start + 1, result, 0, length);
+ return result;
}
} \ No newline at end of file

Back to the top