Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util')
-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
4 files changed, 85 insertions, 40 deletions
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