[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [Subclipse-dev] Help needed - Subclipse performance problem

From: Brock Janiczak <brockj_at_tpg.com.au>
Date: 2006-02-26 02:18:44 CET

Mark Phippard wrote:
>> I wasn't, but i just had another very quick go and it looks like you can
>> remove the status refresh from the add command entirely.
>>
>
> Can you commit this and the Annotate patch?
>
I have commited the annotation patch, but i am a bit uneasy about the
change to the add operation. I have another patch that uses recursive
adds where possible. It has passed all of my testing, but i would
prefer it if someone else had a look. It is a very non trivial change
and makes assumption about the resources being passed in (they do not
overlap). The patch is attached to this email.

Index: D:/data/eclipse/workspace/core/src/org/tigris/subversion/subclipse/core/commands/AddResourcesCommand.java
===================================================================
--- D:/data/eclipse/workspace/core/src/org/tigris/subversion/subclipse/core/commands/AddResourcesCommand.java (revision 2099)
+++ D:/data/eclipse/workspace/core/src/org/tigris/subversion/subclipse/core/commands/AddResourcesCommand.java (working copy)
@@ -9,14 +9,14 @@
  *******************************************************************************/
 package org.tigris.subversion.subclipse.core.commands;
 
-import java.util.HashSet;
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceVisitor;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
@@ -61,14 +61,14 @@
         public void run(IProgressMonitor monitor) throws SVNException {
         monitor = Policy.monitorFor(monitor);
         
- // Visit the children of the resources using the depth in order to
- // determine which folders, text files and binary files need to be added
- // A TreeSet is needed for the folders so they are in the right order (i.e. parents created before children)
- final SortedSet folders = new TreeSet();
- // Sets are required for the files to ensure that files will not appear twice if there parent was added as well
- // and the depth isn't zero
- final HashSet files = new HashSet();
         
+ // Resoruces that were selected for addition.
+ // In the case of folders, they will be recursively added if the depth is infinite
+ List addedFiles = new ArrayList();
+ List addedFolders = new ArrayList();
+
+ final SortedSet autoAddedFolders = new TreeSet();
+
         for (int i=0; i<resources.length; i++) {
             
             final IResource currentResource = resources[i];
@@ -78,68 +78,65 @@
                 IContainer parent = currentResource.getParent();
                 ISVNLocalResource svnParentResource = SVNWorkspaceRoot.getSVNResourceFor(parent);
                 while (parent.getType() != IResource.ROOT && parent.getType() != IResource.PROJECT && ! svnParentResource.isManaged()) {
- folders.add(svnParentResource);
+ autoAddedFolders.add(svnParentResource);
                     parent = parent.getParent();
                     svnParentResource = svnParentResource.getParent();
                 }
-
- // Auto-add children accordingly to depth
- final SVNException[] exception = new SVNException[] { null };
- currentResource.accept(new IResourceVisitor() {
- public boolean visit(IResource resource) {
- try {
- ISVNLocalResource mResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
- // Add the resource is its not already managed and it was either
- // added explicitly (is equal currentResource) or is not ignored
- if ((! mResource.isManaged()) && (currentResource.equals(resource) || ! mResource.isIgnored())) {
- if (resource.getType() == IResource.FILE) {
- files.add(mResource);
- } else {
- folders.add(mResource);
- }
- }
- // Always return true and let the depth determine if children are visited
- return true;
- } catch (SVNException e) {
- exception[0] = e;
- return false;
- }
+
+ ISVNLocalResource mResource = SVNWorkspaceRoot.getSVNResourceFor(currentResource);
+ // Add the resource is its not already managed and it was either
+ // added explicitly (is equal currentResource) or is not ignored
+ if ((! mResource.isManaged()) || ! mResource.isIgnored()) {
+ if (currentResource.getType() == IResource.FILE) {
+ addedFiles.add(mResource);
+ } else {
+ addedFolders.add(mResource);
                     }
- }, depth, false);
- if (exception[0] != null) {
- throw exception[0];
                 }
+
             } catch (CoreException e) {
                 throw new SVNException(new Status(IStatus.ERROR, SVNProviderPlugin.ID, TeamException.UNABLE, Policy.bind("SVNTeamProvider.visitError", new Object[] {resources[i].getFullPath()}), e)); //$NON-NLS-1$
             }
         } // for
- // If an exception occured during the visit, throw it here
 
         // Add the folders, followed by files!
         ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
- monitor.beginTask(null, files.size() * 10 + (folders.isEmpty() ? 0 : 10));
+ monitor.beginTask(null, addedFiles.size() + autoAddedFolders.size() + (addedFolders.size() * 10));
         OperationManager.getInstance().beginOperation(svnClient);
         try {
- for(Iterator it=folders.iterator(); it.hasNext();) {
+ for(Iterator it=autoAddedFolders.iterator(); it.hasNext();) {
                 final ISVNLocalResource localResource = (ISVNLocalResource)it.next();
   
                 try {
                     svnClient.addDirectory(localResource.getIResource().getLocation().toFile(),false);
- localResource.refreshStatus();
+ monitor.worked(1);
                 } catch (SVNClientException e) {
                     throw SVNException.wrapException(e);
                 }
             }
+
+ for(Iterator it=addedFolders.iterator(); it.hasNext();) {
+ final ISVNLocalResource localResource = (ISVNLocalResource)it.next();
+
+ try {
+ svnClient.addDirectory(localResource.getIResource().getLocation().toFile(), (depth == IResource.DEPTH_INFINITE));
+ monitor.worked(10);
+ } catch (SVNClientException e) {
+ throw SVNException.wrapException(e);
+ }
+ }
 
- for(Iterator it=files.iterator(); it.hasNext();) {
+ for(Iterator it=addedFiles.iterator(); it.hasNext();) {
                 final ISVNLocalResource localResource = (ISVNLocalResource)it.next();
   
                 try {
                     svnClient.addFile(localResource.getIResource().getLocation().toFile());
                     // If file has read-only attribute set, remove it
- if (localResource.getIResource().getType() == IResource.FILE && localResource.getIResource().isReadOnly())
+ if (localResource.getIResource().getType() == IResource.FILE && localResource.getIResource().isReadOnly()) {
                         localResource.getIResource().setReadOnly(false);
- localResource.refreshStatus();
+ }
+
+ monitor.worked(1);
                 } catch (SVNClientException e) {
                     throw SVNException.wrapException(e);
                 }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subclipse.tigris.org
For additional commands, e-mail: dev-help@subclipse.tigris.org
Received on Sun Feb 26 02:21:10 2006

This is an archived mail posted to the Subclipse Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.