diff options
author | Jean Michel-Lemieux | 2002-03-26 04:54:30 +0000 |
---|---|---|
committer | Jean Michel-Lemieux | 2002-03-26 04:54:30 +0000 |
commit | b053773fc4d0afb81b89dab3dbf6356a43cd80a6 (patch) | |
tree | 6b93a19c8947e6ef57ca30158a17351f83170f60 | |
parent | a1f2d5d77b3112282347f142729eee42be882037 (diff) | |
download | eclipse.platform.team-b053773fc4d0afb81b89dab3dbf6356a43cd80a6.tar.gz eclipse.platform.team-b053773fc4d0afb81b89dab3dbf6356a43cd80a6.tar.xz eclipse.platform.team-b053773fc4d0afb81b89dab3dbf6356a43cd80a6.zip |
*** empty log message ***
20 files changed, 272 insertions, 283 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSTeamProvider.java index fd59319d9..5dd334402 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 @@ -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.getType())); + info.getTimeStamp(), info.getKeywordMode(), tag, info.getPermissions())); } }; 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.getType()); + info.getTag(), info.getPermissions()); 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(ICVSFile.NULL_TIMESTAMP); + mFile.setTimeStamp(null /*set the timestamp to current time*/); } /* 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 494371c78..9a249a4b0 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 @@ -7,9 +7,9 @@ package org.eclipse.team.ccvs.core; import java.io.InputStream; import java.io.OutputStream; +import java.util.Date; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.CVSException; /** @@ -27,8 +27,6 @@ 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. */ @@ -76,7 +74,7 @@ public interface ICVSFile extends ICVSResource { * * @throws CVSFileNotFoundException if exists() = false */ - long getTimeStamp(); + Date getTimeStamp(); /** * Sets the current timestamp for this file. The supplied date must be in the @@ -87,7 +85,7 @@ public interface ICVSFile extends ICVSResource { * If the date is <code>null</code> then the current time is used as * the timestamp. */ - void setTimeStamp(long date) throws CVSException; + void setTimeStamp(Date 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/client/AbstractStructureVisitor.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java index 680b439a9..353f8662a 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/AbstractStructureVisitor.java @@ -139,7 +139,7 @@ abstract class AbstractStructureVisitor implements ICVSResourceVisitor { boolean isManaged = mFile.isManaged(); if (isManaged) { info = mFile.getSyncInfo(); - session.sendEntry(info.getEntryLine(false, mFile.getTimeStamp())); + session.sendEntry(info.getServerEntryLine(mFile.getTimeStamp())); } else { // If the file is not managed, send a questionable to the server if the file exists locally // A unmanaged, locally non-existant file results from the explicit use of the file name as a command argument diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/CheckedInHandler.java index a86a18084..d42ad027e 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, 0, ResourceSyncInfo.DUMMY_SYNC); + newInfo = new ResourceSyncInfo(entryLine, null, ResourceSyncInfo.DUMMY_DATE); } else { ResourceSyncInfo fileInfo = mFile.getSyncInfo(); - newInfo = new ResourceSyncInfo(entryLine, fileInfo.getPermissions(), mFile.getTimeStamp(), ResourceSyncInfo.REGULAR_SYNC); + newInfo = new ResourceSyncInfo(entryLine, fileInfo.getPermissions(), mFile.getTimeStamp()); } 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 1e13dd686..af1b61d91 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 @@ -32,10 +32,10 @@ class DiffStructureVisitor extends FileStructureVisitor { Policy.checkCanceled(monitor); if (mFile.isManaged()) { - session.sendEntry(mFile.getSyncInfo().getEntryLine(false)); + session.sendEntry(mFile.getSyncInfo().getEntryLine(false /*don't include timestamp*/)); } else { - ResourceSyncInfo info = new ResourceSyncInfo(mFile.getName(), ResourceSyncInfo.ADDED_REVISION, 0, null, null, null, ResourceSyncInfo.REGULAR_SYNC); - session.sendEntry(info.getEntryLine(false)); + ResourceSyncInfo info = new ResourceSyncInfo(mFile.getName(), ResourceSyncInfo.ADDED_REVISION, null, null, null, null); + session.sendEntry(info.getEntryLine(false /*don't include timestamp*/)); newFile = true; } 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 eb2c67af4..8ddac82fa 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,7 +39,7 @@ public class NewEntryHandler extends ResponseHandler { ICVSFile mFile = mParent.getFile(fileName); ResourceSyncInfo fileInfo = mFile.getSyncInfo(); - ResourceSyncInfo newInfo = new ResourceSyncInfo(entryLine, fileInfo.getPermissions(), 0, ResourceSyncInfo.DUMMY_SYNC); + ResourceSyncInfo newInfo = new ResourceSyncInfo(entryLine, fileInfo.getPermissions(), null); 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 224aad985..fab315200 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,10 +34,10 @@ 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.getType()); + info = new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions()); } if (! info.isAdded()) { - session.sendEntry(info.getEntryLine(false, mFile.getTimeStamp())); + session.sendEntry(info.getServerEntryLine(mFile.getTimeStamp())); boolean binary = info != null && KSubstOption.fromMode(info.getKeywordMode()).isBinary(); session.sendIsModified(mFile, binary, monitor); } 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 7ff598f8b..04591beff 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 @@ -72,7 +72,7 @@ class UpdatedHandler extends ResponseHandler { String entryLine = session.readLine(); String permissionsLine = session.readLine(); // temporary sync info for parsing the line received from the server - ResourceSyncInfo info = new ResourceSyncInfo(entryLine, permissionsLine, ResourceSyncInfo.NULL_TIMESTAMP, ResourceSyncInfo.REGULAR_SYNC); + ResourceSyncInfo info = new ResourceSyncInfo(entryLine, permissionsLine, null); // clear file update modifiers Date modTime = session.getModTime(); @@ -92,12 +92,12 @@ class UpdatedHandler extends ResponseHandler { if (readOnly) mFile.setReadOnly(true); // Set the timestamp in the file, set the result in the fileInfo - long timestamp = ICVSFile.NULL_TIMESTAMP; + Date timestamp = ResourceSyncInfo.DUMMY_DATE; if (modTime != null) { - timestamp = modTime.getTime(); + timestamp = modTime; } mFile.setTimeStamp(timestamp); mFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.getRevision(), - timestamp, info.getKeywordMode(), info.getTag(), info.getPermissions(), info.getType())); + timestamp, info.getKeywordMode(), info.getTag(), info.getPermissions())); } }
\ 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 156f6e298..b8a9ebbe0 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(), info.getType()); + ksubstMode, info.getTag(), info.getPermissions()); file.setSyncInfo(newInfo); } } catch (CVSException e) { 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 23816ee31..3c32f612b 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.NULL_TIMESTAMP, - mode, local.getParent().getFolderSyncInfo().getTag(), null, ResourceSyncInfo.REGULAR_SYNC); + info = new ResourceSyncInfo(local.getName(), ResourceSyncInfo.ADDED_REVISION, ResourceSyncInfo.DUMMY_DATE, + mode, local.getParent().getFolderSyncInfo().getTag(), null); revision = info.getRevision(); } else { info = remote.getSyncInfo(); @@ -206,9 +206,9 @@ public class CVSRemoteSyncElement extends RemoteSyncElement { return; } } - info = new ResourceSyncInfo(info.getName(), revision, ResourceSyncInfo.NULL_TIMESTAMP, + info = new ResourceSyncInfo(info.getName(), revision, ResourceSyncInfo.DUMMY_DATE, info.getKeywordMode(), local.getParent().getFolderSyncInfo().getTag(), - info.getPermissions(), ResourceSyncInfo.DUMMY_SYNC); + info.getPermissions()); 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 351803327..560f9bc6f 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 @@ -64,20 +64,19 @@ class EclipseFile extends EclipseResource implements ICVSFile { /* * @see ICVSFile#getTimeStamp() */ - public long getTimeStamp() { - return getIOFile().lastModified(); + public Date getTimeStamp() { + return new Date(getIOFile().lastModified()); } /* * @see ICVSFile#setTimeStamp(String) */ - public void setTimeStamp(long date) throws CVSException { - long timestamp = date; - if (date==NULL_TIMESTAMP) { + public void setTimeStamp(Date date) throws CVSException { + if (date==null) { // get the current time - timestamp = new Date().getTime(); + date = new Date(); } - getIOFile().setLastModified(timestamp); + getIOFile().setLastModified(date.getTime()); try { // Needed for workaround to Platform Core Bug # resource.refreshLocal(IResource.DEPTH_ZERO, null); @@ -103,7 +102,7 @@ class EclipseFile extends EclipseResource implements ICVSFile { ResourceSyncInfo info = getSyncInfo(); if (info.isAdded()) return false; if (info.isDeleted()) return true; - return getTimeStamp() != info.getTimeStamp(); + return !getTimeStamp().equals(info.getTimeStamp()); } } @@ -115,7 +114,7 @@ class EclipseFile extends EclipseResource implements ICVSFile { return true; } else { ResourceSyncInfo info = getSyncInfo(); - return getTimeStamp() != info.getTimeStamp(); + return !getTimeStamp().equals(info.getTimeStamp()); } } 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 87d85de3d..8f194b763 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 @@ -11,6 +11,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; +import java.util.Date; import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; @@ -119,7 +120,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.NULL_TIMESTAMP, ResourceSyncInfo.USE_SERVER_MODE, tag, ResourceSyncInfo.DEFAULT_PERMISSIONS, ResourceSyncInfo.REGULAR_SYNC)); + this(parent, workspaceSyncState, new ResourceSyncInfo(name, revision, ResourceSyncInfo.DUMMY_DATE, ResourceSyncInfo.USE_SERVER_MODE, tag, ResourceSyncInfo.DEFAULT_PERMISSIONS)); } public RemoteFile(RemoteFolder parent, ResourceSyncInfo info) { @@ -293,7 +294,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.getType()); + info = new ResourceSyncInfo(info.getName(), revision, info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions()); } /* @@ -321,38 +322,39 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi } } + /* + * @see ICVSFile#setReadOnly(boolean) + */ public void setReadOnly(boolean readOnly) throws CVSException { } + /* + * @see ICVSFile#isReadOnly() + */ public boolean isReadOnly() throws CVSException { return true; } - /** - * @see IManagedFile#getTimeStamp() + /* + * @see ICVSFile#getTimeStamp() */ - public long getTimeStamp() { + public Date getTimeStamp() { return info.getTimeStamp(); } - /** - * @see IManagedFile#setTimeStamp(String) + /* + * @see ICVSFile#setTimeStamp(Date) */ - public void setTimeStamp(long date) throws CVSException { + public void setTimeStamp(Date date) throws CVSException { } - /** - * @see IManagedFile#isDirty() - * - * A remote file is never dirty + /* + * @see ICVSFile#isDirty() */ public boolean isDirty() throws CVSException { return false; } - /** - * @see IManagedFile#isModified() - */ public boolean isModified() throws CVSException { // it is safe to always consider a remote file handle as modified. This will cause any // CVS command to fetch new contents from the server. 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 bf16ee24a..0a24a38a2 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.getType()); + info = new ResourceSyncInfo(info.getName(), info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions()); 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 ce88672ef..7159a8d2f 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 @@ -27,12 +27,14 @@ import org.eclipse.team.internal.ccvs.core.util.EmptyTokenizer; * * Example entry line from the CVS/Entry file: * - * /new.java/1.2/Fri Dec 07 00:17:52 2001/-kb/ + * /new.java/1.2/Fri Dec 7 00:17:52 2001/-kb/ * D/src//// * * @see ICVSResource#getSyncInfo() */ -public class ResourceSyncInfo { +public class ResourceSyncInfo implements Cloneable { + + public static final Date DUMMY_DATE = new Date(0); // 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). @@ -52,18 +54,16 @@ public class ResourceSyncInfo { 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 int TYPE_REGULAR = 1; + private static final int TYPE_MERGED = 2; + private static final int TYPE_MERGED_WITH_CONFLICTS = 3; - 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 TIMESTAMP_DUMMY = "dummy timestamp"; //$NON-NLS-1$ + private static final String TIMESTAMP_MERGED = "Result of merge"; //$NON-NLS-1$ + private static final String TIMESTAMP_MERGED_WITH_CONFLICT = TIMESTAMP_MERGED + "+"; //$NON-NLS-1$ - private static final String MERGE_MODIFIED = "+modified"; //$NON-NLS-1$ - private static final String MERGE_UNMODIFIED = "+="; //$NON-NLS-1$ + private static final String TIMESTAMP_SERVER_MERGED = "+modified"; //$NON-NLS-1$ + private static final String TIMESTAMP_SERVER_MERGED_WITH_CONFLICT = "+="; //$NON-NLS-1$ // a directory sync info will have nothing more than a name private boolean isDirectory = false; @@ -76,53 +76,26 @@ public class ResourceSyncInfo { // fields describing the synchronization of a resource in CVS parlance private String name; private String revision; - private long timeStamp; + private Date timeStamp; private String keywordMode; private CVSEntryLineTag tag; private String permissions; // type of sync - private int syncType = REGULAR_SYNC; + private int syncType = TYPE_REGULAR; /** * 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>. + * @param timestamp if not included in the entry line. May be <code>null</code>. * * @exception CVSException is thrown if the entry cannot be parsed. */ - public ResourceSyncInfo(String entryLine, String permissions, long timestamp, int syncType) throws CVSException { + public ResourceSyncInfo(String entryLine, String permissions, Date timestamp) 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); if (permissions != null) { @@ -130,7 +103,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(timestamp!=ICVSFile.NULL_TIMESTAMP) { + if(timestamp!=null) { this.timeStamp = timestamp; } } @@ -145,14 +118,13 @@ public class ResourceSyncInfo { * @param tag can be <code>null</code> * @param permissions can be <code>null</code> */ - public ResourceSyncInfo(String name, String revision, long timestamp, String keywordMode, CVSTag tag, String permissions, int syncType) { + public ResourceSyncInfo(String name, String revision, Date timestamp, String keywordMode, CVSTag tag, String permissions) { 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); } @@ -186,8 +158,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(long otherTimestamp) { - return syncType == MERGED_SYNC_WITH_CONFLICTS && timeStamp == otherTimestamp; + public boolean isNeedsMerge(Date otherTimestamp) { + return syncType == TYPE_MERGED_WITH_CONFLICTS && timeStamp.equals(otherTimestamp); } /** @@ -198,7 +170,7 @@ public class ResourceSyncInfo { * <code>false</code> for folders and for files that have not been merged. */ public boolean isMerged() { - return syncType == MERGED_SYNC || syncType == MERGED_SYNC_WITH_CONFLICTS; + return syncType == TYPE_MERGED || syncType == TYPE_MERGED_WITH_CONFLICTS; } /** @@ -228,68 +200,10 @@ public class ResourceSyncInfo { return isDeleted; } - /** - * Answers a CVS compatible entry line. The client can use this line to store in the CVS/Entry file or - * sent it to the server. - * - * @param includeTimeStamp determines if the timestamp will be included in the returned entry line. In - * some usages the timestamp should not be included in entry lines, for example when sending the entries - * to the server. - * - * @return a file or folder entry line reflecting the state of this sync object. - */ public String getEntryLine(boolean includeTimeStamp) { - return getEntryLine(includeTimeStamp, (String)null); + return getEntryLine(includeTimeStamp, null); } - - private String getEntryLine(boolean includeTimeStamp, String timestampOverride) { - - StringBuffer result = new StringBuffer(); - if(isDirectory) { - result.append(DIRECTORY_PREFIX); - result.append(name + "////"); //$NON-NLS-1$ - } else { - result.append(SEPERATOR); - result.append(name); - result.append(SEPERATOR); - - if(isDeleted){ - result.append(DELETED_PREFIX); - } - - result.append(revision); - result.append(SEPERATOR); - - if(includeTimeStamp) { - 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$ - result.append(SEPERATOR); - if (tag != null) { - result.append(tag.toEntryLineFormat(true)); - } - } - - return result.toString(); - } - /** * Same as <code>getEntryLine</code> except it considers merged files in entry line format. This is only * valid for sending the file to the server. @@ -301,17 +215,17 @@ public class ResourceSyncInfo { * * @return a file or folder entry line reflecting the state of this sync object. */ - public String getEntryLine(boolean includeTimeStamp, long fileTimestamp) { + public String getServerEntryLine(Date fileTimestamp) { String serverTimestamp; if(isMerged()) { if(isNeedsMerge(fileTimestamp)) { - serverTimestamp = MERGE_UNMODIFIED; + serverTimestamp = TIMESTAMP_SERVER_MERGED_WITH_CONFLICT; } else { - serverTimestamp = MERGE_MODIFIED; + serverTimestamp = TIMESTAMP_SERVER_MERGED; } return getEntryLine(true, serverTimestamp); } else { - return getEntryLine(includeTimeStamp); + return getEntryLine(false, null); } } @@ -363,7 +277,7 @@ public class ResourceSyncInfo { * * @return a string of the format "Thu Oct 18 20:21:13 2001" */ - public long getTimeStamp() { + public Date getTimeStamp() { return timeStamp; } @@ -415,6 +329,13 @@ public class ResourceSyncInfo { return getName().hashCode(); } + /* + * @see Object#toString() + */ + public String toString() { + return getEntryLine(true, null /*no timestamp override*/); + } + /** * Sets the tag for the resource. */ @@ -474,30 +395,29 @@ public class ResourceSyncInfo { // 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; + if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED) != -1) { + syncType = TYPE_MERGED; date = null; - } else if(date.indexOf(ResourceSyncInfo.MERGE_UNMODIFIED) != -1) { - syncType = MERGED_SYNC_WITH_CONFLICTS; + } else if(date.indexOf(ResourceSyncInfo.TIMESTAMP_SERVER_MERGED_WITH_CONFLICT) != -1) { + syncType = TYPE_MERGED_WITH_CONFLICTS; date = null; - } else if(date.indexOf(RESULT_OF_MERGE_CONFLICT)!=-1) { + } else if(date.indexOf(TIMESTAMP_MERGED_WITH_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; + syncType = TYPE_MERGED_WITH_CONFLICTS; + } else if(date.indexOf(TIMESTAMP_MERGED)!=-1) { + syncType = TYPE_MERGED; date = null; } if(date==null || "".equals(date)) { - timeStamp = NULL_TIMESTAMP; + timeStamp = null; } else { try { - timeStamp = CVSDateFormatter.entryLineToDate(date).getTime(); + timeStamp = CVSDateFormatter.entryLineToDate(date); } 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; + timeStamp = DUMMY_DATE; } } @@ -511,6 +431,55 @@ public class ResourceSyncInfo { } } + private String getEntryLine(boolean includeTimeStamp, String timestampOverride) { + StringBuffer result = new StringBuffer(); + + if(isDirectory) { + result.append(DIRECTORY_PREFIX); + result.append(name + "////"); //$NON-NLS-1$ + } else { + result.append(SEPERATOR); + result.append(name); + result.append(SEPERATOR); + + if(isDeleted){ + result.append(DELETED_PREFIX); + } + + result.append(revision); + result.append(SEPERATOR); + + if(includeTimeStamp) { + String entryLineTimestamp = ""; + if(timestampOverride!=null) { + entryLineTimestamp = timestampOverride; + } else { + switch(syncType) { + case TYPE_REGULAR: + if(timeStamp==DUMMY_DATE) { + entryLineTimestamp = TIMESTAMP_DUMMY; + } else { + entryLineTimestamp = CVSDateFormatter.dateToEntryLine(timeStamp); + } break; + case TYPE_MERGED: + entryLineTimestamp = TIMESTAMP_MERGED; break; + case TYPE_MERGED_WITH_CONFLICTS: + entryLineTimestamp = TIMESTAMP_MERGED_WITH_CONFLICT + CVSDateFormatter.dateToEntryLine(timeStamp); break; + } + } + result.append(entryLineTimestamp); + } + result.append(SEPERATOR); + result.append(keywordMode == null ? "" : keywordMode); //$NON-NLS-1$ + result.append(SEPERATOR); + if (tag != null) { + result.append(tag.toEntryLineFormat(true)); + } + } + + return result.toString(); + } + /** * Sets the version and decides if the revision is for a deleted resource the revision field * will not include the deleted prefix '-'. @@ -526,18 +495,11 @@ public class ResourceSyncInfo { isDeleted = false; } } - - /** - * Returns the type of this sync info - */ - public int getType() { - return syncType; - } - /* - * @see Object#toString() + * @see Object#clone() */ - public String toString() { - return getEntryLine(true); + public Object clone() { + ResourceSyncInfo clonedInfo = new ResourceSyncInfo(getName(), getRevision(), getTimeStamp(), getKeywordMode(), getTag(), getPermissions()); + return clonedInfo; } }
\ 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 43ffc7cae..abed9323a 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(), info.getType())); + mFile.setSyncInfo(new ResourceSyncInfo(info.getName(), info.DELETED_PREFIX + info.getRevision(), info.getTimeStamp(), info.getKeywordMode(), info.getTag(), info.getPermissions())); } } } 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(), info.getType())); + mFile.setSyncInfo((ResourceSyncInfo)info.clone()); } 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(), fromInfo.getType())); + fromFile.setSyncInfo(new ResourceSyncInfo(fromInfo.getName(), fromInfo.DELETED_PREFIX + fromInfo.getRevision(), fromInfo.getTimeStamp(), fromInfo.getKeywordMode(), fromInfo.getTag(), fromInfo.getPermissions())); } } @@ -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(), info.getType())); + toFile.setSyncInfo((ResourceSyncInfo)info.clone()); } } else if (fromInfo != null) { - toFile.setSyncInfo(new ResourceSyncInfo(toFile.getName(), ResourceSyncInfo.ADDED_REVISION, ResourceSyncInfo.NULL_TIMESTAMP, fromInfo.getKeywordMode(), fromInfo.getTag(), fromInfo.getPermissions(), ResourceSyncInfo.DUMMY_SYNC)); + toFile.setSyncInfo(new ResourceSyncInfo(toFile.getName(), ResourceSyncInfo.ADDED_REVISION, ResourceSyncInfo.DUMMY_DATE, fromInfo.getKeywordMode(), fromInfo.getTag(), fromInfo.getPermissions())); } } catch (CVSException e) { 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 3bdb35449..854567ea2 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 @@ -149,7 +149,7 @@ public class SyncFileWriter implements IResourceChangeListener { 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, ResourceSyncInfo.NULL_TIMESTAMP, ResourceSyncInfo.REGULAR_SYNC); + ResourceSyncInfo info = new ResourceSyncInfo(line, null, null); infos.put(info.getName(), info); } } @@ -161,11 +161,11 @@ public class SyncFileWriter implements IResourceChangeListener { String line = entriesLog[i]; if (line.startsWith(ADD_TAG)) { line = line.substring(ADD_TAG.length()); - ResourceSyncInfo info = new ResourceSyncInfo(line, null, ResourceSyncInfo.NULL_TIMESTAMP, ResourceSyncInfo.REGULAR_SYNC); + ResourceSyncInfo info = new ResourceSyncInfo(line, null, null); infos.put(info.getName(), info); } else if (line.startsWith(REMOVE_TAG)) { line = line.substring(REMOVE_TAG.length()); - ResourceSyncInfo info = new ResourceSyncInfo(line, null, ResourceSyncInfo.NULL_TIMESTAMP, ResourceSyncInfo.REGULAR_SYNC); + ResourceSyncInfo info = new ResourceSyncInfo(line, null, null); infos.remove(info.getName()); } } 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 6052f86b5..324eef064 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 @@ -56,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, CVSDateFormatter.dateToEntryLine(new Date(syncInfo.getTimeStamp()))); + createLabel(composite, CVSDateFormatter.dateToEntryLine(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 84be67f13..1eab2cb2d 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 @@ -26,6 +26,9 @@ public class CVSTestSetup extends TestSetup { public static CVSRepositoryLocation repository; + // allows running those suites that don't require a connection to a server + private static boolean DONT_CONNECT = false; + // Static initializer for constants static { loadProperties(); @@ -64,6 +67,15 @@ public class CVSTestSetup extends TestSetup { super(test); } + /** + * Constructor for CVSTestSetup. + */ + public CVSTestSetup(Test test, boolean dontConnect) { + super(test); + DONT_CONNECT = dontConnect; + } + + /* * Use rsh to delete any contents of the repository and initialize it again */ @@ -84,8 +96,8 @@ public class CVSTestSetup extends TestSetup { } } - public void setUp() throws CVSException { - if (repository == null) + public void setUp() throws CVSException { + if (repository == null && !DONT_CONNECT) repository = setupRepository(REPOSITORY_LOCATION); } @@ -114,8 +126,6 @@ public class CVSTestSetup extends TestSetup { } public void tearDown() throws CVSException { - // Nothing to do here } - } 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 51a77c663..bc23deb61 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.NULL_TIMESTAMP, "", CVSTag.DEFAULT, "", ResourceSyncInfo.DUMMY_SYNC); + return new ResourceSyncInfo(resource.getName(), "1.1", ResourceSyncInfo.DUMMY_DATE, "", CVSTag.DEFAULT, ""); } 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 b1c251062..a2023966a 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 @@ -3,8 +3,16 @@ package org.eclipse.team.tests.ccvs.core.cvsresources; * (c) Copyright IBM Corp. 2000, 2002. * All Rights Reserved. */ +import java.io.ByteArrayInputStream; +import java.io.File; +import java.util.Date; + import junit.framework.Test; import junit.framework.TestSuite; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; import org.eclipse.team.ccvs.core.CVSTag; import org.eclipse.team.internal.ccvs.core.CVSException; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; @@ -13,8 +21,6 @@ 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(); } @@ -25,140 +31,152 @@ public class ResourceSyncInfoTest extends EclipseTest { public static Test suite() { TestSuite suite = new TestSuite(ResourceSyncInfoTest.class); - return new CVSTestSetup(suite); + return new CVSTestSetup(suite, true /*don't need to connect for these tests*/); } - /** - * Testing that the resource sync parses entry lines correctly. - */ public void testEntryLineParsing() { String entryLine; // testing malformed entry lines first try { - new ResourceSyncInfo("//////", null, 0, 0); + new ResourceSyncInfo("//////", null, null); fail(); } catch(CVSException e) { } try { - new ResourceSyncInfo("//1.1///", null, 0, 0); + new ResourceSyncInfo("//1.1///", null, null); fail(); } catch(CVSException e) { } try { - new ResourceSyncInfo("/file.txt////", null, 0, 0); + new ResourceSyncInfo("/file.txt////", null, null); fail(); } catch(CVSException e) { } try { - new ResourceSyncInfo("/file.txt//////////", null, 0, 0); + new ResourceSyncInfo("/file.txt//////////", null, null); fail(); } catch(CVSException e) { } } - /** - * Testing that the entry line constructor - */ - public void testEntryLineConstructor() { - try { - ResourceSyncInfo info; - 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/something/-k/", null, 0); - assertTrue(info.isAdded()); - - info = new ResourceSyncInfo("/file.java/1.0/Mon Feb 25 21:44:02 2002/-k/Tv1", null, 0); - assertTrue(info.getTag() != null); - - 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/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/Mon Feb 25 21:44:02 2002/-k/Tv1", permissions, 0); - assertTrue(info.getPermissions().equals(permissions)); - - info = new ResourceSyncInfo("D/file.java////", null, 0); - assertTrue(info.isDirectory()); - - } catch(CVSException e) { - fail("end"); - } + public void testEntryLineConstructor() throws CVSException { + ResourceSyncInfo info; + info = new ResourceSyncInfo("/file.java/-1.1/Mon Feb 25 21:44:02 2002/-k/", null, null); + assertTrue(info.isDeleted()); + + info = new ResourceSyncInfo("/file.java/0/something/-k/", null, null); + assertTrue(info.isAdded()); + + info = new ResourceSyncInfo("/file.java/1.0/Mon Feb 25 21:44:02 2002/-k/Tv1", null, null); + assertTrue(info.getTag() != null); + + Date timestamp = new Date(123000); + info = new ResourceSyncInfo("/file.java/1.0/Mon Feb 25 21:44:02 2002/-k/Tv1", null, timestamp); + assertTrue(info.getTimeStamp().equals(timestamp)); + + info = new ResourceSyncInfo("/file.java/0/Mon Feb 25 21:44:02 2002/-k/", null, timestamp); + assertTrue(info.getTimeStamp().equals(timestamp)); + + String permissions = "u=rwx,g=rwx,o=rwx"; + info = new ResourceSyncInfo("/file.java/2.0/Mon Feb 25 21:44:02 2002/-k/Tv1", permissions, null); + assertTrue(info.getPermissions().equals(permissions)); + + info = new ResourceSyncInfo("D/file.java////", null, null); + assertTrue(info.isDirectory()); } - /** - * Testing the parameter constructor - */ public void testConstructor() throws CVSException { ResourceSyncInfo info; info = new ResourceSyncInfo("folder"); assertTrue(info.isDirectory()); - long timestamp = 123456; - info = new ResourceSyncInfo("file.txt", "-2.34", timestamp, "", null, "", 0); + Date timestamp = new Date(123000); + info = new ResourceSyncInfo("file.txt", "-2.34", timestamp, "", null, ""); assertTrue(info.isDeleted()); assertTrue(info.getRevision().equals("2.34")); - info = new ResourceSyncInfo("file.txt", "0", 0, "", null, "", 0); - assertTrue(info.isAdded()); - - info = new ResourceSyncInfo("file.txt", "0", 0, "", null, "", ResourceSyncInfo.DUMMY_SYNC); + info = new ResourceSyncInfo("file.txt", "0", ResourceSyncInfo.DUMMY_DATE, "", null, ""); String entry = info.getEntryLine(true); - info = new ResourceSyncInfo(entry, null, 0); - assertTrue(info.getTimeStamp() == ResourceSyncInfo.NULL_TIMESTAMP); + assertTrue(info.isAdded()); assertTrue(entry.indexOf("dummy") != -1); CVSTag tag = new CVSTag("v1", CVSTag.VERSION); - info = new ResourceSyncInfo("file.txt", "1.1", timestamp, "", tag, "", 0); + info = new ResourceSyncInfo("file.txt", "1.1", timestamp, "", tag, ""); CVSTag newTag = info.getTag(); - assertTrue(newTag.getName().equals(tag.getName()) && newTag.getType() == tag.getType()); + assertTrue(newTag.getName().equals(tag.getName())); assertTrue(info.getRevision().equals("1.1")); } public void testMergeTimestamps() throws CVSException { ResourceSyncInfo info, info2; - long timestamp = 123000; - long timestamp2 = 654000; + Date timestamp = new Date(123000); + Date timestamp2 = new Date(654000); info = new ResourceSyncInfo("/file.java/1.1//-kb/", null, timestamp); assertTrue(!info.isMerged()); assertTrue(!info.isNeedsMerge(timestamp)); - // entry lines the server can send + // test merged entry lines the server and ensure that their entry line format is compatible 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); + info2 = new ResourceSyncInfo(entryLine, null, null); + assertTrue(info.isMerged() && info2.isMerged()); + assertTrue(info.isNeedsMerge(timestamp) && info2.isNeedsMerge(timestamp)); + assertTrue(!info.isNeedsMerge(timestamp2) && !info2.isNeedsMerge(timestamp2)); + assertTrue(info.getTimeStamp().equals(timestamp) && info2.getTimeStamp().equals(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); + info = new ResourceSyncInfo("/file.java/1.1/+modified/-kb/", null, null); 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); + info2 = new ResourceSyncInfo(entryLine, null, null); + assertTrue(info.isMerged() && info2.isMerged()); + assertTrue(!info.isNeedsMerge(timestamp) && !info2.isNeedsMerge(timestamp)); + assertTrue(!info.isNeedsMerge(timestamp2) && !info2.isNeedsMerge(timestamp2)); + assertTrue(info.getTimeStamp()==null && info2.getTimeStamp()==null); } - public void testTimestampCompatibility() throws CVSException { + public void testTimestampCompatibility() throws CVSException, CoreException { + String entryLine1 = "/a.bin/1.1/Mon Feb 9 21:44:02 2002/-kb/"; + String entryLine2 = "/a.bin/1.1/Mon Feb 9 21:44:02 2002/-kb/"; + String entryLine3 = "/a.bin/1.1/Mon Feb 09 21:44:02 2002/-kb/"; + ResourceSyncInfo info1 = new ResourceSyncInfo(entryLine1, null, null); + ResourceSyncInfo info2 = new ResourceSyncInfo(entryLine2, null, null); + ResourceSyncInfo info3 = new ResourceSyncInfo(entryLine3, null, null); + Date date1 = info1.getTimeStamp(); + Date date2 = info2.getTimeStamp(); + Date date3 = info3.getTimeStamp(); + assertTrue(date1.equals(date2)); + assertTrue(date1.equals(date3)); + assertTrue(date2.equals(date3)); + + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("testTimeStamp"); + project.create(null); project.open(null); + IFile file = project.getFile("test.txt"); + file.create(new ByteArrayInputStream("one".getBytes()), true, null); + File ioFile = file.getLocation().toFile(); + ioFile.setLastModified(info1.getTimeStamp().getTime()); + Date ioFileDate = new Date(ioFile.lastModified()); + assertTrue(ioFileDate.equals(info1.getTimeStamp())); + + ioFile.setLastModified(info2.getTimeStamp().getTime()); + ioFileDate = new Date(ioFile.lastModified()); + assertTrue(ioFileDate.equals(info2.getTimeStamp())); + + String entryLine4 = "/a.bin/1.1/Tue Mar 12 20:59:01 2002/-kb/"; + ResourceSyncInfo info4 = new ResourceSyncInfo(entryLine4, null, null); + + ioFile.setLastModified(info4.getTimeStamp().getTime()); + ioFileDate = new Date(ioFile.lastModified()); + //assertTrue(ioFileDate.equals(info4.getTimeStamp())); + + for(int i=0 ; i < 1000; i++) { + Date date = new Date(info4.getTimeStamp().getTime() + (1000*i)); + ioFile.setLastModified(date.getTime()); + if(ioFile.lastModified() != date.getTime()) { + System.out.println("Different date: " + date + " file: " + new Date(ioFile.lastModified())); + } + } + } }
\ No newline at end of file |