Search in sources :

Example 1 with SVNClientException

use of org.tigris.subversion.svnclientadapter.SVNClientException in project subclipse by subclipse.

the class StatusCacheManager method getURL.

// getStatuses returns null URL for svn:externals folder.  This will
// get the URL using svn info command on the local resource
private String getURL(ISVNStatus status) {
    String url = status.getUrlString();
    if (url == null && !(status.getTextStatus() == SVNStatusKind.UNVERSIONED) && !(status.getTextStatus() == SVNStatusKind.IGNORED)) {
        ISVNClientAdapter svnClient = null;
        try {
            svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
            SVNProviderPlugin.disableConsoleLogging();
            ISVNInfo info = svnClient.getInfoFromWorkingCopy(status.getFile());
            SVNUrl svnurl = info.getUrl();
            url = (svnurl != null) ? svnurl.toString() : null;
        } catch (SVNException e) {
        } catch (SVNClientException e) {
        } finally {
            SVNProviderPlugin.enableConsoleLogging();
            SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
        }
    }
    return url;
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 2 with SVNClientException

use of org.tigris.subversion.svnclientadapter.SVNClientException in project subclipse by subclipse.

the class CheckinResourcesCommand method run.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
   */
public void run(IProgressMonitor monitor) throws SVNException {
    commitError = false;
    postCommitError = null;
    final ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
    OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor, svnClient));
    try {
        // Prepare the parents list
        // we will Auto-commit parents if they are not already commited
        List<IContainer> parentsList = new ArrayList<IContainer>();
        List<IProject> projectList = new ArrayList<IProject>();
        for (IResource currentResource : resources) {
            IProject project = currentResource.getProject();
            if (!projectList.contains(project)) {
                projectList.add(project);
            }
            IContainer parent = currentResource.getParent();
            ISVNLocalResource svnParentResource = SVNWorkspaceRoot.getSVNResourceFor(parent);
            while (parent.getType() != IResource.ROOT && parent.getType() != IResource.PROJECT && !svnParentResource.hasRemote()) {
                if (!inCommitList(parent))
                    parentsList.add(parent);
                parent = parent.getParent();
                svnParentResource = svnParentResource.getParent();
            }
        }
        // convert parents and resources to an array of File
        int parents = parentsList.size();
        // change commit to non-recursive!!
        if (parents > 0)
            depth = IResource.DEPTH_ZERO;
        final File[] resourceFiles = new File[parents + resources.length];
        for (int i = 0; i < parents; i++) {
            resourceFiles[i] = ((IResource) parentsList.get(i)).getLocation().toFile();
        }
        for (int i = 0, j = parents; i < resources.length; i++, j++) {
            resourceFiles[j] = resources[i].getLocation().toFile();
        }
        IProject[] projects = new IProject[projectList.size()];
        projectList.toArray(projects);
        ISchedulingRule rule = MultiRule.combine(projects);
        SVNProviderPlugin.run(new ISVNRunnable() {

            public void run(final IProgressMonitor pm) throws SVNException {
                try {
                    notifyListener = new ISVNNotifyListener() {

                        public void logCommandLine(String commandLine) {
                        }

                        public void logCompleted(String message) {
                        }

                        public void logError(String message) {
                        }

                        public void logMessage(String message) {
                            if (message.startsWith("Transmitting file data"))
                                pm.subTask(message);
                        }

                        public void logRevision(long revision, String path) {
                        }

                        public void onNotify(File path, SVNNodeKind kind) {
                        }

                        public void setCommand(int command) {
                        }
                    };
                    pm.beginTask(null, resourceFiles.length);
                    pm.setTaskName("Checking in...");
                    svnClient.addNotifyListener(operationResourceCollector);
                    svnClient.addNotifyListener(notifyListener);
                    // then the resources the user has requested to commit
                    if (svnClient.canCommitAcrossWC())
                        svnClient.commitAcrossWC(resourceFiles, message, depth == IResource.DEPTH_INFINITE, keepLocks, true);
                    else
                        svnClient.commit(resourceFiles, message, depth == IResource.DEPTH_INFINITE, keepLocks);
                    postCommitError = svnClient.getPostCommitError();
                } catch (SVNClientException e) {
                    commitError = true;
                    throw SVNException.wrapException(e);
                } finally {
                    pm.done();
                    if (svnClient != null) {
                        svnClient.removeNotifyListener(operationResourceCollector);
                        svnClient.removeNotifyListener(notifyListener);
                        root.getRepository().returnSVNClient(svnClient);
                    }
                }
            }
        }, rule, Policy.monitorFor(monitor));
    } finally {
        OperationManager.getInstance().endOperation(true, operationResourceCollector.getOperationResources(), !commitError);
    }
}
Also used : ISVNRunnable(org.tigris.subversion.subclipse.core.ISVNRunnable) ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IProject(org.eclipse.core.resources.IProject) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNNodeKind(org.tigris.subversion.svnclientadapter.SVNNodeKind) ISVNNotifyListener(org.tigris.subversion.svnclientadapter.ISVNNotifyListener) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) IContainer(org.eclipse.core.resources.IContainer) File(java.io.File) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter) OperationProgressNotifyListener(org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)

Example 3 with SVNClientException

use of org.tigris.subversion.svnclientadapter.SVNClientException in project subclipse by subclipse.

the class CheckoutCommand method scrubProject.

/*
   * Delete the target projects before checking out
   * @param monitor - may be null !
   */
private void scrubProject(ISVNRemoteFolder resource, IProject project, IProgressMonitor monitor) throws SVNException {
    if (project == null) {
        if (monitor != null) {
            monitor.done();
        }
        return;
    }
    if (monitor != null) {
        monitor.beginTask("", 100);
        monitor.subTask(// $NON-NLS-1$
        Policy.bind("SVNProvider.Scrubbing_local_project_1", project.getName()));
    }
    try {
        File destPath = null;
        if (projectRoot != null) {
            destPath = new File(projectRoot.toFile(), project.getName());
        }
        // New location, just delete the project but not the content.
        if (destPath != null && !destPath.exists() && project != null && project.exists()) {
            project.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, monitor);
            project = null;
        }
        if (project != null && project.exists() && (destPath == null || destPath.exists())) {
            if (!project.isOpen()) {
                project.open((monitor != null) ? Policy.subMonitorFor(monitor, 10) : null);
            }
            // unmap the project from any previous repository provider
            if (RepositoryProvider.getProvider(project) != null)
                RepositoryProvider.unmap(project);
            IResource[] children = project.members(IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
            IProgressMonitor subMonitor = (monitor != null) ? Policy.subMonitorFor(monitor, 80) : null;
            if (subMonitor != null) {
                subMonitor.beginTask(null, children.length * 100);
            }
            ISVNClientAdapter clientSilent = null;
            try {
                for (int j = 0; j < children.length; j++) {
                    if (!children[j].getName().equals(".project")) {
                        // $NON-NLS-1$
                        if (clientSilent == null)
                            clientSilent = SVNProviderPlugin.getPlugin().getSVNClient();
                        ISVNInfo info = null;
                        try {
                            SVNUrl url = new SVNUrl(resource.getUrl().toString() + "/" + children[j].getProjectRelativePath());
                            try {
                                SVNProviderPlugin.disableConsoleLogging();
                                info = clientSilent.getInfo(url);
                            } catch (SVNClientException e2) {
                            } finally {
                                SVNProviderPlugin.enableConsoleLogging();
                            }
                        } catch (MalformedURLException e1) {
                        }
                        if (info != null)
                            children[j].delete(true, /* force */
                            (subMonitor != null) ? Policy.subMonitorFor(subMonitor, 100) : null);
                    }
                }
            } finally {
                if (subMonitor != null) {
                    subMonitor.done();
                }
                SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(clientSilent);
            }
        } else if (project != null) {
            // Make sure there is no directory in the local file system.
            File location = new File(project.getParent().getLocation().toFile(), project.getName());
            if (location.exists()) {
                deepDelete(location);
            }
        }
    } catch (CoreException e) {
        throw SVNException.wrapException(e);
    } finally {
        if (monitor != null) {
            monitor.subTask(" ");
            monitor.done();
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MalformedURLException(java.net.MalformedURLException) CoreException(org.eclipse.core.runtime.CoreException) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) File(java.io.File) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 4 with SVNClientException

use of org.tigris.subversion.svnclientadapter.SVNClientException in project subclipse by subclipse.

the class CleanupResourcesCommand method run.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
   */
public void run(IProgressMonitor monitor) throws SVNException {
    ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
    try {
        monitor.beginTask(null, 100 * resources.length);
        OperationManager.getInstance().beginOperation(svnClient);
        for (int i = 0; i < resources.length; i++) {
            if (resources[i].getLocation() != null) {
                svnClient.cleanup(resources[i].getLocation().toFile());
                cleanedUpResources.add(resources[i]);
            }
            monitor.worked(100);
        }
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        Set<IResource> refreshResources = new LinkedHashSet<IResource>();
        for (IResource resource : cleanedUpResources) {
            addToRefreshList(refreshResources, resource);
        }
        OperationManager.getInstance().endOperation(true, refreshResources);
        root.getRepository().returnSVNClient(svnClient);
        monitor.done();
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 5 with SVNClientException

use of org.tigris.subversion.svnclientadapter.SVNClientException in project subclipse by subclipse.

the class GetRemoteResourceCommand method run.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
   */
public void run(IProgressMonitor monitor) throws SVNException {
    monitor = Policy.monitorFor(monitor);
    // $NON-NLS-1$
    monitor.beginTask(Policy.bind("GetRemoteResourceCommand.getLogEntries"), 100);
    remoteResource = null;
    ISVNClientAdapter svnClient = repository.getSVNClient();
    ISVNInfo info;
    try {
        info = svnClient.getInfo(url, revision, revision);
    } catch (SVNClientException e) {
        throw new SVNException("Can't get remote resource " + url + " at revision " + revision, e);
    } finally {
        repository.returnSVNClient(svnClient);
    }
    if (info == null) {
        // no remote file
        remoteResource = null;
    } else {
        if (info.getNodeKind() == SVNNodeKind.FILE)
            remoteResource = new RemoteFile(// we don't know its parent
            null, repository, url, revision, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
        else
            remoteResource = new RemoteFolder(// we don't know its parent
            null, repository, url, revision, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
    }
    monitor.done();
}
Also used : RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNException(org.tigris.subversion.subclipse.core.SVNException) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)69 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)63 SVNException (org.tigris.subversion.subclipse.core.SVNException)24 IResource (org.eclipse.core.resources.IResource)19 File (java.io.File)16 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)14 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)12 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)11 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)11 CoreException (org.eclipse.core.runtime.CoreException)9 ArrayList (java.util.ArrayList)8 OperationProgressNotifyListener (org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)8 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)8 TeamException (org.eclipse.team.core.TeamException)7 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)6 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)5 MalformedURLException (java.net.MalformedURLException)4 IContainer (org.eclipse.core.resources.IContainer)4 IProject (org.eclipse.core.resources.IProject)4 ISVNRunnable (org.tigris.subversion.subclipse.core.ISVNRunnable)4