Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > subclipse commit: rev 82 - trunk/subclipse/core/src/org/tigris/subversion/subclipse/core/resources

subclipse
Discussion topic

Back to topic list

subclipse commit: rev 82 - trunk/subclipse/core/src/org/tigris/subversion/subclipse/core/resources

Author cchab
Full name chabanois cédric
Date 2003-07-23 14:30:00 PDT
Message Author: cchab
Date: Wed Jul 23 16:29:59 2003
New Revision: 82

Modified:
   trunk/subclipse/core​/src/org/tigris/subv​ersion/subclipse/cor​e/resources/SVNMoveD​eleteHook.java
Log:
don't let eclipse to move or delete a resource if we did not succeed with svn

Modified: trunk/subclipse/core​/src/org/tigris/subv​ersion/subclipse/cor​e/resources/SVNMoveD​eleteHook.java
====================​====================​====================​==================
--- trunk/subclipse/core​/src/org/tigris/subv​ersion/subclipse/cor​e/resources/SVNMoveD​eleteHook.java (original)
+++ trunk/subclipse/core​/src/org/tigris/subv​ersion/subclipse/cor​e/resources/SVNMoveD​eleteHook.java Wed Jul 23 16:29:59 2003
@@ -6,19 +6,22 @@
  * http://www.eclipse.o​rg/legal/cpl-v10.htm​l
  *
  * Contributors:
- * Daniel Bradby
+ * Daniel Bradby
+ * Cédric Chabanois (cchabanois at ifrance dot com)
  ********************​********************​********************​*******************/​
 package org.tigris.subversio​n.subclipse.core.res​ources;
 
-import java.io.File;
-
+import org.eclipse.core.int​ernal.resources.Reso​urceStatus;
 import org.eclipse.core.res​ources.IFile;
 import org.eclipse.core.res​ources.IFolder;
 import org.eclipse.core.res​ources.IProject;
 import org.eclipse.core.res​ources.IProjectDescr​iption;
+import org.eclipse.core.res​ources.IResource;
+import org.eclipse.core.res​ources.IResourceStat​us;
 import org.eclipse.core.res​ources.team.IMoveDel​eteHook;
 import org.eclipse.core.res​ources.team.IResourc​eTree;
 import org.eclipse.core.run​time.IProgressMonito​r;
+import org.eclipse.core.run​time.IStatus;
 import org.tigris.subversio​n.subclipse.core.ISV​NLocalFile;
 import org.tigris.subversio​n.subclipse.core.ISV​NLocalFolder;
 import org.tigris.subversio​n.subclipse.core.ISV​NResource;
@@ -33,11 +36,11 @@
 
     public boolean deleteFile(IResourceTree tree, IFile file, int updateFlags, IProgressMonitor monitor) {
 
- if (!isMoveable(file))
- return false;
+ ISVNLocalFile resource = new LocalFile(file);
+ try {
+ if (!resource.isManaged())
+ return false;
 
- try {
- ISVNLocalFile resource = new LocalFile(file);
             SVNClientAdapter svnClient = resource.getReposito​ry().getSVNClient();​
             monitor.beginTask(null, 1000);
             monitor.setTaskName(​"Working..");
@@ -53,7 +56,7 @@
                     "Error removing file",
                     e));
             e.printStackTrace();
- return false;
+ return true; // we attempted
         } finally {
             monitor.done();
         }
@@ -65,10 +68,11 @@
 
         ISVNLocalFolder resource = new LocalFolder(folder);
 
- if (!isMoveable(folder))
- return false;
+ try {
+ if (!resource.isManaged())
+ return false;
+
 
- try {
             SVNClientAdapter svnClient = resource.getReposito​ry().getSVNClient();​
             monitor.beginTask(null, 1000);
             monitor.setTaskName(​"Working..");
@@ -83,7 +87,7 @@
                     "Error removing folder",
                     e));
             e.printStackTrace();
- return false;
+ return true; // we attempted
         } finally {
             monitor.done();
         }
@@ -94,6 +98,10 @@
         return false;
     }
 
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.res​ources.team.IMoveDel​eteHook#moveFile(org​.eclipse.core.resour​ces.team.IResourceTr​ee, org.eclipse.core.res​ources.IFile, org.eclipse.core.res​ources.IFile, int, org.eclipse.core.run​time.IProgressMonito​r)
+ */
     public boolean moveFile(
         IResourceTree tree,
         IFile source,
@@ -101,15 +109,33 @@
         int updateFlags,
         IProgressMonitor monitor) {
 
- if (!isMoveable(source))
- return false;
-
         try {
- ISVNResource resource = new LocalFile(source);
+ ISVNLocalFile resource = new LocalFile(source);
+
+ if (!resource.isManaged())
+ return false; // pass
+
             SVNClientAdapter svnClient = resource.getReposito​ry().getSVNClient();​
             monitor.beginTask(null, 1000);
             monitor.setTaskName(​"Working..");
 
+ boolean force = (updateFlags & IResource.FORCE) != 0;
+ boolean keepHistory = (updateFlags & IResource.KEEP_HISTORY) != 0;
+ boolean isDeep = (updateFlags & IResource.SHALLOW) == 0;
+
+ // If the file is not in sync with the local file system and force is false,
+ // then signal that we have an error.
+ if (!force && !tree.isSynchronized(source, IResource.DEPTH_INFINITE)) {
+ String message = org.eclipse.core.int​ernal.utils.Policy.b​ind("localstore.reso​urceIsOutOfSync", source.getFullPath()​.toString()); //$NON-NLS-1$
+ IStatus status = new ResourceStatus(IReso​urceStatus.OUT_OF_SY​NC_LOCAL, source.getFullPath(), message);
+ tree.failed(status);
+ return true; // we attempted even if we failed
+ }
+
+ // Add the file contents to the local history if requested by the user.
+ if (keepHistory)
+ tree.addToLocalHistory(source);
+
             try {
                 OperationManager.get​Instance().beginOper​ation(svnClient);
                 
@@ -131,8 +157,6 @@
                 OperationManager.get​Instance().endOperat​ion();
             }
 
-
-
         } catch (SVNException e) {
             tree.failed(
                 new org.eclipse.core.run​time.Status(
@@ -142,7 +166,7 @@
                     "Error move file",
                     e));
             e.printStackTrace();
- return false;
+ return true; // we attempted
         } finally {
             monitor.done();
         }
@@ -156,14 +180,25 @@
         int updateFlags,
         IProgressMonitor monitor) {
 
- if (!isMoveable(source))
- return false;
-
         try {
+ ISVNLocalFolder resource = new LocalFolder(source);
+ if (!resource.isManaged())
+ return false;
+
             monitor.beginTask(null, 1000);
             monitor.setTaskName(​"Working..");
 
- ISVNResource resource = new LocalFolder(source);
+ // Check to see if we are synchronized with the local file system. If we are in sync then we can
+ // short circuit this method and do a file system only move. Otherwise we have to recursively
+ // try and move all resources, doing it in a best-effort manner.
+ boolean force = (updateFlags & IResource.FORCE) != 0;
+ if (!force && !tree.isSynchronized(source, IResource.DEPTH_INFINITE)) {
+ String message = org.eclipse.core.int​ernal.utils.Policy.b​ind("localstore.reso​urceIsOutOfSync", source.getFullPath()​.toString());//$NON​-NLS-1$
+ IStatus status = new ResourceStatus(IReso​urceStatus.ERROR, source.getFullPath(), message);
+ tree.failed(status);
+ return true;
+ }
+
             SVNClientAdapter svnClient = resource.getReposito​ry().getSVNClient();​
 
             try {
@@ -188,7 +223,7 @@
                     "Error move Folder " + source.getLocation(),
                     e));
             e.printStackTrace();
- return false;
+ return true; // we attempted
         } finally {
             monitor.done();
         }
@@ -204,37 +239,5 @@
         return false;
     }
 
- private boolean isMoveable(IFile file)
- {
- if (file.isTeamPrivateMember())
- return false;
-
- return isMoveable(new LocalFile(file));
- }
     
- private boolean isMoveable(IFolder folder)
- {
- if (folder.isTeamPrivateMember())
- return false;
-
- return isMoveable(new LocalFolder(folder));
- }
-
-
- private boolean isMoveable(LocalResource resource) {
- try {
- LocalResource svnResource = (LocalResource) resource;
- SVNClientAdapter svnClient = svnResource.getRepos​itory().getSVNClient​();
- Status status = svnClient.getSingleS​tatus(svnResource.ge​tFile());
-
- if (!status.isManaged())
- return false;
-
- } catch (Exception e1) {
- e1.printStackTrace();
- return false;
- }
-
- return true;
- }
 }

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@subc​lipse.tigris.org
For additional commands, e-mail: cvs-help at subclipse dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

subclipse commit: rev 82 - trunk/subclipse/core/src/org/tigris/subversion/subclipse/core/resources cchab chabanois cédric 2003-07-23 14:30:00 PDT
Messages per page: