Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-02-27 11:35:13 -0500
committerJean Michel-Lemieux2002-02-27 11:35:13 -0500
commita09db77517adf107cc5790a85b9441a0409d1989 (patch)
tree76589817c301117f550f42f2b5d029a621d5c210
parentb960655efbdd2631d47e669c8bc5e0bf59247ea7 (diff)
downloadeclipse.platform.team-a09db77517adf107cc5790a85b9441a0409d1989.tar.gz
eclipse.platform.team-a09db77517adf107cc5790a85b9441a0409d1989.tar.xz
eclipse.platform.team-a09db77517adf107cc5790a85b9441a0409d1989.zip
Bug 10150: conflicting files should not be allowed to be checked in
Bug 9972: load should show more than file name
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java13
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java1
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java57
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java23
7 files changed, 97 insertions, 8 deletions
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 6e912a846..7dd8544b6 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
@@ -113,7 +113,7 @@ abstract class AbstractStructureVisitor implements ICVSResourceVisitor {
// Send the file's entry line to the server
if (mFile.isManaged()) {
- session.sendEntry(mFile.getSyncInfo().getEntryLine(false));
+ session.sendEntry(mFile.getSyncInfo().getEntryLine(false, 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
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 1f0b7e2a4..722881b06 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
@@ -28,6 +28,7 @@ import org.eclipse.team.internal.ccvs.core.resources.LocalFile;
import org.eclipse.team.internal.ccvs.core.resources.LocalFolder;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.Assert;
+import org.eclipse.team.internal.ccvs.core.util.Util;
/**
* Maintains CVS communication state for the lifetime of a connection
@@ -529,7 +530,7 @@ public class Session {
public void sendFile(ICVSFile file, boolean isBinary, IProgressMonitor monitor)
throws CVSException {
// update progress monitor
- String title = Policy.bind("Session.sending", new Object[]{ file.getName() }); //$NON-NLS-1$
+ String title = Policy.bind("Session.sending", new Object[]{ Util.toTruncatedPath(file, localRoot, 3) }); //$NON-NLS-1$
monitor.subTask(Policy.bind("Session.transferNoSize", title)); //$NON-NLS-1$
// obtain an input stream for the file and its size
long size = file.getSize();
@@ -622,7 +623,7 @@ public class Session {
public void receiveFile(ICVSFile file, boolean isBinary, IProgressMonitor monitor)
throws CVSException {
// update progress monitor
- String title = Policy.bind("Session.receiving", new Object[]{ file.getName() }); //$NON-NLS-1$
+ String title = Policy.bind("Session.receiving", new Object[]{ Util.toTruncatedPath(file, localRoot, 3) }); //$NON-NLS-1$
monitor.subTask(Policy.bind("Session.transferNoSize", title)); //$NON-NLS-1$
// get the file size from the server
long size;
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java
index 5269bf7c1..7dbf2f89e 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java
@@ -87,7 +87,18 @@ class UpdatedHandler extends ResponseHandler {
if (updateResponse) {
timestamp = mFile.getTimeStamp();
} else {
- timestamp = ResourceSyncInfo.RESULT_OF_MERGE + mFile.getTimeStamp();
+ // This is to handle the Merged response. The server will send a timestamp of "+=" if
+ // the file was merged with conflicts. The '+' indicates that there are conflicts and the
+ // '=' indicate that the timestamp for the file should be used. If the merge does not
+ // have conflicts, simply add a text only timestamp and the file will be regarded as
+ // having outgoing changes.
+ // The purpose for having the two different timestamp options for merges is to
+ // dissallow commit of files that have conflicts until they have been manually edited.
+ if(entryLine.indexOf(ResourceSyncInfo.MERGE_UNMODIFIED) != -1) {
+ timestamp = ResourceSyncInfo.RESULT_OF_MERGE_CONFLICT + mFile.getTimeStamp();
+ } else {
+ timestamp = ResourceSyncInfo.RESULT_OF_MERGE;
+ }
}
mFile.setSyncInfo(new ResourceSyncInfo(entryLine, permissionsLine, timestamp));
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
index 4b19bec6d..3875ee244 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/messages.properties
@@ -92,8 +92,8 @@ RemoteFile.noContentsReceived=No contents received from server for {0}
Session.readError=Read finished prematurely
Session.badInt="Malformed file transmission received"
-Session.receiving=Receiving file {0}
-Session.sending=Sending file {0}
+Session.receiving=Receiving file: {0}
+Session.sending=Sending file: {0}
Session.transfer={0} ({1}K of {2}K bytes)
Session.transferNoSize={0}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
index 2c9bca629..ce8c55128 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalFile.java
@@ -88,7 +88,6 @@ public class LocalFile extends LocalResource implements ICVSFile {
}
public boolean isDirty() throws CVSException {
- // XXX Is the below correct for isDirty?
if (!exists() || !isManaged()) {
return true;
} else {
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 f7aca5223..5d8b02370 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
@@ -37,7 +37,10 @@ public class ResourceSyncInfo {
// Timestamp constants used to identify special cases
public static final String DUMMY_TIMESTAMP = "dummy timestamp"; //$NON-NLS-1$
- public static final String RESULT_OF_MERGE = "Result of merge+"; //$NON-NLS-1$
+ public static final String RESULT_OF_MERGE = "Result of merge"; //$NON-NLS-1$
+ public static final String RESULT_OF_MERGE_CONFLICT = RESULT_OF_MERGE + "+"; //$NON-NLS-1$
+ public static final String MERGE_MODIFIED = "+modified"; //$NON-NLS-1$
+ public static final String MERGE_UNMODIFIED = "+="; //$NON-NLS-1$
// safe default permissions. Permissions are saved separatly so that the correct permissions
// can be sent back to the server on systems that don't save execute bits (e.g. windows).
@@ -133,6 +136,33 @@ public class ResourceSyncInfo {
}
/**
+ * Answers if this sync information is for a resource that has been merged by the cvs server with
+ * conflicts.
+ *
+ * @return <code>true</code> if the sync information is for a file that has been merged and
+ * <code>false</code> for folders and for files that have not been merged.
+ */
+ public boolean isNeedsMerge(String fileTimestamp) {
+ if(timeStamp.indexOf(RESULT_OF_MERGE_CONFLICT) != -1) {
+ String t = timeStamp.substring(timeStamp.indexOf("+") + 1);
+ return t.equals(fileTimestamp);
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Answers if this sync information is for a resource that has been merged by the cvs server with
+ * conflicts.
+ *
+ * @return <code>true</code> if the sync information is for a file that has been merged and
+ * <code>false</code> for folders and for files that have not been merged.
+ */
+ public boolean isMerged() {
+ return timeStamp.indexOf(RESULT_OF_MERGE) != -1;
+ }
+
+ /**
* Answers if this sync information is for a file that has been added but not comitted
* to the CVS repository yet.
*
@@ -203,6 +233,31 @@ public class ResourceSyncInfo {
}
/**
+ * Same as <code>getEntryLine</code> except it considers merged files in entry line format. This is only
+ * valid for sending the file to the server.
+ *
+ * @param includeTimeStamp determines if the timestamp will be included in the returned entry line. In
+ * some usages the timestamp should not be included in entry lines, for example when sending the entries
+ * to the server.
+ * @param isModified is the resource associated with this sync info modified.
+ *
+ * @return a file or folder entry line reflecting the state of this sync object.
+ */
+ public String getEntryLine(boolean includeTimeStamp, String fileTimestamp) {
+ String serverTimestamp;
+ if(isMerged()) {
+ if(isNeedsMerge(fileTimestamp)) {
+ serverTimestamp = MERGE_UNMODIFIED;
+ } else {
+ serverTimestamp = MERGE_MODIFIED;
+ }
+ return new ResourceSyncInfo(getName(), getRevision(), serverTimestamp, getKeywordMode(), getTag(), getPermissions()).getEntryLine(true);
+ } else {
+ return getEntryLine(includeTimeStamp);
+ }
+ }
+
+ /**
* Anwsers the a compatible permissions line for files.
*
* @return a permission line for files and <code>null</code> if this sync object is
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 2775fe4cd..0be5cea3f 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
@@ -5,11 +5,15 @@ package org.eclipse.team.internal.ccvs.core.util;
* All Rights Reserved.
*/
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.client.Session;
+import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
import org.eclipse.team.internal.ccvs.core.Policy;
/**
@@ -284,4 +288,23 @@ public class Util {
public static void logError(String message, Throwable throwable) {
CVSProviderPlugin.log(new Status(IStatus.ERROR, CVSProviderPlugin.ID, IStatus.ERROR, message, throwable));
}
+
+ /**
+ * If the number of segments in the relative path of <code>resource</code> to <code>root</code> is
+ * greater than <code>split</code> then the returned path is truncated to <code>split</code> number
+ * of segments and '...' is shown as the first segment of the path.
+ */
+ public static String toTruncatedPath(ICVSResource resource, ICVSFolder root, int split) {
+ try {
+ IPath path = new Path(resource.getRelativePath(root));
+ int segments = path.segmentCount();
+ if(segments>split) {
+ IPath last = path.removeFirstSegments(segments - split);
+ return "..." + path.SEPARATOR + last.toString();
+ }
+ return path.toString();
+ } catch(CVSException e) {
+ return resource.getName();
+ }
+ }
} \ No newline at end of file

Back to the top