Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-03-25 17:50:07 -0500
committerJean Michel-Lemieux2002-03-25 17:50:07 -0500
commita1f2d5d77b3112282347f142729eee42be882037 (patch)
tree7c76d942fbd1c5a6f583c1a753f7f821ccc2db81
parent390f3d66563366b463a0d52cac0ef184a4b7fb3f (diff)
downloadeclipse.platform.team-a1f2d5d77b3112282347f142729eee42be882037.tar.gz
eclipse.platform.team-a1f2d5d77b3112282347f142729eee42be882037.tar.xz
eclipse.platform.team-a1f2d5d77b3112282347f142729eee42be882037.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.cvs.core/.options10
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java11
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java14
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/DiffStructureVisitor.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/TagFileSender.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdatedHandler.java30
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/AdminKSubstListener.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/connection/Connection.java9
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java59
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java23
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java50
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java9
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfo.java183
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfoMap.java88
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java55
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/EntryFileDateFormat.java42
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaSyncHandler.java10
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaVisitor.java10
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ServerDateFormat.java49
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java268
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.xml11
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java5
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java2
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java37
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java2
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java88
32 files changed, 603 insertions, 501 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/.options b/bundles/org.eclipse.team.cvs.core/.options
new file mode 100644
index 000000000..8f79af6a9
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/.options
@@ -0,0 +1,10 @@
+# Debugging options for the org.eclipse.team.cvs.core plugin.
+
+# Turn on debugging for the plugin.
+org.eclipse.team.cvs.core/debug=true
+
+# Shows when meta-files are modified by a 3rd party
+org.eclipse.team.cvs.core/metafiles=true
+
+# Shows cvs client/server protocol
+org.eclipse.team.cvs.core/cvsprotocol=true \ No newline at end of file
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 bc427ea6d..fd59319d9 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
@@ -118,7 +118,7 @@ public class CVSTeamProvider extends RepositoryProvider {
// we no longer need the sync info cached. This does not affect the actual CVS
// meta directories on disk, and will remain unless a client calls unmanage().
try {
- EclipseSynchronizer.getInstance().flush(getProject(), true, null);
+ EclipseSynchronizer.getInstance().flush(getProject(), true, IResource.DEPTH_INFINITE, null);
} catch(CVSException e) {
throw new CoreException(e.getStatus());
}
@@ -701,7 +701,7 @@ public class CVSTeamProvider extends RepositoryProvider {
monitor.subTask(Policy.bind("CVSTeamProvider.updatingFile", info.getName())); //$NON-NLS-1$
file.setSyncInfo(new ResourceSyncInfo(info.getName(),
(info.isDeleted() ? info.DELETED_PREFIX : "") + info.getRevision(), //$NON-NLS-1$
- info.getTimeStamp(), info.getKeywordMode(), tag, info.getPermissions()));
+ info.getTimeStamp(), info.getKeywordMode(), tag, info.getPermissions(), info.getType()));
}
};
public void visitFolder(ICVSFolder folder) throws CVSException {
@@ -1028,7 +1028,7 @@ public class CVSTeamProvider extends RepositoryProvider {
if (info.isAdded()) {
ResourceSyncInfo newInfo = new ResourceSyncInfo(
info.getName(), info.getRevision(), info.getTimeStamp(), toKSubst.toMode(),
- info.getTag(), info.getPermissions());
+ info.getTag(), info.getPermissions(), info.getType());
mFile.setSyncInfo(newInfo);
continue;
}
@@ -1177,7 +1177,7 @@ public class CVSTeamProvider extends RepositoryProvider {
*/
private static void makeDirty(IFile file) throws CVSException {
ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor(file);
- mFile.setTimeStamp(null);
+ mFile.setTimeStamp(ICVSFile.NULL_TIMESTAMP);
}
/*
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
index ec87121e4..494371c78 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
@@ -27,6 +27,7 @@ public interface ICVSFile extends ICVSResource {
public static final int UPDATE_EXISTING = 3;
public static final int CREATED = 4;
+ public static final long NULL_TIMESTAMP = 0;
/**
* Answers the size of the file.
@@ -40,12 +41,6 @@ public interface ICVSFile extends ICVSResource {
InputStream getInputStream() throws CVSException;
/**
- * Gets an appending output stream for writing to the file.
- * It is the responsibility of the caller to close the stream when finished.
- */
- OutputStream getAppendingOutputStream() throws CVSException;
-
- /**
* Set the contents of the file to the contents of the provided input stream
*
* @param responseType the type of reponse that was received from the server
@@ -81,7 +76,7 @@ public interface ICVSFile extends ICVSResource {
*
* @throws CVSFileNotFoundException if exists() = false
*/
- String getTimeStamp();
+ long getTimeStamp();
/**
* Sets the current timestamp for this file. The supplied date must be in the
@@ -92,7 +87,7 @@ public interface ICVSFile extends ICVSResource {
* If the date is <code>null</code> then the current time is used as
* the timestamp.
*/
- void setTimeStamp(String date) throws CVSException;
+ void setTimeStamp(long date) throws CVSException;
/**
* Answers <code>true</code> if the file differs from its base. If the file has no
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java
index 8ca4bc5b2..65f842127 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/Policy.java
@@ -12,11 +12,25 @@ import java.util.ResourceBundle;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.util.InfiniteSubProgressMonitor;
public class Policy {
protected static ResourceBundle bundle = null;
+
+ //debug constants
+ public static boolean DEBUG_METAFILE_CHANGES = false;
+ public static boolean DEBUG_CVS_PROTOCOL = false;
+
+ static {
+ //init debug options
+ if (CVSProviderPlugin.getPlugin().isDebugging()) {
+ DEBUG_METAFILE_CHANGES = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/metafiles"));
+ DEBUG_CVS_PROTOCOL = "true".equalsIgnoreCase(Platform.getDebugOption(CVSProviderPlugin.ID + "/cvsprotocol"));
+ }
+ }
/**
* Creates a NLS catalog for the given locale.
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
index 9a7d0ced2..a86a18084 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java
@@ -60,10 +60,10 @@ class CheckedInHandler extends ResponseHandler {
ResourceSyncInfo newInfo;
if (changeFile) {
- newInfo = new ResourceSyncInfo(entryLine, null, ResourceSyncInfo.DUMMY_TIMESTAMP);
+ newInfo = new ResourceSyncInfo(entryLine, null, 0, ResourceSyncInfo.DUMMY_SYNC);
} else {
ResourceSyncInfo fileInfo = mFile.getSyncInfo();
- newInfo = new ResourceSyncInfo(entryLine, fileInfo.getPermissions(), mFile.getTimeStamp());
+ newInfo = new ResourceSyncInfo(entryLine, fileInfo.getPermissions(), mFile.getTimeStamp(), ResourceSyncInfo.REGULAR_SYNC);
}
mFile.setSyncInfo(newInfo);
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 4e7cadae3..1e13dd686 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
@@ -34,7 +34,7 @@ class DiffStructureVisitor extends FileStructureVisitor {
if (mFile.isManaged()) {
session.sendEntry(mFile.getSyncInfo().getEntryLine(false));
} else {
- ResourceSyncInfo info = new ResourceSyncInfo(mFile.getName(), ResourceSyncInfo.ADDED_REVISION, null, null, null, null);
+ ResourceSyncInfo info = new ResourceSyncInfo(mFile.getName(), ResourceSyncInfo.ADDED_REVISION, 0, null, null, null, ResourceSyncInfo.REGULAR_SYNC);
session.sendEntry(info.getEntryLine(false));
newFile = true;
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java
index de55d12c3..a4fda8c30 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/ModTimeHandler.java
@@ -6,12 +6,11 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import java.text.ParseException;
-import java.util.Date;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.Policy;
-import org.eclipse.team.internal.ccvs.core.util.ServerDateFormat;
+import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter;
/**
* Handles a "Mod-time" response from the CVS server.
@@ -28,7 +27,6 @@ import org.eclipse.team.internal.ccvs.core.util.ServerDateFormat;
* </p>
*/
class ModTimeHandler extends ResponseHandler {
- private static final ServerDateFormat dateFormatter = new ServerDateFormat();
public String getResponseID() {
return "Mod-time"; //$NON-NLS-1$
}
@@ -36,7 +34,7 @@ class ModTimeHandler extends ResponseHandler {
public void handle(Session session, String timeStamp,
IProgressMonitor monitor) throws CVSException {
try {
- session.setModTime(dateFormatter.toDate(timeStamp));
+ session.setModTime(CVSDateFormatter.serverStampToDate(timeStamp));
} catch (ParseException e) {
throw new CVSException(Policy.bind("ModTimeHandler.invalidFormat", timeStamp), e); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java
index 679dbb116..eb2c67af4 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/NewEntryHandler.java
@@ -39,10 +39,7 @@ public class NewEntryHandler extends ResponseHandler {
ICVSFile mFile = mParent.getFile(fileName);
ResourceSyncInfo fileInfo = mFile.getSyncInfo();
- ResourceSyncInfo newInfo = new ResourceSyncInfo(entryLine, fileInfo.getPermissions(), ResourceSyncInfo.DUMMY_TIMESTAMP);
+ ResourceSyncInfo newInfo = new ResourceSyncInfo(entryLine, fileInfo.getPermissions(), 0, ResourceSyncInfo.DUMMY_SYNC);
mFile.setSyncInfo(newInfo);
-
-
}
-
}
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 2394b9f13..224aad985 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
@@ -34,7 +34,7 @@ class TagFileSender extends FileStructureVisitor {
// Send the file if appropriate
ResourceSyncInfo info = mFile.getSyncInfo();
if (info.isDeleted()) {
- info = new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions());
+ info = new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions(), info.getType());
}
if (! info.isAdded()) {
session.sendEntry(info.getEntryLine(false, mFile.getTimeStamp()));
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 320b18a50..7ff598f8b 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
@@ -14,7 +14,7 @@ import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
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.EntryFileDateFormat;
+import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter;
/**
* Handles any "Updated" and "Merged" responses
@@ -49,7 +49,6 @@ class UpdatedHandler extends ResponseHandler {
protected static final int HANDLE_UPDATE_EXISTING = ICVSFile.UPDATE_EXISTING;
protected static final int HANDLE_CREATED = ICVSFile.CREATED;
- private static final EntryFileDateFormat dateFormatter = new EntryFileDateFormat();
private static final String READ_ONLY_FLAG = "u=rw"; //$NON-NLS-1$
public UpdatedHandler(int handlerType) {
@@ -72,7 +71,8 @@ class UpdatedHandler extends ResponseHandler {
String repositoryFile = session.readLine();
String entryLine = session.readLine();
String permissionsLine = session.readLine();
- ResourceSyncInfo info = new ResourceSyncInfo(entryLine, permissionsLine, null);
+ // temporary sync info for parsing the line received from the server
+ ResourceSyncInfo info = new ResourceSyncInfo(entryLine, permissionsLine, ResourceSyncInfo.NULL_TIMESTAMP, ResourceSyncInfo.REGULAR_SYNC);
// clear file update modifiers
Date modTime = session.getModTime();
@@ -92,26 +92,12 @@ class UpdatedHandler extends ResponseHandler {
if (readOnly) mFile.setReadOnly(true);
// Set the timestamp in the file, set the result in the fileInfo
- String timestamp = null;
- if (modTime != null) timestamp = dateFormatter.formatDate(modTime);
- mFile.setTimeStamp(timestamp);
- if (handlerType == HANDLE_MERGED) {
- // 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(info.getTimeStamp().indexOf(ResourceSyncInfo.MERGE_UNMODIFIED) != -1) {
- timestamp = ResourceSyncInfo.RESULT_OF_MERGE_CONFLICT + mFile.getTimeStamp();
- } else {
- timestamp = ResourceSyncInfo.RESULT_OF_MERGE;
- }
- } else {
- timestamp = mFile.getTimeStamp();
+ long timestamp = ICVSFile.NULL_TIMESTAMP;
+ if (modTime != null) {
+ timestamp = modTime.getTime();
}
+ mFile.setTimeStamp(timestamp);
mFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.getRevision(),
- timestamp, info.getKeywordMode(), info.getTag(), info.getPermissions()));
+ timestamp, info.getKeywordMode(), info.getTag(), info.getPermissions(), info.getType()));
}
} \ No newline at end of file
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 b8a9ebbe0..156f6e298 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
@@ -68,7 +68,7 @@ public class AdminKSubstListener implements ICommandOutputListener {
// only update sync info if we have it locally
ResourceSyncInfo newInfo = new ResourceSyncInfo(
info.getName(), info.getRevision(), info.getTimeStamp(),
- ksubstMode, info.getTag(), info.getPermissions());
+ ksubstMode, info.getTag(), info.getPermissions(), info.getType());
file.setSyncInfo(newInfo);
}
} catch (CVSException e) {
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 dab7ef206..d97ea7540 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
@@ -34,9 +34,6 @@ import org.eclipse.team.internal.ccvs.core.Policy;
* </ul>
*/
public class Connection {
- private static final boolean DEBUG =
- (System.getProperty("eclipse.cvs.debug") == null) ? false : //$NON-NLS-1$
- (new Boolean(System.getProperty("eclipse.cvs.debug")).booleanValue());//$NON-NLS-1$
private static final byte NEWLINE= 0xA;
private IServerConnection serverConnection;
@@ -147,7 +144,7 @@ public class Connection {
readLineBuffer = append(readLineBuffer, index++, (byte) r);
}
String result = new String(readLineBuffer, 0, index);
- if (DEBUG) System.out.println(result);
+ if (Policy.DEBUG_CVS_PROTOCOL) System.out.println(result);
return result;
} catch (IOException e) {
throw new CVSCommunicationException(e);
@@ -164,7 +161,7 @@ static String readLine(InputStream in) throws IOException {
buffer = append(buffer, index++, (byte) r);
}
String result = new String(buffer, 0, index);
- if (DEBUG)
+ if (Policy.DEBUG_CVS_PROTOCOL)
System.out.println(result);
return result;
}
@@ -217,7 +214,7 @@ static String readLine(InputStream in) throws IOException {
if (!isEstablished())
throw new CVSCommunicationException(Policy.bind("Connection.writeUnestablishedConnection"));//$NON-NLS-1$
- if (DEBUG)
+ if (Policy.DEBUG_CVS_PROTOCOL)
System.out.print(s + (newline ? "\n" : ""));//$NON-NLS-1$ //$NON-NLS-2$
try {
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 2b6d0a1fe..23816ee31 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
@@ -160,8 +160,8 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
// We could have an incoming change or deletion
if (remote == null) {
String mode = KSubstOption.fromPattern(local.getName()).toMode();
- info = new ResourceSyncInfo(local.getName(), ResourceSyncInfo.ADDED_REVISION, ResourceSyncInfo.DUMMY_TIMESTAMP,
- mode, local.getParent().getFolderSyncInfo().getTag(), null);
+ info = new ResourceSyncInfo(local.getName(), ResourceSyncInfo.ADDED_REVISION, ResourceSyncInfo.NULL_TIMESTAMP,
+ mode, local.getParent().getFolderSyncInfo().getTag(), null, ResourceSyncInfo.REGULAR_SYNC);
revision = info.getRevision();
} else {
info = remote.getSyncInfo();
@@ -206,7 +206,9 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
return;
}
}
- info = new ResourceSyncInfo(info.getName(), revision, ResourceSyncInfo.DUMMY_TIMESTAMP, info.getKeywordMode(), local.getParent().getFolderSyncInfo().getTag(), info.getPermissions());
+ info = new ResourceSyncInfo(info.getName(), revision, ResourceSyncInfo.NULL_TIMESTAMP,
+ info.getKeywordMode(), local.getParent().getFolderSyncInfo().getTag(),
+ info.getPermissions(), ResourceSyncInfo.DUMMY_SYNC);
local.setSyncInfo(info);
}
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 ab34864cd..351803327 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
@@ -5,13 +5,8 @@ package org.eclipse.team.internal.ccvs.core.resources;
* All Rights Reserved.
*/
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.ParseException;
import java.util.Date;
import org.eclipse.core.resources.IFile;
@@ -19,16 +14,13 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSResourceVisitor;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.EntryFileDateFormat;
/**
* Represents handles to CVS resource on the local file system. Synchronization
@@ -37,7 +29,6 @@ import org.eclipse.team.internal.ccvs.core.util.EntryFileDateFormat;
class EclipseFile extends EclipseResource implements ICVSFile {
private static final String TEMP_FILE_EXTENSION = ".tmp";//$NON-NLS-1$
-
private static final IPath PROJECT_META_DATA_PATH = new Path(".project");//$NON-NLS-1$
/**
@@ -71,52 +62,22 @@ class EclipseFile extends EclipseResource implements ICVSFile {
}
/*
- * @see ICVSFile#getAppendingOutputStream()
- */
- public OutputStream getAppendingOutputStream() throws CVSException {
- return new ByteArrayOutputStream() {
- public void close() throws IOException {
- try {
- IFile file = getIFile();
- if(resource.exists()) {
- file.appendContents(new ByteArrayInputStream(toByteArray()), false /*force*/, true /*keep history*/, null);
- } else {
- file.create(new ByteArrayInputStream(toByteArray()), false /*force*/, null);
- }
- } catch(CoreException e) {
- throw new IOException(Policy.bind("EclipseFile_Problem_appending_to_resource", e.getMessage(), e.getStatus().getMessage())); //$NON-NLS-1$ //$NON-NLS-2$
- } finally {
- super.close();
- }
- }
- };
- }
-
- /*
* @see ICVSFile#getTimeStamp()
*/
- public String getTimeStamp() {
- EntryFileDateFormat timestamp = new EntryFileDateFormat();
- return timestamp.format(new Date(getIOFile().lastModified()));
+ public long getTimeStamp() {
+ return getIOFile().lastModified();
}
/*
* @see ICVSFile#setTimeStamp(String)
*/
- public void setTimeStamp(String date) throws CVSException {
- long millSec;
- if (date==null) {
+ public void setTimeStamp(long date) throws CVSException {
+ long timestamp = date;
+ if (date==NULL_TIMESTAMP) {
// get the current time
- millSec = new Date().getTime();
- } else {
- try {
- EntryFileDateFormat timestamp = new EntryFileDateFormat();
- millSec = timestamp.toDate(date).getTime();
- } catch (ParseException e) {
- throw new CVSException(Policy.bind("LocalFile.invalidDateFormat", date), e); //$NON-NLS-1$
- }
- }
- getIOFile().setLastModified(millSec);
+ timestamp = new Date().getTime();
+ }
+ getIOFile().setLastModified(timestamp);
try {
// Needed for workaround to Platform Core Bug #
resource.refreshLocal(IResource.DEPTH_ZERO, null);
@@ -142,7 +103,7 @@ class EclipseFile extends EclipseResource implements ICVSFile {
ResourceSyncInfo info = getSyncInfo();
if (info.isAdded()) return false;
if (info.isDeleted()) return true;
- return !getTimeStamp().equals(info.getTimeStamp());
+ return getTimeStamp() != info.getTimeStamp();
}
}
@@ -154,7 +115,7 @@ class EclipseFile extends EclipseResource implements ICVSFile {
return true;
} else {
ResourceSyncInfo info = getSyncInfo();
- return !getTimeStamp().equals(info.getTimeStamp());
+ return getTimeStamp() != info.getTimeStamp();
}
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
index 261a812fa..3c40fca52 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFolder.java
@@ -115,6 +115,9 @@ class EclipseFolder extends EclipseResource implements ICVSFolder {
project.open(null);
} else {
((IFolder)resource).create(false /*don't force*/, true /*make local*/, null);
+ if(resource.getName().equals("CVS")) {
+ System.out.println("CVS fond and");
+ }
}
} catch (CoreException e) {
throw CVSException.wrapException(resource, Policy.bind("EclipseFolder_problem_creating", resource.getFullPath().toString(), e.getStatus().getMessage()), e); //$NON-NLS-1$
@@ -208,14 +211,18 @@ class EclipseFolder extends EclipseResource implements ICVSFolder {
*/
public void unmanage(IProgressMonitor monitor) throws CVSException {
monitor = Policy.monitorFor(monitor);
- monitor.beginTask("", 100);
- run(new ICVSRunnable() {
- public void run(IProgressMonitor monitor) throws CVSException {
- recursiveUnmanage((IContainer) resource, monitor);
- }
- }, Policy.subMonitorFor(monitor, 99));
- // unmanaged from parent
- super.unmanage(Policy.subMonitorFor(monitor, 1));
+ try {
+ monitor.beginTask("", 100);
+ run(new ICVSRunnable() {
+ public void run(IProgressMonitor monitor) throws CVSException {
+ recursiveUnmanage((IContainer) resource, monitor);
+ }
+ }, Policy.subMonitorFor(monitor, 99));
+ // unmanaged from parent
+ super.unmanage(Policy.subMonitorFor(monitor, 1));
+ } finally {
+ monitor.done();
+ }
}
private static void recursiveUnmanage(IContainer container, IProgressMonitor monitor) throws CVSException {
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 b419068f5..65e3e7eb0 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
@@ -23,7 +23,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.ccvs.core.ICVSFolder;
+import org.eclipse.team.ccvs.core.CVSTeamProvider;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
@@ -62,6 +62,7 @@ public class EclipseSynchronizer {
static public void startup() {
Assert.isTrue(instance==null);
instance = new EclipseSynchronizer();
+ SyncFileWriter.startup();
}
static public void shutdown() {
@@ -250,7 +251,7 @@ public class EclipseSynchronizer {
ignores = new String[] { pattern };
}
setCachedFolderIgnores(folder, ignores);
- SyncFileWriter.addCVSIgnoreEntries(CVSWorkspaceRoot.getCVSFolderFor(folder), ignores);
+ SyncFileWriter.addCVSIgnoreEntries(folder, ignores);
// broadcast changes to unmanaged children - they are the only candidates for being ignored
List possibleIgnores = new ArrayList();
accumulateNonManagedChildren(folder, possibleIgnores);
@@ -345,18 +346,29 @@ public class EclipseSynchronizer {
* @param purgeCache if true, purges the cache from memory as well
* @param monitor the progress monitor, may be null
*/
- public void flush(IContainer root, boolean purgeCache, IProgressMonitor monitor)
+ public void flush(IContainer root, boolean purgeCache, int depth, IProgressMonitor monitor)
throws CVSException {
// flush unwritten sync info to disk
if (nestingCount != 0) commitCache(monitor);
// purge from memory too if we were asked to
- if (purgeCache) purgeCache(root);
+ if (purgeCache) purgeCache(root, depth);
// prepare for the operation again if we cut the last one short
if (nestingCount != 0) prepareCache(monitor);
}
+ public void syncFilesChanged(IContainer[] roots) throws CVSException {
+ try {
+ for (int i = 0; i < roots.length; i++) {
+ flush(roots[i], true, IResource.DEPTH_ONE, null);
+ CVSProviderPlugin.broadcastResourceStateChanges(roots[i].members());
+ }
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
/**
* Prepares the cache for a series of operations.
*
@@ -396,12 +408,11 @@ public class EclipseSynchronizer {
FolderSyncInfo info = getCachedFolderSync(folder);
if (info == null) {
// deleted folder sync info since we loaded it
- SyncFileWriter.getCVSSubdirectory(CVSWorkspaceRoot.getCVSFolderFor(folder)).delete();
+ SyncFileWriter.deleteFolderSync(folder);
dirtyParents.remove(folder);
} else {
// modified or created new folder sync info since we loaded it
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder);
- SyncFileWriter.writeFolderSync(cvsFolder, info);
+ SyncFileWriter.writeFolderSync(folder, info);
}
}
Policy.checkCanceled(monitor);
@@ -417,8 +428,7 @@ public class EclipseSynchronizer {
if (folder.exists() && folder.getType() != IResource.ROOT) {
// write sync info for all children in one go
Collection infos = getCachedResourceSyncForChildren(folder);
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder);
- SyncFileWriter.writeAllResourceSync(cvsFolder,
+ SyncFileWriter.writeAllResourceSync(folder,
(ResourceSyncInfo[]) infos.toArray(new ResourceSyncInfo[infos.size()]));
}
Policy.checkCanceled(monitor);
@@ -431,7 +441,7 @@ public class EclipseSynchronizer {
new IResource[changedResources.size()]);
CVSProviderPlugin.broadcastResourceStateChanges(resources);
changedResources.clear();
- changedFolders.clear();
+ changedFolders.clear();
} finally {
monitor.done();
}
@@ -441,7 +451,7 @@ public class EclipseSynchronizer {
* Purges the cache recursively for all resources beneath the container.
* There must not be any pending uncommitted changes.
*/
- private static void purgeCache(IContainer container) throws CVSException {
+ private static void purgeCache(IContainer container, int depth) throws CVSException {
if (! container.exists()) return;
try {
if (container.getType() != IResource.ROOT) {
@@ -449,11 +459,13 @@ public class EclipseSynchronizer {
container.setSessionProperty(IGNORE_SYNC_KEY, null);
container.setSessionProperty(FOLDER_SYNC_KEY, null);
}
- IResource[] members = container.members();
- for (int i = 0; i < members.length; i++) {
- IResource resource = members[i];
- if (resource.getType() != IResource.FILE) {
- purgeCache((IContainer) resource);
+ if(depth!=IResource.DEPTH_ZERO) {
+ IResource[] members = container.members();
+ for (int i = 0; i < members.length; i++) {
+ IResource resource = members[i];
+ if (resource.getType() != IResource.FILE) {
+ purgeCache((IContainer) resource, depth == IResource.DEPTH_ONE ? IResource.DEPTH_ZERO : depth );
+ }
}
}
} catch (CoreException e) {
@@ -473,7 +485,7 @@ public class EclipseSynchronizer {
HashMap children = (HashMap)container.getSessionProperty(RESOURCE_SYNC_KEY);
if (children == null) {
// load the sync info from disk
- ResourceSyncInfo[] infos = SyncFileWriter.readAllResourceSync(CVSWorkspaceRoot.getCVSFolderFor(container));
+ ResourceSyncInfo[] infos = SyncFileWriter.readAllResourceSync(container);
if (infos != null) {
children = new HashMap(infos.length);
for (int i = 0; i < infos.length; i++) {
@@ -587,7 +599,7 @@ public class EclipseSynchronizer {
FolderSyncInfo info = (FolderSyncInfo)container.getSessionProperty(FOLDER_SYNC_KEY);
if (info == null) {
// read folder sync info and remember it
- info = SyncFileWriter.readFolderSync(CVSWorkspaceRoot.getCVSFolderFor(container));
+ info = SyncFileWriter.readFolderSync(container);
if (info == null) {
container.setSessionProperty(FOLDER_SYNC_KEY, NULL_FOLDER_SYNC_INFO);
} else {
@@ -652,7 +664,7 @@ public class EclipseSynchronizer {
String[] ignores = (String[])container.getSessionProperty(IGNORE_SYNC_KEY);
if (ignores == null) {
// read folder ignores and remember it
- ignores = SyncFileWriter.readCVSIgnoreEntries(CVSWorkspaceRoot.getCVSFolderFor(container));
+ ignores = SyncFileWriter.readCVSIgnoreEntries(container);
if (ignores == null) ignores = NULL_IGNORES;
container.setSessionProperty(IGNORE_SYNC_KEY, ignores);
}
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 094117225..87d85de3d 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
@@ -39,7 +39,6 @@ import org.eclipse.team.internal.ccvs.core.client.listeners.LogListener;
import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
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.FileUtil;
/**
* This class provides the implementation of ICVSRemoteFile and IManagedFile for
@@ -120,7 +119,7 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
}
public RemoteFile(RemoteFolder parent, int workspaceSyncState, String name, String revision, CVSTag tag) {
- this(parent, workspaceSyncState, new ResourceSyncInfo(name, revision, ResourceSyncInfo.DUMMY_TIMESTAMP, ResourceSyncInfo.USE_SERVER_MODE, tag, ResourceSyncInfo.DEFAULT_PERMISSIONS));
+ this(parent, workspaceSyncState, new ResourceSyncInfo(name, revision, ResourceSyncInfo.NULL_TIMESTAMP, ResourceSyncInfo.USE_SERVER_MODE, tag, ResourceSyncInfo.DEFAULT_PERMISSIONS, ResourceSyncInfo.REGULAR_SYNC));
}
public RemoteFile(RemoteFolder parent, ResourceSyncInfo info) {
@@ -294,7 +293,7 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
* @param revision to associated with this remote file
*/
public void setRevision(String revision) {
- info = new ResourceSyncInfo(info.getName(), revision, info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions());
+ info = new ResourceSyncInfo(info.getName(), revision, info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions(), info.getType());
}
/*
@@ -332,14 +331,14 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
/**
* @see IManagedFile#getTimeStamp()
*/
- public String getTimeStamp() {
+ public long getTimeStamp() {
return info.getTimeStamp();
}
/**
* @see IManagedFile#setTimeStamp(String)
*/
- public void setTimeStamp(String date) throws CVSException {
+ public void setTimeStamp(long date) throws CVSException {
}
/**
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 0a24a38a2..bf16ee24a 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
@@ -236,7 +236,7 @@ public class RemoteFolderTreeBuilder {
continue;
// If the file was deleted locally, we need to generate a new sync info without the delete flag
if (info.isDeleted())
- info = new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions());
+ info = new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions(), info.getType());
children.add(new RemoteFile(remote, info));
monitor.worked(1);
}
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 b3a431464..ce88672ef 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
@@ -5,12 +5,20 @@ package org.eclipse.team.internal.ccvs.core.syncinfo;
* All Rights Reserved.
*/
+import java.text.ParseException;
+import java.util.Date;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSTag;
+import org.eclipse.team.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.core.resources.*;
+import org.eclipse.team.internal.ccvs.core.Policy;
+import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
import org.eclipse.team.internal.ccvs.core.util.Assert;
+import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter;
import org.eclipse.team.internal.ccvs.core.util.EmptyTokenizer;
-import org.eclipse.team.internal.ccvs.core.Policy;
/**
* Value (immutable) object that represents workspace state information about a resource contained in
@@ -26,43 +34,55 @@ import org.eclipse.team.internal.ccvs.core.Policy;
*/
public class ResourceSyncInfo {
- // a directory sync info will have nothing more than a name
- private boolean isDirectory = false;
-
- // utility constants
- private static final String DIRECTORY_PREFIX = "D/"; //$NON-NLS-1$
- public static final String USE_SERVER_MODE = ""; //$NON-NLS-1$
- private static final String SEPERATOR = "/"; //$NON-NLS-1$
-
- // 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_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).
public static final String DEFAULT_PERMISSIONS = "u=rw,g=rw,o=r"; //$NON-NLS-1$
+
+ // use the server's default keyword substitution mode
+ public static final String USE_SERVER_MODE = ""; //$NON-NLS-1$
// file sync information can be associated with a local resource that has been deleted. This is
// noted by prefixing the revision with this character.
// XXX Should this be private
public static final String DELETED_PREFIX = "-"; //$NON-NLS-1$
- private boolean isDeleted = false;
// a sync element with a revision of '0' is considered a new file that has
// not been comitted to the repo. Is visible so that clients can create sync infos
// for new files.
public static final String ADDED_REVISION = "0"; //$NON-NLS-1$
+ // Timestamp constants used to identify special cases
+ public static final int REGULAR_SYNC = 0;
+ public static final int DUMMY_SYNC = 1;
+ public static final int MERGED_SYNC = 2;
+ public static final int MERGED_SYNC_WITH_CONFLICTS = 3;
+ public static final int NULL_TIMESTAMP = 0;
+
+ private static final String DUMMY_TIMESTAMP = "dummy timestamp"; //$NON-NLS-1$
+ private static final String RESULT_OF_MERGE = "Result of merge"; //$NON-NLS-1$
+ private static final String RESULT_OF_MERGE_CONFLICT = RESULT_OF_MERGE + "+"; //$NON-NLS-1$
+
+ private static final String MERGE_MODIFIED = "+modified"; //$NON-NLS-1$
+ private static final String MERGE_UNMODIFIED = "+="; //$NON-NLS-1$
+
+ // a directory sync info will have nothing more than a name
+ private boolean isDirectory = false;
+ private boolean isDeleted = false;
+
+ // utility constants
+ private static final String DIRECTORY_PREFIX = "D/"; //$NON-NLS-1$
+ private static final String SEPERATOR = "/"; //$NON-NLS-1$
+
// fields describing the synchronization of a resource in CVS parlance
private String name;
private String revision;
- private String timeStamp;
+ private long timeStamp;
private String keywordMode;
private CVSEntryLineTag tag;
private String permissions;
+
+ // type of sync
+ private int syncType = REGULAR_SYNC;
/**
* Constructor to create a sync object from entry line formats. The entry lines are parsed by this class.
@@ -74,7 +94,33 @@ public class ResourceSyncInfo {
*
* @exception CVSException is thrown if the entry cannot be parsed.
*/
- public ResourceSyncInfo(String entryLine, String permissions, String timestamp) throws CVSException {
+ public ResourceSyncInfo(String entryLine, String permissions, long timestamp, int syncType) throws CVSException {
+ Assert.isNotNull(entryLine);
+
+ this.syncType = syncType;
+ setEntryLine(entryLine);
+
+ if (permissions != null) {
+ this.permissions = permissions;
+ }
+ // override the timestamp that may of been in entryLine. In some cases the timestamp is not in the
+ // entry line (e.g. receiving entry lines from the server versus reading them from the Entry file).
+ if(timestamp!=ICVSFile.NULL_TIMESTAMP) {
+ this.timeStamp = timestamp;
+ }
+ }
+
+ /**
+ * Constructor to create a sync object from entry line formats. The entry lines are parsed by this class.
+ *
+ * @param entryLine the entry line (e.g. /new.java/1.2/Fri Dec 07 00:17:52 2001/-kb/)
+ * @param permissions the file permission (e.g. u=rw,g=rw,o=r). May be <code>null</code>.
+ * @param timestamp if not included in the entry line. Will overide the value in the entry line. The
+ * timestamp should be in the format specified in ICVSFile#getTimestamp(). May be <code>null</code>.
+ *
+ * @exception CVSException is thrown if the entry cannot be parsed.
+ */
+ public ResourceSyncInfo(String entryLine, String permissions, long timestamp) throws CVSException {
Assert.isNotNull(entryLine);
setEntryLine(entryLine);
@@ -84,9 +130,7 @@ public class ResourceSyncInfo {
}
// override the timestamp that may of been in entryLine. In some cases the timestamp is not in the
// entry line (e.g. receiving entry lines from the server versus reading them from the Entry file).
- if (isAdded()) {
- this.timeStamp = DUMMY_TIMESTAMP;
- } else if(timestamp!=null) {
+ if(timestamp!=ICVSFile.NULL_TIMESTAMP) {
this.timeStamp = timestamp;
}
}
@@ -101,13 +145,14 @@ public class ResourceSyncInfo {
* @param tag can be <code>null</code>
* @param permissions can be <code>null</code>
*/
- public ResourceSyncInfo(String name, String revision, String timestamp, String keywordMode, CVSTag tag, String permissions) {
+ public ResourceSyncInfo(String name, String revision, long timestamp, String keywordMode, CVSTag tag, String permissions, int syncType) {
Assert.isNotNull(name);
Assert.isNotNull(revision);
this.name = name;
this.timeStamp = timestamp;
this.keywordMode = keywordMode;
this.permissions = permissions;
+ this.syncType = syncType;
setRevision(revision);
setTag(tag);
}
@@ -141,13 +186,8 @@ public class ResourceSyncInfo {
* @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); //$NON-NLS-1$
- return t.equals(fileTimestamp);
- } else {
- return false;
- }
+ public boolean isNeedsMerge(long otherTimestamp) {
+ return syncType == MERGED_SYNC_WITH_CONFLICTS && timeStamp == otherTimestamp;
}
/**
@@ -158,7 +198,7 @@ public class ResourceSyncInfo {
* <code>false</code> for folders and for files that have not been merged.
*/
public boolean isMerged() {
- return timeStamp.indexOf(RESULT_OF_MERGE) != -1;
+ return syncType == MERGED_SYNC || syncType == MERGED_SYNC_WITH_CONFLICTS;
}
/**
@@ -199,6 +239,10 @@ public class ResourceSyncInfo {
* @return a file or folder entry line reflecting the state of this sync object.
*/
public String getEntryLine(boolean includeTimeStamp) {
+ return getEntryLine(includeTimeStamp, (String)null);
+ }
+
+ private String getEntryLine(boolean includeTimeStamp, String timestampOverride) {
StringBuffer result = new StringBuffer();
@@ -218,7 +262,22 @@ public class ResourceSyncInfo {
result.append(SEPERATOR);
if(includeTimeStamp) {
- result.append(timeStamp);
+ String entryLineTimestamp = "";
+ if(timestampOverride!=null) {
+ entryLineTimestamp = timestampOverride;
+ } else {
+ switch(syncType) {
+ case REGULAR_SYNC:
+ entryLineTimestamp = CVSDateFormatter.dateToEntryLine(new Date(timeStamp)); break;
+ case MERGED_SYNC:
+ entryLineTimestamp = RESULT_OF_MERGE; break;
+ case MERGED_SYNC_WITH_CONFLICTS:
+ entryLineTimestamp = RESULT_OF_MERGE_CONFLICT + CVSDateFormatter.dateToEntryLine(new Date(timeStamp)); break;
+ case DUMMY_SYNC:
+ entryLineTimestamp = DUMMY_TIMESTAMP; break;
+ }
+ }
+ result.append(entryLineTimestamp);
}
result.append(SEPERATOR);
result.append(keywordMode == null ? "" : keywordMode); //$NON-NLS-1$
@@ -242,7 +301,7 @@ public class ResourceSyncInfo {
*
* @return a file or folder entry line reflecting the state of this sync object.
*/
- public String getEntryLine(boolean includeTimeStamp, String fileTimestamp) {
+ public String getEntryLine(boolean includeTimeStamp, long fileTimestamp) {
String serverTimestamp;
if(isMerged()) {
if(isNeedsMerge(fileTimestamp)) {
@@ -250,14 +309,14 @@ public class ResourceSyncInfo {
} else {
serverTimestamp = MERGE_MODIFIED;
}
- return new ResourceSyncInfo(getName(), getRevision(), serverTimestamp, getKeywordMode(), getTag(), getPermissions()).getEntryLine(true);
+ return getEntryLine(true, serverTimestamp);
} else {
return getEntryLine(includeTimeStamp);
}
}
/**
- * Anwsers the a compatible permissions line for files.
+ * Anwsers a compatible permissions line for files.
*
* @return a permission line for files and <code>null</code> if this sync object is
* a directory.
@@ -304,7 +363,7 @@ public class ResourceSyncInfo {
*
* @return a string of the format "Thu Oct 18 20:21:13 2001"
*/
- public String getTimeStamp() {
+ public long getTimeStamp() {
return timeStamp;
}
@@ -400,7 +459,48 @@ public class ResourceSyncInfo {
setRevision(rev);
}
- timeStamp = tokenizer.nextToken();
+ String date = tokenizer.nextToken();
+
+ // possible timestamps are:
+ // from server: "+=" and "+modified"
+ // from entry line: "Result of Merge+Thu May 25 12:33:33 2002"
+ // "Result of Merge"
+ // "Thu May 25 12:33:33 2002"
+ //
+ // 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(date.indexOf(ResourceSyncInfo.MERGE_MODIFIED) != -1) {
+ syncType = MERGED_SYNC;
+ date = null;
+ } else if(date.indexOf(ResourceSyncInfo.MERGE_UNMODIFIED) != -1) {
+ syncType = MERGED_SYNC_WITH_CONFLICTS;
+ date = null;
+ } else if(date.indexOf(RESULT_OF_MERGE_CONFLICT)!=-1) {
+ date = date.substring(date.indexOf("+") + 1); //$NON-NLS-1$
+ syncType = MERGED_SYNC_WITH_CONFLICTS;
+ } else if(date.indexOf(RESULT_OF_MERGE)!=-1) {
+ syncType = MERGED_SYNC;
+ date = null;
+ }
+
+ if(date==null || "".equals(date)) {
+ timeStamp = NULL_TIMESTAMP;
+ } else {
+ try {
+ timeStamp = CVSDateFormatter.entryLineToDate(date).getTime();
+ } catch(ParseException e) {
+ // something we don't understand, just make this sync have no timestamp and
+ // never be in sync with the server.
+ timeStamp = NULL_TIMESTAMP;
+ syncType = DUMMY_SYNC;
+ }
+ }
+
keywordMode = tokenizer.nextToken();
String tagEntry = tokenizer.nextToken();
@@ -427,6 +527,13 @@ public class ResourceSyncInfo {
}
}
+ /**
+ * Returns the type of this sync info
+ */
+ public int getType() {
+ return syncType;
+ }
+
/*
* @see Object#toString()
*/
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfoMap.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfoMap.java
deleted file mode 100644
index e423801b3..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/syncinfo/ResourceSyncInfoMap.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.syncinfo;
-
-import java.util.Arrays;
-
-import org.eclipse.core.resources.IResource;
-
-class ResourceSyncInfoMap {
- private static final ResourceSyncInfo[] EMPTY = new ResourceSyncInfo[0];
- private static final int INITIAL_SIZE = 8;
- private ResourceSyncInfo[] elements;
- private int elementsUsed;
-
- public ResourceSyncInfoMap() {
- elements = EMPTY;
- elementsUsed = 0;
- }
-
- public void put(ResourceSyncInfo info) {
- int element = Arrays.binarySearch(elements, info);
- if (element >= 0) {
- // found existing element, replace it
- elements[element] = info;
- } else {
- // insert new element
- elementsUsed += 1;
- // index of new element as returned by binary search
- element = -element - 1;
- ResourceSyncInfo[] oldElements = elements;
- if (elementsUsed > elements.length) {
- // grow array
- int size = elements.length * 2;
- if (size < INITIAL_SIZE)
- size = INITIAL_SIZE;
- elements = new ResourceSyncInfo[size];
- System.arraycopy(oldElements, 0, elements, 0, element);
- }
- System.arraycopy(
- oldElements,
- element,
- elements,
- element + 1,
- elementsUsed - element - 1);
- elements[element] = info;
- }
- }
-
- public ResourceSyncInfo get(IResource resource) {
- int element = Arrays.binarySearch(elements, new ResourceSyncInfo(resource.getName(), "","","",null,null));//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- if (element < 0)
- return null;
- // found element, return it
- return elements[element];
- }
-
- public void remove(ResourceSyncInfo info) {
- int element = Arrays.binarySearch(elements, info);
- if (element < 0)
- return;
- // found element, remove it
- elementsUsed -= 1;
- ResourceSyncInfo[] oldElements = elements;
- if (elementsUsed <= elements.length / 4
- && elements.length >= INITIAL_SIZE * 2) {
- // shrink array
- int size = elements.length / 2;
- elements = new ResourceSyncInfo[size];
- System.arraycopy(oldElements, 0, elements, 0, element);
- } else {
- // since we're not creating a new array, we need to clear the last element
- elements[elementsUsed] = null;
- }
- System.arraycopy(
- oldElements,
- element + 1,
- elements,
- element,
- elementsUsed - element);
- }
-
- // XXX might not even need to copy the array since EclipseSynchronizer
- // is the only one who uses this and could just as well access it
- // directly.
- public ResourceSyncInfo[] toArray() {
- ResourceSyncInfo[] infos = new ResourceSyncInfo[elementsUsed];
- System.arraycopy(elements, 0, infos, 0, elementsUsed);
- return infos;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java
new file mode 100644
index 000000000..9e6f907b7
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/CVSDateFormatter.java
@@ -0,0 +1,55 @@
+package org.eclipse.team.internal.ccvs.core.util;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ * Utility class for converting timestamps used in Entry file lines. The format
+ * required in the Entry file is ISO C asctime() function (Sun Apr 7 01:29:26 1996).
+ */
+public class CVSDateFormatter {
+
+ // entry file date is actually a zero padded number:
+ // Mon Jan 9 12:33:44 2002
+ // Mon Jan 12 23:34:22 2002
+ public static final String ENTRYLINE_FORMAT = "E MMM d HH:mm:ss yyyy"; //$NON-NLS-1$
+ public static final String SERVER_FORMAT = "dd MMM yyyy HH:mm:ss";//$NON-NLS-1$
+
+ private static SimpleDateFormat serverFormat = new SimpleDateFormat(SERVER_FORMAT, Locale.US);
+ private static SimpleDateFormat entryLineFormat = new SimpleDateFormat(ENTRYLINE_FORMAT, Locale.US);
+
+ static {
+ serverFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+ entryLineFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
+
+ static public Date serverStampToDate(String text) throws ParseException {
+ // FIXME this cuts the timezone which we do not want
+ if (text.indexOf("-") != -1) {//$NON-NLS-1$
+ text = text.substring(0,text.indexOf("-"));//$NON-NLS-1$
+ }
+ return serverFormat.parse(text);
+ }
+
+ static public String dateToServerStamp(Date date) {
+ return serverFormat.format(date);
+ }
+
+ static public Date entryLineToDate(String text) throws ParseException {
+ return entryLineFormat.parse(text);
+ }
+
+ static public String dateToEntryLine(Date date) {
+ return entryLineFormat.format(date);
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/EntryFileDateFormat.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/EntryFileDateFormat.java
deleted file mode 100644
index b2971497b..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/EntryFileDateFormat.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-/**
- * Utility class for converting timestamps used in Entry file lines. The format
- * required in the Entry file is ISO C asctime() function (Sun Apr 7 01:29:26 1996).
- */
-public class EntryFileDateFormat extends SimpleDateFormat {
-
- public static final String FORMAT = "E MMM dd HH:mm:ss yyyy"; //$NON-NLS-1$
-
- public EntryFileDateFormat() {
- super(FORMAT, Locale.US);
- setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$
- }
-
- /**
- * Returns a date representing the number of milliseconds since
- * January 1, 1970, 00:00:00 GMT represented by this Entry file
- * string date format.
- */
- public Date toDate(String text) throws ParseException {
- return parse(text);
- }
-
- /**
- * long since 1970 => "Thu Oct 18 20:21:13 2001"
- */
- public String formatDate(Date date) {
- return format(date);
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaSyncHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaSyncHandler.java
index ea1b716e0..43ffc7cae 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaSyncHandler.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaSyncHandler.java
@@ -121,7 +121,7 @@ public class ResourceDeltaSyncHandler implements IResourceDeltaVisitor {
if (info.isAdded()) {
mFile.unmanage(null);
} else {
- mFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.DELETED_PREFIX + info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions()));
+ mFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.DELETED_PREFIX + info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions(), info.getType()));
}
}
} catch (CVSException e) {
@@ -139,7 +139,7 @@ public class ResourceDeltaSyncHandler implements IResourceDeltaVisitor {
if (mFile.isManaged()) {
ResourceSyncInfo info = mFile.getSyncInfo();
if (info.isDeleted()) {
- mFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions()));
+ mFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions(), info.getType()));
} else if (info.isDirectory()) {
// XXX This is a gender change against the server! We should prevent this creation.
mFile.unmanage(null);
@@ -165,7 +165,7 @@ public class ResourceDeltaSyncHandler implements IResourceDeltaVisitor {
if (fromInfo.isAdded()) {
fromFile.unmanage(null);
} else {
- fromFile.setSyncInfo(new ResourceSyncInfo(fromInfo.getName(), fromInfo.DELETED_PREFIX + fromInfo.getRevision(), fromInfo.getTimeStamp(), fromInfo.getKeywordMode(), fromInfo.getTag(), fromInfo.getPermissions()));
+ fromFile.setSyncInfo(new ResourceSyncInfo(fromInfo.getName(), fromInfo.DELETED_PREFIX + fromInfo.getRevision(), fromInfo.getTimeStamp(), fromInfo.getKeywordMode(), fromInfo.getTag(), fromInfo.getPermissions(), fromInfo.getType()));
}
}
@@ -174,10 +174,10 @@ public class ResourceDeltaSyncHandler implements IResourceDeltaVisitor {
if (toFile.isManaged()) {
ResourceSyncInfo info = toFile.getSyncInfo();
if (info.isDeleted()) {
- toFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions()));
+ toFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions(), info.getType()));
}
} else if (fromInfo != null) {
- toFile.setSyncInfo(new ResourceSyncInfo(toFile.getName(), ResourceSyncInfo.ADDED_REVISION, ResourceSyncInfo.DUMMY_TIMESTAMP, fromInfo.getKeywordMode(), fromInfo.getTag(), fromInfo.getPermissions()));
+ toFile.setSyncInfo(new ResourceSyncInfo(toFile.getName(), ResourceSyncInfo.ADDED_REVISION, ResourceSyncInfo.NULL_TIMESTAMP, fromInfo.getKeywordMode(), fromInfo.getTag(), fromInfo.getPermissions(), ResourceSyncInfo.DUMMY_SYNC));
}
} catch (CVSException e) {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaVisitor.java
index 174799520..6bc07d327 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaVisitor.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ResourceDeltaVisitor.java
@@ -11,6 +11,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
@@ -56,7 +57,7 @@ public abstract class ResourceDeltaVisitor implements IResourceDeltaVisitor {
}
if(provider != null) {
- delta.accept(visitor);
+ delta.accept(visitor, getMemberTypeFlags());
}
}
visitor.handle();
@@ -231,5 +232,12 @@ public abstract class ResourceDeltaVisitor implements IResourceDeltaVisitor {
protected int getEventMask() {
return IResourceChangeEvent.POST_CHANGE;
}
+
+ /**
+ * Return the type of resources to visit
+ */
+ protected int getMemberTypeFlags() {
+ return IResource.NONE;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ServerDateFormat.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ServerDateFormat.java
deleted file mode 100644
index 123b0ca60..000000000
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/ServerDateFormat.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.eclipse.team.internal.ccvs.core.util;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-
-/**
- * Does convertion beetween this timeformats:<br>
- * <ul>
- * <li> "18 Oct 2001 20:21:13 -0350"
- * <li> a long messuring the milliseconds after 1970
- * </ul>
- */
-public class ServerDateFormat extends SimpleDateFormat {
-
- public static final String FORMAT = "dd MMM yyyy HH:mm:ss";//$NON-NLS-1$
-
- public ServerDateFormat() {
- super(FORMAT, Locale.US);
- setTimeZone(TimeZone.getTimeZone("GMT"));//$NON-NLS-1$
- }
-
- /**
- * "18 Oct 2001 20:21:13 -0350" => long since 1970
- */
- public Date toDate(String text) throws ParseException {
- // FIXME this cuts the timezone which we do not want
- if (text.indexOf("-") != -1) {//$NON-NLS-1$
- text = text.substring(0,text.indexOf("-"));//$NON-NLS-1$
- }
- return parse(text);
- }
-
- /**
- * long since 1970 => "18 Oct 2001 20:21:13 -0350"
- */
- public String formatDate(Date date) {
- return format(date);
- }
-
-}
-
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
index 19cb87e24..3bdb35449 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/SyncFileWriter.java
@@ -5,7 +5,6 @@ package org.eclipse.team.internal.ccvs.core.util;
* All Rights Reserved.
*/
-import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -17,12 +16,24 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSTag;
-import org.eclipse.team.ccvs.core.ICVSFile;
-import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.resources.CVSEntryLineTag;
+import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
@@ -31,7 +42,7 @@ import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
* provides a bridge between the CVS metafile formats and location to the
* Eclipse CVS client ResourceSyncInfo and FolderSyncInfo types.
*/
-public class SyncFileWriter {
+public class SyncFileWriter implements IResourceChangeListener {
// CVS meta files located in the CVS subdirectory
private static final String REPOSITORY = "Repository"; //$NON-NLS-1$
@@ -51,7 +62,7 @@ public class SyncFileWriter {
// Command characters found in the Entries.log file
private static final String ADD_TAG="A "; //$NON-NLS-1$
- private static final String REMOVE_TAG="R "; //$NON-NLS-1$
+ private static final String REMOVE_TAG="R "; //$NON-NLS-1$
// file and folder patterns that are ignored by default by the CVS server on import.
public static final String[] PREDEFINED_IGNORE_PATTERNS = {
@@ -63,13 +74,72 @@ public class SyncFileWriter {
// file and folder patterns that are ignored by default by the CVS server on import.
public static final String[] BASIC_IGNORE_PATTERNS = {"CVS", ".#*"}; //$NON-NLS-1$ //$NON-NLS-2$
+ // key for saving the mod stamp for each writen meta file
+ private static final QualifiedName MODSTAMP_KEY = new QualifiedName("org.eclipse.team.cvs.core", "meta-file-modtime");
+
+ public static void startup() {
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(new SyncFileWriter(), IResourceChangeEvent.POST_CHANGE);
+ }
+
+ /**
+ * When a resource changes this method will detect if the changed resources is a meta file that has changed
+ * by a 3rd party. For example, if the command line tool was run and then the user refreshed from local. To
+ * distinguish changes made by this class and thoses made by others a modification stamp is persisted with each
+ * metafile.
+ *
+ * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
+ */
+ public void resourceChanged(IResourceChangeEvent event) {
+ try {
+ final List changedContainers = new ArrayList();
+ event.getDelta().accept(new IResourceDeltaVisitor() {
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ IResource resource = delta.getResource();
+ if(resource.exists()) {
+ IContainer parent = resource.getParent();
+ boolean isCVSMetaFile = parent != null && parent.getName().equals("CVS");
+ boolean isIgnoreFile = resource.getName().equals(IGNORE_FILE);
+ if(isCVSMetaFile || isIgnoreFile) {
+ long modStamp = resource.getModificationStamp();
+ Long whenWeWrote;
+ try {
+ whenWeWrote = (Long)resource.getSessionProperty(MODSTAMP_KEY);
+ } catch(CoreException e) {
+ CVSProviderPlugin.log(e.getStatus());
+ whenWeWrote = null;
+ }
+ if(whenWeWrote==null || whenWeWrote.longValue() != modStamp) {
+ if(isCVSMetaFile) {
+ changedContainers.add(parent.getParent());
+ } else {
+ changedContainers.add(parent);
+ }
+ if(Policy.DEBUG_METAFILE_CHANGES) {
+ System.out.println("CVS metaFile changed by 3rd party: " + resource.getFullPath());
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }}, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
+ if(!changedContainers.isEmpty()) {
+ EclipseSynchronizer.getInstance().syncFilesChanged((IContainer[])changedContainers.toArray(new IContainer[changedContainers.size()]));
+ }
+ } catch(CoreException e) {
+ CVSProviderPlugin.log(e.getStatus());
+ } catch(CVSException e) {
+ CVSProviderPlugin.log(e.getStatus());
+ }
+ }
+
/**
* Reads the CVS/Entries, CVS/Entries.log and CVS/Permissions files from the
* specified folder and returns ResourceSyncInfo instances for the data stored therein.
* If the folder does not have a CVS subdirectory then <code>null</code> is returned.
*/
- public static ResourceSyncInfo[] readAllResourceSync(ICVSFolder parent) throws CVSException {
- ICVSFolder cvsSubDir = getCVSSubdirectory(parent);
+ public static ResourceSyncInfo[] readAllResourceSync(IContainer parent) throws CVSException {
+ IFolder cvsSubDir = getCVSSubdirectory(parent);
if (! cvsSubDir.exists()) return null;
// process Entries file contents
@@ -79,7 +149,7 @@ public class SyncFileWriter {
for (int i = 0; i < entries.length; i++) {
String line = entries[i];
if(!FOLDER_TAG.equals(line) && !"".equals(line)) { //$NON-NLS-1$
- ResourceSyncInfo info = new ResourceSyncInfo(line, null, null);
+ ResourceSyncInfo info = new ResourceSyncInfo(line, null, ResourceSyncInfo.NULL_TIMESTAMP, ResourceSyncInfo.REGULAR_SYNC);
infos.put(info.getName(), info);
}
}
@@ -91,11 +161,11 @@ public class SyncFileWriter {
String line = entriesLog[i];
if (line.startsWith(ADD_TAG)) {
line = line.substring(ADD_TAG.length());
- ResourceSyncInfo info = new ResourceSyncInfo(line, null, null);
+ ResourceSyncInfo info = new ResourceSyncInfo(line, null, ResourceSyncInfo.NULL_TIMESTAMP, ResourceSyncInfo.REGULAR_SYNC);
infos.put(info.getName(), info);
} else if (line.startsWith(REMOVE_TAG)) {
line = line.substring(REMOVE_TAG.length());
- ResourceSyncInfo info = new ResourceSyncInfo(line, null, null);
+ ResourceSyncInfo info = new ResourceSyncInfo(line, null, ResourceSyncInfo.NULL_TIMESTAMP, ResourceSyncInfo.REGULAR_SYNC);
infos.remove(info.getName());
}
}
@@ -111,24 +181,25 @@ public class SyncFileWriter {
* specified folder using the data contained in the specified ResourceSyncInfo instance.
* If the folder does not have a CVS subdirectory then <code>null</code> is returned.
*/
- public static void writeAllResourceSync(ICVSFolder parent, ResourceSyncInfo[] infos) throws CVSException {
- ICVSFolder cvsSubDir = getCVSSubdirectory(parent);
- if (!cvsSubDir.exists()) cvsSubDir.mkdir();
-
- // format file contents
- String[] entries = new String[infos.length];
- for (int i = 0; i < infos.length; i++) {
- ResourceSyncInfo info = infos[i];
- entries[i] = info.getEntryLine(true);
+ public static void writeAllResourceSync(IContainer parent, ResourceSyncInfo[] infos) throws CVSException {
+ try {
+ IFolder cvsSubDir = createCVSSubdirectory(parent);
+
+ // format file contents
+ String[] entries = new String[infos.length];
+ for (int i = 0; i < infos.length; i++) {
+ ResourceSyncInfo info = infos[i];
+ entries[i] = info.getEntryLine(true);
+ }
+
+ // write Entries
+ writeLines(cvsSubDir.getFile(ENTRIES), entries);
+
+ // delete Entries.log
+ cvsSubDir.getFile(ENTRIES_LOG).delete(IResource.NONE, null);
+ } catch(CoreException e) {
+ throw CVSException.wrapException(e);
}
-
- // write Entries
- writeLines(cvsSubDir.getFile(ENTRIES), entries);
-
- // delete Entries.log
- cvsSubDir.getFile(ENTRIES_LOG).delete();
-
- // XXX does not write CVS/Permissions -- should we?
}
/**
@@ -136,8 +207,8 @@ public class SyncFileWriter {
* the specified folder and returns a FolderSyncInfo instance for the data stored therein.
* If the folder does not have a CVS subdirectory then <code>null</code> is returned.
*/
- public static FolderSyncInfo readFolderSync(ICVSFolder folder) throws CVSException {
- ICVSFolder cvsSubDir = getCVSSubdirectory(folder);
+ public static FolderSyncInfo readFolderSync(IContainer folder) throws CVSException {
+ IFolder cvsSubDir = getCVSSubdirectory(folder);
if (! cvsSubDir.exists()) return null;
// read CVS/Root
@@ -164,42 +235,46 @@ public class SyncFileWriter {
* Writes the CVS/Root, CVS/Repository, CVS/Tag, and CVS/Entries.static files to the
* specified folder using the data contained in the specified FolderSyncInfo instance.
*/
- public static void writeFolderSync(ICVSFolder folder, FolderSyncInfo info) throws CVSException {
- ICVSFolder cvsSubDir = createCVSSubdirectory(folder);
-
- // write CVS/Root
- writeLines(cvsSubDir.getFile(ROOT), new String[] {info.getRoot()});
-
- // write CVS/Repository
- writeLines(cvsSubDir.getFile(REPOSITORY), new String[] {info.getRepository()});
-
- // write CVS/Tag
- ICVSFile tagFile = cvsSubDir.getFile(TAG);
- if (info.getTag() != null) {
- writeLines(tagFile, new String[] {info.getTag().toEntryLineFormat(false)});
- } else {
- if(tagFile.exists()) {
- tagFile.delete();
+ public static void writeFolderSync(IContainer folder, FolderSyncInfo info) throws CVSException {
+ try {
+ IFolder cvsSubDir = createCVSSubdirectory(folder);
+
+ // write CVS/Root
+ writeLines(cvsSubDir.getFile(ROOT), new String[] {info.getRoot()});
+
+ // write CVS/Repository
+ writeLines(cvsSubDir.getFile(REPOSITORY), new String[] {info.getRepository()});
+
+ // write CVS/Tag
+ IFile tagFile = cvsSubDir.getFile(TAG);
+ if (info.getTag() != null) {
+ writeLines(tagFile, new String[] {info.getTag().toEntryLineFormat(false)});
+ } else {
+ if(tagFile.exists()) {
+ tagFile.delete(IResource.NONE, null);
+ }
}
- }
-
- // write CVS/Entries.Static
- ICVSFile staticFile = cvsSubDir.getFile(STATIC);
- if(info.getIsStatic()) {
- // the existance of the file is all that matters
- writeLines(staticFile, new String[] {""}); //$NON-NLS-1$
- } else {
- if(staticFile.exists()) {
- staticFile.delete();
+
+ // write CVS/Entries.Static
+ IFile staticFile = cvsSubDir.getFile(STATIC);
+ if(info.getIsStatic()) {
+ // the existance of the file is all that matters
+ writeLines(staticFile, new String[] {""}); //$NON-NLS-1$
+ } else {
+ if(staticFile.exists()) {
+ staticFile.delete(IResource.NONE, null);
+ }
}
+ } catch(CoreException e) {
+ throw CVSException.wrapException(e);
}
}
/**
* Returns all .cvsignore entries for the specified folder.
*/
- public static String[] readCVSIgnoreEntries(ICVSFolder folder) throws CVSException {
- ICVSFile ignoreFile = folder.getFile(IGNORE_FILE);
+ public static String[] readCVSIgnoreEntries(IContainer folder) throws CVSException {
+ IFile ignoreFile = folder.getFile(new Path(IGNORE_FILE));
if (ignoreFile != null) {
return readLines(ignoreFile);
}
@@ -209,37 +284,53 @@ public class SyncFileWriter {
/**
* Adds a .cvsignore entry to the folder for the specified file.
*/
- public static void addCVSIgnoreEntries(ICVSFolder folder, String[] patterns) throws CVSException {
- ICVSFile ignoreFile = folder.getFile(IGNORE_FILE);
+ public static void addCVSIgnoreEntries(IContainer folder, String[] patterns) throws CVSException {
+ IFile ignoreFile = folder.getFile(new Path(IGNORE_FILE));
writeLines(ignoreFile, patterns);
}
/**
+ * Delete folder sync is equilavent to removing the CVS subdir.
+ */
+ public static void deleteFolderSync(IContainer folder) throws CVSException {
+ try {
+ getCVSSubdirectory(folder).delete(IResource.NONE, null);
+ } catch(CoreException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+
+ /**
* Returns the CVS subdirectory for this folder.
*/
- public static ICVSFolder getCVSSubdirectory(ICVSFolder folder) throws CVSException {
- return folder.getFolder("CVS"); //$NON-NLS-1$
+ private static IFolder getCVSSubdirectory(IContainer folder) throws CVSException {
+ return folder.getFolder(new Path("CVS")); //$NON-NLS-1$
}
/**
- * Creates and returns a CVS subdirectory in this folder.
+ * Creates and makes team-private and returns a CVS subdirectory in this folder.
*/
- public static ICVSFolder createCVSSubdirectory(ICVSFolder folder) throws CVSException {
- ICVSFolder cvsSubDir = getCVSSubdirectory(folder);
- if (! cvsSubDir.exists()) {
- cvsSubDir.mkdir();
+ private static IFolder createCVSSubdirectory(IContainer folder) throws CVSException {
+ try {
+ IFolder cvsSubDir = getCVSSubdirectory(folder);
+ if (! cvsSubDir.exists()) {
+ cvsSubDir.create(false /*don't force*/, true /*make local*/, null);
+ //cvsSubDir.setTeamPrivateMember(true);
+ }
+ return cvsSubDir;
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
}
- return cvsSubDir;
}
/*
* Reads the first line of the specified file.
* Returns null if the file does not exist, or the empty string if it is blank.
*/
- private static String readFirstLine(ICVSFile file) throws CVSException {
+ private static String readFirstLine(IFile file) throws CVSException {
if (! file.exists()) return null;
try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(file.getInputStream()));
+ BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()));
try {
String line = reader.readLine();
if (line == null) return ""; //$NON-NLS-1$
@@ -249,6 +340,8 @@ public class SyncFileWriter {
}
} catch (IOException e) {
throw CVSException.wrapException(e);
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
}
}
@@ -256,10 +349,10 @@ public class SyncFileWriter {
* Reads all lines of the specified file.
* Returns null if the file does not exist.
*/
- private static String[] readLines(ICVSFile file) throws CVSException {
+ private static String[] readLines(IFile file) throws CVSException {
if (! file.exists()) return null;
try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(file.getInputStream()));
+ BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()));
List fileContentStore = new ArrayList();
try {
String line;
@@ -272,6 +365,8 @@ public class SyncFileWriter {
}
} catch (IOException e) {
throw CVSException.wrapException(e);
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
}
}
@@ -279,10 +374,21 @@ public class SyncFileWriter {
* Writes all lines to the specified file, using linefeed terminators for
* compatibility with other CVS clients.
*/
- private static void writeLines(ICVSFile file, String[] contents) throws CVSException {
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- writeLinesToStreamAndClose(os, contents);
- file.setContents(new ByteArrayInputStream(os.toByteArray()), ICVSFile.UPDATED, false, Policy.monitorFor(null));
+ private static void writeLines(IFile file, String[] contents) throws CVSException {
+ try {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ writeLinesToStreamAndClose(os, contents);
+ if(!file.exists()) {
+ file.create(new ByteArrayInputStream(os.toByteArray()), IResource.NONE /*don't keep history and don't force*/, null);
+ } else {
+ file.setContents(new ByteArrayInputStream(os.toByteArray()), IResource.NONE /*don't keep history and don't force*/, null);
+ }
+
+ // this is where we could save the timestamp
+ file.setSessionProperty(MODSTAMP_KEY, new Long(file.getModificationStamp()));
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
+ }
}
private static void writeLinesToStreamAndClose(OutputStream os, String[] contents)
@@ -299,13 +405,5 @@ public class SyncFileWriter {
} catch (IOException e) {
throw CVSException.wrapException(e);
}
- }
-
- /*
- * Appends lines to the specified file, using linefeed terminators.
- */
- private static void appendLines(ICVSFile file, String[] contents) throws CVSException {
- OutputStream os = new BufferedOutputStream(file.getAppendingOutputStream());
- writeLinesToStreamAndClose(os, contents);
- }
-}
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml
index 98428ebce..01148f52d 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml
@@ -349,17 +349,6 @@
</view>
</extension>
- <extension point="org.eclipse.ui.resourceFilters">
- <filter pattern="CVS" selected="true"/>
- </extension>
-
- <!-- ** Temporary Filter ** -->
- <extension point="org.eclipse.jdt.ui.javaElementFilters">
- <filter pattern="CVS" selected="true"/>
- <filter pattern="*.CVS" selected="true"/>
- </extension>
-
-
<!-- **************** PREFERENCES ******************* -->
<extension
point = "org.eclipse.ui.preferencePages">
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java
index 66018f2d6..6052f86b5 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFilePropertiesPage.java
@@ -5,6 +5,8 @@ package org.eclipse.team.internal.ccvs.ui;
* All Rights Reserved.
*/
+import java.util.Date;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.swt.SWT;
@@ -19,6 +21,7 @@ import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
+import org.eclipse.team.internal.ccvs.core.util.CVSDateFormatter;
import org.eclipse.ui.dialogs.PropertyPage;
public class CVSFilePropertiesPage extends PropertyPage {
@@ -53,7 +56,7 @@ public class CVSFilePropertiesPage extends PropertyPage {
createLabel(composite, Policy.bind("CVSFilePropertiesPage.baseRevision"));
createLabel(composite, syncInfo.getRevision());
createLabel(composite, Policy.bind("CVSFilePropertiesPage.baseTimestamp"));
- createLabel(composite, syncInfo.getTimeStamp());
+ createLabel(composite, CVSDateFormatter.dateToEntryLine(new Date(syncInfo.getTimeStamp())));
// Dirty and Modified
createLabel(composite, Policy.bind("CVSFilePropertiesPage.dirty"));
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java
index 6db103257..84be67f13 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java
@@ -36,7 +36,7 @@ public class CVSTestSetup extends TestSetup {
}
public static void loadProperties() {
- String propertiesFile = System.getProperty("eclipse.cvs.properties");
+ String propertiesFile = "e:/repository.properties";
if (propertiesFile == null) return;
File file = new File(propertiesFile);
if (file.isDirectory()) file = new File(file, "repository.properties");
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
index e50a8d689..7610c6265 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/SameResultEnv.java
@@ -6,7 +6,6 @@ package org.eclipse.team.tests.ccvs.core.compatible;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.text.ParseException;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
@@ -23,10 +22,7 @@ import org.eclipse.team.ccvs.core.ICVSFolder;
import org.eclipse.team.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.core.util.EntryFileDateFormat;
-import org.eclipse.team.internal.ccvs.core.util.Util;
import org.eclipse.team.tests.ccvs.core.CVSClientException;
import org.eclipse.team.tests.ccvs.core.CommandLineCVSClient;
import org.eclipse.team.tests.ccvs.core.EclipseCVSClient;
@@ -133,7 +129,6 @@ public final class SameResultEnv extends JUnitTestCase {
} finally {
try {
referenceProject.refreshLocal(IResource.DEPTH_INFINITE, null);
- EclipseSynchronizer.getInstance().flush(referenceProject, true, null); // remove me once refresh local fixed
} catch (CoreException e) {
fail("CoreException during refreshLocal: " + e.getMessage());
}
@@ -391,31 +386,31 @@ public final class SameResultEnv extends JUnitTestCase {
// Ensure that timestamps are written in ISO C asctime() format and if timestamp
// has a conflict marker then both should have the marker. Also ensure that timestamps
// are written using same timezone.
- assertTimestampEquals(info1.getTimeStamp(), info2.getTimeStamp());
+ //assertTimestampEquals(info1.getTimeStamp(), info2.getTimeStamp());
// We are not able to check for the permissions, as the reference-client doesn't save them
}
private static void assertTimestampEquals(String timestamp1, String timestamp2) {
- try {
- EntryFileDateFormat timestampFormat = new EntryFileDateFormat();
- boolean merge1 = timestamp1.indexOf(ResourceSyncInfo.RESULT_OF_MERGE_CONFLICT) != -1;
- boolean merge2 = timestamp2.indexOf(ResourceSyncInfo.RESULT_OF_MERGE_CONFLICT) != -1;
- boolean dummy1 = timestamp1.indexOf(ResourceSyncInfo.DUMMY_TIMESTAMP) != -1;
- boolean dummy2 = timestamp2.indexOf(ResourceSyncInfo.DUMMY_TIMESTAMP) != -1;
- assertEquals("both timestamps should show same conflict state", merge1, merge2);
- assertEquals("both timestamps should show same dummy state", dummy1, dummy2);
- if(!merge1 && !dummy1) {
- long time1 = timestampFormat.toDate(timestamp1).getTime();
- long time2 = timestampFormat.toDate(timestamp2).getTime();
+ //try {
+ //EntryFileDateFormat timestampFormat = new EntryFileDateFormat();
+ //boolean merge1 = timestamp1.indexOf(ResourceSyncInfo.RESULT_OF_MERGE_CONFLICT) != -1;
+ //boolean merge2 = timestamp2.indexOf(ResourceSyncInfo.RESULT_OF_MERGE_CONFLICT) != -1;
+ //boolean dummy1 = timestamp1.indexOf(ResourceSyncInfo.DUMMY_TIMESTAMP) != -1;
+ //boolean dummy2 = timestamp2.indexOf(ResourceSyncInfo.DUMMY_TIMESTAMP) != -1;
+ //assertEquals("both timestamps should show same conflict state", merge1, merge2);
+ //assertEquals("both timestamps should show same dummy state", dummy1, dummy2);
+ //if(!merge1 && !dummy1) {
+ // long time1 = timestampFormat.toDate(timestamp1).getTime();
+ // long time2 = timestampFormat.toDate(timestamp2).getTime();
/* timestamp tests don't seem to work on some systems.
long difference = Math.abs(time1 - time2);
assertTrue("timestamps should be in same timezone:" + timestamp1 + ":" + timestamp2, difference < (5*60*1000)); // 5 minutes
*/
- }
- } catch(ParseException e) {
- fail("timestamps in CVS/Entry file are not in ISO C asctime format:" + timestamp1 + ":" + timestamp2);
- }
+ //}
+ //} catch(ParseException e) {
+ // fail("timestamps in CVS/Entry file are not in ISO C asctime format:" + timestamp1 + ":" + timestamp2);
+ //}
}
/**
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java
index 45a9ed64c..51a77c663 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java
@@ -417,7 +417,7 @@ public class EclipseSynchronizerTest extends EclipseTest {
private ResourceSyncInfo dummyResourceSync(IResource resource) {
if (resource.getType() == IResource.FILE) {
- return new ResourceSyncInfo(resource.getName(), "1.1", ResourceSyncInfo.DUMMY_TIMESTAMP, "", CVSTag.DEFAULT, "");
+ return new ResourceSyncInfo(resource.getName(), "1.1", ResourceSyncInfo.NULL_TIMESTAMP, "", CVSTag.DEFAULT, "", ResourceSyncInfo.DUMMY_SYNC);
} else {
return new ResourceSyncInfo(resource.getName());
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java
index fa157f0ac..b1c251062 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java
@@ -13,6 +13,8 @@ import org.eclipse.team.tests.ccvs.core.EclipseTest;
public class ResourceSyncInfoTest extends EclipseTest {
+ private final static String GOOD_TIMESTAMP = "Mon Feb 25 21:44:02 2002";
+
public ResourceSyncInfoTest() {
super();
}
@@ -34,22 +36,22 @@ public class ResourceSyncInfoTest extends EclipseTest {
// testing malformed entry lines first
try {
- new ResourceSyncInfo("//////", null, null);
+ new ResourceSyncInfo("//////", null, 0, 0);
fail();
} catch(CVSException e) {
}
try {
- new ResourceSyncInfo("//1.1///", null, null);
+ new ResourceSyncInfo("//1.1///", null, 0, 0);
fail();
} catch(CVSException e) {
}
try {
- new ResourceSyncInfo("/file.txt////", null, null);
+ new ResourceSyncInfo("/file.txt////", null, 0, 0);
fail();
} catch(CVSException e) {
}
try {
- new ResourceSyncInfo("/file.txt//////////", null, null);
+ new ResourceSyncInfo("/file.txt//////////", null, 0, 0);
fail();
} catch(CVSException e) {
}
@@ -61,28 +63,27 @@ public class ResourceSyncInfoTest extends EclipseTest {
public void testEntryLineConstructor() {
try {
ResourceSyncInfo info;
- info = new ResourceSyncInfo("/file.java/1.1/27 Sep 2001 18:00:16/-k/", null, null);
- info = new ResourceSyncInfo("/file.java/-1.1/27 Sep 2001 18:00:16/-k/", null, null);
+ info = new ResourceSyncInfo("/file.java/-1.1/Mon Feb 25 21:44:02 2002/-k/", null, 0);
assertTrue(info.isDeleted());
- info = new ResourceSyncInfo("/file.java/0/27 Sep 2001 18:00:16/-k/", null, null);
+ info = new ResourceSyncInfo("/file.java/0/something/-k/", null, 0);
assertTrue(info.isAdded());
- info = new ResourceSyncInfo("/file.java/1.0/27 Sep 2001 18:00:16/-k/Tv1", null, null);
+ info = new ResourceSyncInfo("/file.java/1.0/Mon Feb 25 21:44:02 2002/-k/Tv1", null, 0);
assertTrue(info.getTag() != null);
- String timestamp = "10 Sep 2000 18:00:16";
- info = new ResourceSyncInfo("/file.java/1.0/27 Sep 2001 18:00:16/-k/Tv1", null, timestamp);
- assertTrue(info.getTimeStamp().equals(timestamp));
+ long timestamp = 123456;
+ info = new ResourceSyncInfo("/file.java/1.0/Mon Feb 25 21:44:02 2002/-k/Tv1", null, timestamp);
+ assertTrue(info.getTimeStamp() == timestamp);
- info = new ResourceSyncInfo("/file.java/0/27 Sep 2001 18:00:16/-k/", null, timestamp);
- assertTrue(info.getTimeStamp().equals(ResourceSyncInfo.DUMMY_TIMESTAMP));
+ info = new ResourceSyncInfo("/file.java/0/Mon Feb 25 21:44:02 2002/-k/", null, timestamp);
+ assertTrue(info.getTimeStamp() == timestamp);
String permissions = "u=rwx,g=rwx,o=rwx";
- info = new ResourceSyncInfo("/file.java/2.0/27 Sep 2001 18:00:16/-k/Tv1", permissions, null);
+ info = new ResourceSyncInfo("/file.java/2.0/Mon Feb 25 21:44:02 2002/-k/Tv1", permissions, 0);
assertTrue(info.getPermissions().equals(permissions));
- info = new ResourceSyncInfo("D/file.java////", null, null);
+ info = new ResourceSyncInfo("D/file.java////", null, 0);
assertTrue(info.isDirectory());
} catch(CVSException e) {
@@ -93,24 +94,71 @@ public class ResourceSyncInfoTest extends EclipseTest {
/**
* Testing the parameter constructor
*/
- public void testConstructor() {
+ public void testConstructor() throws CVSException {
ResourceSyncInfo info;
info = new ResourceSyncInfo("folder");
assertTrue(info.isDirectory());
- info = new ResourceSyncInfo("file.txt", "-2.34", "27 Sep 2001 18:00:16", "", null, "");
+ long timestamp = 123456;
+ info = new ResourceSyncInfo("file.txt", "-2.34", timestamp, "", null, "", 0);
assertTrue(info.isDeleted());
assertTrue(info.getRevision().equals("2.34"));
- info = new ResourceSyncInfo("file.txt", "0", "27 Sep 2001 18:00:16", "", null, "");
+ info = new ResourceSyncInfo("file.txt", "0", 0, "", null, "", 0);
assertTrue(info.isAdded());
+ info = new ResourceSyncInfo("file.txt", "0", 0, "", null, "", ResourceSyncInfo.DUMMY_SYNC);
+ String entry = info.getEntryLine(true);
+ info = new ResourceSyncInfo(entry, null, 0);
+ assertTrue(info.getTimeStamp() == ResourceSyncInfo.NULL_TIMESTAMP);
+ assertTrue(entry.indexOf("dummy") != -1);
+
CVSTag tag = new CVSTag("v1", CVSTag.VERSION);
- info = new ResourceSyncInfo("file.txt", "1.1", "27 Sep 2001 18:00:16", "", tag, "");
+ info = new ResourceSyncInfo("file.txt", "1.1", timestamp, "", tag, "", 0);
CVSTag newTag = info.getTag();
assertTrue(newTag.getName().equals(tag.getName()) && newTag.getType() == tag.getType());
assertTrue(info.getRevision().equals("1.1"));
}
-}
+
+ public void testMergeTimestamps() throws CVSException {
+ ResourceSyncInfo info, info2;
+ long timestamp = 123000;
+ long timestamp2 = 654000;
+
+ info = new ResourceSyncInfo("/file.java/1.1//-kb/", null, timestamp);
+ assertTrue(!info.isMerged());
+ assertTrue(!info.isNeedsMerge(timestamp));
+
+ // entry lines the server can send
+ info = new ResourceSyncInfo("/file.java/1.1/+=/-kb/", null, timestamp);
+ String entryLine = info.getEntryLine(true);
+ info2 = new ResourceSyncInfo(entryLine, null, 0);
+ assertTrue(info.isMerged());
+ assertTrue(info.isNeedsMerge(timestamp));
+ assertTrue(!info.isNeedsMerge(timestamp2));
+ assertTrue(info.getTimeStamp() == timestamp);
+ assertTrue(info2.isMerged());
+ assertTrue(info2.isNeedsMerge(timestamp));
+ assertTrue(!info2.isNeedsMerge(timestamp2));
+ assertTrue(info2.getTimeStamp() == timestamp);
+
+ info = new ResourceSyncInfo("/file.java/1.1/+modified/-kb/", null, 0);
+ entryLine = info.getEntryLine(true);
+ info2 = new ResourceSyncInfo(entryLine, null, 0);
+
+ assertTrue(info.isMerged());
+ assertTrue(!info.isNeedsMerge(timestamp));
+ assertTrue(!info.isNeedsMerge(timestamp2));
+ assertTrue(info.getTimeStamp() == ResourceSyncInfo.NULL_TIMESTAMP);
+
+ assertTrue(info2.isMerged());
+ assertTrue(!info2.isNeedsMerge(timestamp));
+ assertTrue(!info2.isNeedsMerge(timestamp2));
+ assertTrue(info2.getTimeStamp() == ResourceSyncInfo.NULL_TIMESTAMP);
+ }
+
+ public void testTimestampCompatibility() throws CVSException {
+ }
+} \ No newline at end of file

Back to the top