diff options
author | Michael Valenta | 2004-10-25 20:05:52 +0000 |
---|---|---|
committer | Michael Valenta | 2004-10-25 20:05:52 +0000 |
commit | 2487b377c27180e5324ff6dc26f40dfeed7ca5cb (patch) | |
tree | 91c80da972ef07f11ecc85eb727de3625fa8d8a9 | |
parent | 3baa0f45b106227fa02977d8141259a396ef72dd (diff) | |
download | eclipse.platform.team-2487b377c27180e5324ff6dc26f40dfeed7ca5cb.tar.gz eclipse.platform.team-2487b377c27180e5324ff6dc26f40dfeed7ca5cb.tar.xz eclipse.platform.team-2487b377c27180e5324ff6dc26f40dfeed7ca5cb.zip |
9 files changed, 148 insertions, 46 deletions
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 7236be06c..e6a6cea5b 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,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Red Hat Incorporated - is/setExecutable() code *******************************************************************************/ package org.eclipse.team.internal.ccvs.core; @@ -95,6 +96,19 @@ public interface ICVSFile extends ICVSResource, ICVSStorage { boolean isReadOnly() throws CVSException; /** + * Sets the file to be executable (<code>ture</code>) or not executable + * (<code>false</code>) if the platform supports it. + */ + public void setExecutable(boolean executable) throws CVSException; + + /** + * Answers whether the file is executable or not. + * + * @returns <code>false</code> if the platform doesn't support the executable flag. + */ + public boolean isExecutable() throws CVSException; + + /** * Copy the resource to another file in the same directory * * This method is used by the command framework and should not be used by other clients. diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java index 15ec09e62..f71b20a86 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemovedHandler.java @@ -13,6 +13,7 @@ package org.eclipse.team.internal.ccvs.core.client; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.CVSException; import org.eclipse.team.internal.ccvs.core.ICVSFile; import org.eclipse.team.internal.ccvs.core.ICVSFolder; @@ -52,13 +53,18 @@ class RemovedHandler extends ResponseHandler { ICVSFile mFile = mParent.getFile(fileName); if ( ! mFile.isManaged()) { - throw new CVSException(Policy.bind("RemovedHandler.invalid", new Path(localDir).append(fileName).toString())); //$NON-NLS-1$ + throw new CVSException(Policy.bind("RemovedHandler.invalid", new Path(null, localDir).append(fileName).toString())); //$NON-NLS-1$ } // delete then unmanage the file - if (mFile.isReadOnly()) mFile.setReadOnly(false); - mFile.delete(); - mFile.unmanage(null); + try { + if (mFile.isReadOnly()) mFile.setReadOnly(false); + mFile.delete(); + mFile.unmanage(null); + } catch (CVSException e) { + // Just log and keep going + CVSProviderPlugin.log(e); + } } } diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java index 00ee08839..1d59df344 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Red Hat Incorporated - is/setExecutable() code *******************************************************************************/ package org.eclipse.team.internal.ccvs.core.client; @@ -578,7 +579,11 @@ public class Session { String filename = file.getName(); connection.writeLine("Modified " + filename); //$NON-NLS-1$ // send the default permissions for now - connection.writeLine(ResourceSyncInfo.getDefaultPermissions()); + if (file.isExecutable()) { + connection.writeLine(ResourceSyncInfo.getDefaultExecutablePermissions()); + } else { + connection.writeLine(ResourceSyncInfo.getDefaultPermissions()); + } sendFile(file, isBinary, sendBinary, monitor); } diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java index a8f331a23..1af7a337b 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/UpdateMergableOnly.java @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Red Hat Incorporated - is/setExecutable() code *******************************************************************************/ package org.eclipse.team.internal.ccvs.core.client; @@ -57,7 +58,7 @@ public class UpdateMergableOnly extends Update { if (ResourceSyncInfo.isMergedWithConflicts(entryBytes)) { // for merged-with-conflict, return a temp file adjustedFileName = ".##" + adjustedFileName + " " + ResourceSyncInfo.getRevision(entryBytes); //$NON-NLS-1$ //$NON-NLS-2$ - skippedFiles.add(((IContainer)mParent.getIResource()).getFile(new Path(fileName))); + skippedFiles.add(((IContainer)mParent.getIResource()).getFile(new Path(null, fileName))); } return super.getTargetFile(mParent, adjustedFileName, entryBytes); } @@ -72,6 +73,7 @@ public class UpdateMergableOnly extends Update { Date modTime, boolean binary, boolean readOnly, + boolean executable, IProgressMonitor monitor) throws CVSException { @@ -83,7 +85,7 @@ public class UpdateMergableOnly extends Update { // Now delete the file since it is not used mFile.delete(); } else { - super.receiveTargetFile(session, mFile, entryLine, modTime, binary, readOnly, monitor); + super.receiveTargetFile(session, mFile, entryLine, modTime, binary, readOnly, executable, 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 36e4e506a..3c88163d4 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Red Hat Incorporated - is/setExecutable() code *******************************************************************************/ package org.eclipse.team.internal.ccvs.core.client; @@ -51,6 +52,7 @@ public class UpdatedHandler extends ResponseHandler { protected static final int HANDLE_CREATED = ICVSFile.CREATED; private static final String READ_ONLY_FLAG = "u=rw"; //$NON-NLS-1$ + private static final String EXECUTE_FLAG = "x"; //$NON-NLS-1$ public UpdatedHandler(int handlerType) { this.handlerType = handlerType; @@ -84,12 +86,18 @@ public class UpdatedHandler extends ResponseHandler { boolean binary = ResourceSyncInfo.isBinary(entryBytes); boolean readOnly = permissionsLine.indexOf(READ_ONLY_FLAG) == -1; + boolean executable = permissionsLine.indexOf(EXECUTE_FLAG) != -1; - // The file may have been set as read-only by a previous checkout/update - if (mFile.isReadOnly()) mFile.setReadOnly(false); + try { + // The file may have been set as read-only by a previous checkout/update + if (mFile.isReadOnly()) mFile.setReadOnly(false); + } catch (CVSException e) { + // Just log and keep going + CVSProviderPlugin.log(e); + } try { - receiveTargetFile(session, mFile, entryLine, modTime, binary, readOnly, monitor); + receiveTargetFile(session, mFile, entryLine, modTime, binary, readOnly, executable, monitor); } catch (CVSException e) { // An error occurred while recieving the file. // If it is due to an invalid file name, @@ -105,7 +113,7 @@ public class UpdatedHandler extends ResponseHandler { return mParent.getFile(fileName); } - protected void receiveTargetFile(Session session, ICVSFile mFile, String entryLine, Date modTime, boolean binary, boolean readOnly, IProgressMonitor monitor) throws CVSException { + protected void receiveTargetFile(Session session, ICVSFile mFile, String entryLine, Date modTime, boolean binary, boolean readOnly, boolean executable, IProgressMonitor monitor) throws CVSException { // receive the file contents from the server session.receiveFile(mFile, binary, handlerType, monitor); @@ -129,7 +137,13 @@ public class UpdatedHandler extends ResponseHandler { CVSProviderPlugin.getPlugin().getFileModificationManager().updated(mFile); } mFile.setSyncInfo(newInfoWithTimestamp, modificationState); - if (readOnly) mFile.setReadOnly(true); + try { + if (readOnly) mFile.setReadOnly(true); + if (executable) mFile.setExecutable(true); + } catch (CVSException e) { + // Just log and keep going + CVSProviderPlugin.log(e); + } } } 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 b32220b79..71a8f45d5 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 @@ -7,37 +7,20 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Red Hat Incorporated - is/setExecutable() code *******************************************************************************/ package org.eclipse.team.internal.ccvs.core.resources; import java.io.File; import java.io.InputStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceStatus; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.*; import org.eclipse.team.core.TeamException; -import org.eclipse.team.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.ICVSFile; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; -import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource; -import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor; -import org.eclipse.team.internal.ccvs.core.ICVSRunnable; -import org.eclipse.team.internal.ccvs.core.ILogEntry; -import org.eclipse.team.internal.ccvs.core.Policy; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.client.Session; -import org.eclipse.team.internal.ccvs.core.syncinfo.BaserevInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.NotifyInfo; -import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; +import org.eclipse.team.internal.ccvs.core.syncinfo.*; import org.eclipse.team.internal.ccvs.core.util.Assert; /** @@ -159,7 +142,7 @@ public class EclipseFile extends EclipseResource implements ICVSFile { */ public void copyTo(String filename) throws CVSException { try { - IPath targetPath = new Path(filename); + IPath targetPath = new Path(null, filename); IFile targetFile = getIFile().getParent().getFile(targetPath); if (targetFile.exists()) { // There is a file in the target location. @@ -199,13 +182,13 @@ public class EclipseFile extends EclipseResource implements ICVSFile { break; case MERGED: // merging contents into a file that exists locally // Ensure we don't leave the file in a partially written state - IFile tempFile = file.getParent().getFile(new Path(file.getName() + TEMP_FILE_EXTENSION)); + IFile tempFile = file.getParent().getFile(new Path(null, file.getName() + TEMP_FILE_EXTENSION)); monitor.beginTask(null, 100); if (tempFile.exists()) tempFile.delete(true /* force */, Policy.subMonitorFor(monitor, 25)); tempFile.create(stream, true /*force*/, Policy.subMonitorFor(monitor, 25)); file.delete(false /* force */, true /* keep history */, Policy.subMonitorFor(monitor, 25)); - tempFile.move(new Path(file.getName()), false /*force*/, true /*history*/, Policy.subMonitorFor(monitor, 25)); + tempFile.move(new Path(null, file.getName()), false /*force*/, true /*history*/, Policy.subMonitorFor(monitor, 25)); monitor.done(); break; case UPDATE_EXISTING: // creating a new file so it should exist locally @@ -229,7 +212,15 @@ public class EclipseFile extends EclipseResource implements ICVSFile { * @see ICVSFile#setReadOnly() */ public void setReadOnly(boolean readOnly) throws CVSException { - getIFile().setReadOnly(readOnly); + ResourceAttributes attributes = resource.getResourceAttributes(); + if (attributes != null) { + attributes.setReadOnly(readOnly); + try { + resource.setResourceAttributes(attributes); + } catch (CoreException e) { + throw CVSException.wrapException(e); + } + } } /* @@ -240,6 +231,33 @@ public class EclipseFile extends EclipseResource implements ICVSFile { } /* + * @see ICVSFile#setExecutable() + */ + public void setExecutable(boolean executable) throws CVSException { + ResourceAttributes attributes = resource.getResourceAttributes(); + if (attributes != null) { + attributes.setExecutable(executable); + try { + resource.setResourceAttributes(attributes); + } catch (CoreException e) { + throw CVSException.wrapException(e); + } + } + } + + /* + * @see ICVSFile#isExectuable() + */ + public boolean isExecutable() throws CVSException { + ResourceAttributes attributes = resource.getResourceAttributes(); + if (attributes != null) { + return attributes.isExecutable(); + } else { + return false; + } + } + + /* * Typecasting helper */ public IFile getIFile() { @@ -351,8 +369,13 @@ public class EclipseFile extends EclipseResource implements ICVSFile { setBaserevInfo(new BaserevInfo(getName(), ResourceSyncInfo.getRevision(syncBytes))); } - // allow editing - setReadOnly(false); + try { + // allow editing + setReadOnly(false); + } catch (CVSException e) { + // Just log and keep going + CVSProviderPlugin.log(e); + } } }, monitor); @@ -395,8 +418,13 @@ public class EclipseFile extends EclipseResource implements ICVSFile { } setBaserevInfo(null); - // prevent editing - setReadOnly(true); + try { + // prevent editing + setReadOnly(true); + } catch (CVSException e) { + // Just log and keep going + CVSProviderPlugin.log(e); + } } }, monitor); } @@ -471,7 +499,12 @@ public class EclipseFile extends EclipseResource implements ICVSFile { BaserevInfo base = getBaserevInfo(); if (base != null) { setBaserevInfo(null); - setReadOnly(true); + try { + setReadOnly(true); + } catch (CVSException e) { + // Just log and keep going + CVSProviderPlugin.log(e); + } } } 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 f21718821..7703cd2fc 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Red Hat Incorporated - is/setExecutable() code *******************************************************************************/ package org.eclipse.team.internal.ccvs.core.resources; @@ -81,7 +82,7 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { public static RemoteFile create(String filePath, ICVSRepositoryLocation location) { Assert.isNotNull(filePath); Assert.isNotNull(location); - IPath path = new Path(filePath); + IPath path = new Path(null, filePath); RemoteFolder parent = new RemoteFolder(null /* parent */, location, path.removeLastSegments(1).toString(), null /* tag */); RemoteFile file = new RemoteFile(parent, Update.STATE_NONE, path.lastSegment(), null /* revision */, null /* keyword mode */, null /* tag */); parent.setChildren(new ICVSRemoteResource[] {file}); @@ -621,4 +622,19 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { public void setContents(IFile file, IProgressMonitor monitor) throws TeamException, CoreException { setContents(file.getContents(), monitor); } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ccvs.core.ICVSFile#setExecutable(boolean) + */ + public void setExecutable(boolean executable) throws CVSException { + // remote files are never executable + } + + /* (non-Javadoc) + * @see org.eclipse.team.internal.ccvs.core.ICVSFile#isExecutable() + */ + public boolean isExecutable() throws CVSException { + // remote files are always not executable + return false; + } } 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 ffe9bfa72..eefb5912a 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Red Hat Incorporated - is/setExecutable() code *******************************************************************************/ package org.eclipse.team.internal.ccvs.core.syncinfo; @@ -49,6 +50,7 @@ public class ResourceSyncInfo { // safe default permissions. Permissions are saved separately so that the correct permissions // can be sent back to the server on systems that don't save execute bits (e.g. windows). private static final String DEFAULT_PERMISSIONS = "u=rw,g=rw,o=r"; //$NON-NLS-1$ + private static final String DEFAULT_EXECUTABLE_PERMISSIONS = "u=rwx,g=rwx,o=rx"; //$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. @@ -320,6 +322,13 @@ public class ResourceSyncInfo { } /** + * Answers the default permissions string that is executable. + */ + public static String getDefaultExecutablePermissions() { + return DEFAULT_EXECUTABLE_PERMISSIONS; + } + + /** * Name equality between resource sync info objects. */ public boolean equals(Object other) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java index 7c520c151..9d3690a48 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java @@ -49,6 +49,7 @@ public class CheckoutToRemoteFolderOperation extends CheckoutOperation { Date modTime, boolean binary, boolean readOnly, + boolean executable, IProgressMonitor monitor) throws CVSException { @@ -62,6 +63,7 @@ public class CheckoutToRemoteFolderOperation extends CheckoutOperation { modTime, binary, readOnly, + executable, monitor); } finally { ((RemoteFile)mFile).doneReceivingContents(); @@ -74,6 +76,7 @@ public class CheckoutToRemoteFolderOperation extends CheckoutOperation { modTime, binary, readOnly, + executable, monitor); } } @@ -143,7 +146,7 @@ public class CheckoutToRemoteFolderOperation extends CheckoutOperation { IProgressMonitor monitor) throws CVSException { - IPath sandboxPath = new Path(folder.getRepositoryRelativePath()).removeLastSegments(1); + IPath sandboxPath = new Path(null, folder.getRepositoryRelativePath()).removeLastSegments(1); String pathString; if (sandboxPath.isEmpty()) { pathString = ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME; |