Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r1459 - in trunk: subclipse/core/src/org/tigris/subversion/subclipse/core/resources www/subclipse

subclipse
Discussion topic

Back to topic list

svn commit: r1459 - in trunk: subclipse/core/src/org/tigris/subversion/subclipse/core/resources www/subclipse

Author markphip
Full name Mark Phippard
Date 2005-07-18 08:25:40 PDT
Message Author: markphip
Date: Mon Jul 18 08:25:40 2005
New Revision: 1459

Modified:
   trunk/subclipse/core​/src/org/tigris/subv​ersion/subclipse/cor​e/resources/SVNFileM​odificationValidator​.java
   trunk/www/subclipse/​changes.html
Log:
Fixed problem in validateEdit(). I think this is an Eclipse problem. In
theory, we should only be called, and passed, an array of resources that are
read-only. Under certain conditions, we get called with other resources. An
easy example, is take the PDE option to migrate a plugin from 2.x to 3.x. When
you do this, we are passed an array of files to lock, even though the files
are not read only.

To workaround this problem I just added a secondary cleansing of the array to
remove any files that are not read only.

Modified: trunk/subclipse/core​/src/org/tigris/subv​ersion/subclipse/cor​e/resources/SVNFileM​odificationValidator​.java
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/su​bclipse/core/src/org​/tigris/subversion/s​ubclipse/core/resour​ces/SVNFileModificat​ionValidator.java?vi​ew=diff&rev=1459​&p1=trunk/subcli​pse/core/src/org/tig​ris/subversion/subcl​ipse/core/resources/​SVNFileModificationV​alidator.java&r1​=1458&p2=trunk/s​ubclipse/core/src/or​g/tigris/subversion/​subclipse/core/resou​rces/SVNFileModifica​tionValidator.java​&r2=1459
====================​====================​====================​==================
--- trunk/subclipse/core​/src/org/tigris/subv​ersion/subclipse/cor​e/resources/SVNFileM​odificationValidator​.java (original)
+++ trunk/subclipse/core​/src/org/tigris/subv​ersion/subclipse/cor​e/resources/SVNFileM​odificationValidator​.java Mon Jul 18 08:25:40 2005
@@ -1,5 +1,8 @@
 package org.tigris.subversio​n.subclipse.core.res​ources;
 
+import java.util.List;
+import java.util.ArrayList;
+
 import org.eclipse.core.res​ources.IFile;
 import org.eclipse.core.res​ources.IFileModifica​tionValidator;
 import org.eclipse.core.run​time.IStatus;
@@ -19,30 +22,52 @@
         SVNTeamProvider svnTeamProvider = null;
         RepositoryProvider provider = RepositoryProvider.g​etProvider(files[0].​getProject());
         if ((provider != null) && (provider instanceof SVNTeamProvider)) {
- if (context != null) {
- ISVNFileModification​ValidatorPrompt svnFileModificationV​alidatorPrompt =
- SVNProviderPlugin.ge​tPlugin().getSvnFile​ModificationValidato​rPrompt();
- if (svnFileModification​ValidatorPrompt != null) {
- if (!svnFileModificatio​nValidatorPrompt.pro​mpt(files, context))
- return SVNStatus.CANCEL_STATUS;
- comment = svnFileModificationV​alidatorPrompt.getCo​mment();
- stealLock = svnFileModificationV​alidatorPrompt.isSte​alLock();
- }
- }
- svnTeamProvider = (SVNTeamProvider)provider;
- LockResourcesCommand command = new LockResourcesCommand​(svnTeamProvider.get​SVNWorkspaceRoot(), files, stealLock, comment);
- try {
- command.run(new NullProgressMonitor());
- } catch (SVNException e) {
- e.printStackTrace();
- return SVNStatus.CANCEL_STATUS;
+ IFile[] readOnly = checkReadOnly(files);
+ if (readOnly.length > 0) {
+ if (context != null) {
+ ISVNFileModification​ValidatorPrompt svnFileModificationV​alidatorPrompt =
+ SVNProviderPlugin.ge​tPlugin().getSvnFile​ModificationValidato​rPrompt();
+ if (svnFileModification​ValidatorPrompt != null) {
+ if (!svnFileModificatio​nValidatorPrompt.pro​mpt(readOnly, context))
+ return SVNStatus.CANCEL_STATUS;
+ comment = svnFileModificationV​alidatorPrompt.getCo​mment();
+ stealLock = svnFileModificationV​alidatorPrompt.isSte​alLock();
+ }
+ }
+ svnTeamProvider = (SVNTeamProvider) provider;
+ LockResourcesCommand command = new LockResourcesCommand​(svnTeamProvider.get​SVNWorkspaceRoot(), readOnly, stealLock, comment);
+ try {
+ command.run(new NullProgressMonitor());
+ } catch (SVNException e) {
+ e.printStackTrace();
+ return SVNStatus.CANCEL_STATUS;
+ }
             }
- }
+ }
         return SVNStatus.OK_STATUS;
     }
 
     public IStatus validateSave(IFile file) {
         return SVNStatus.OK_STATUS;
     }
+
+
+ /**
+ * This method does a second check on the files in the array
+ * to verify their readOnly status. There seems to be an Eclipse
+ * bug under certain situations where we are passed files that do not have
+ * this flag set. This method will remove them from the array.
+ */
+ private IFile[] checkReadOnly(IFile[] files) {
+ List fileList = new ArrayList(files.length);
+ for (int i = 0; i < files.length; i++) {
+ try {
+ if (SVNWorkspaceRoot.ge​tSVNResourceFor(file​s[i]).getStatus().is​ReadOnly())
+ fileList.add(files[i]);
+ } catch (SVNException e) {
+ }
+ }
+ return (IFile[]) fileList.toArray(new IFile[fileList.size()]);
+ }
 
 }

Modified: trunk/www/subclipse/​changes.html
Url: http://subclipse.tig​ris.org/source/brows​e/subclipse/trunk/ww​w/subclipse/changes.​html?view=diff&r​ev=1459&p1=trunk​/www/subclipse/chang​es.html&r1=1458​&p2=trunk/www/sub​clipse/changes.html​&r2=1459
====================​====================​====================​==================
--- trunk/www/subclipse/​changes.html (original)
+++ trunk/www/subclipse/​changes.html Mon Jul 18 08:25:40 2005
@@ -118,6 +118,9 @@
  <li>Added workaround in svnClientAdapter for a JavaHL problem in retrieving
  the BASE revision for a newly added file. (<a
   href="http://subclipse.tig​ris.org/issues/show_​bug.cgi?id=339">339</a>)</li>
+ <li>Added workaround for an apparent Eclipse bug in validateEdit(). Sometimes we are
+ passed resources that are not read-only. So we simply added our own filter on the
+ array of resources that Eclipse passes us.</li>
 </ul>
 <hr />
 <a name="0.9.31"></a>

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

Messages

Show all messages in topic

svn commit: r1459 - in trunk: subclipse/core/src/org/tigris/subversion/subclipse/core/resources www/subclipse markphip Mark Phippard 2005-07-18 08:25:40 PDT
Messages per page: