Search in sources :

Example 41 with ISVNClientAdapter

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

the class ShowDifferencesAsUnifiedDiffOperationWC method execute.

protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
    ISVNClientAdapter client = null;
    ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(toUrl.toString());
    if (repository != null)
        client = repository.getSVNClient();
    if (client == null)
        client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
    try {
        client.diff(path, toUrl, toRevision, file, true);
        if (monitor.isCanceled())
            canceled = true;
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        monitor.done();
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 42 with ISVNClientAdapter

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

the class CommitOperation method execute.

protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
    postCommitError = null;
    monitor.beginTask(null, resourcesToAdd.length + resourcesToDelete.length + resourcesToCommit.length);
    try {
        svnClient = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
        if (resourcesToAdd.length > 0) {
            Map<SVNTeamProvider, List<IResource>> table = getProviderMapping(resourcesToAdd);
            if (table.get(null) != null) {
                throw new SVNException(// $NON-NLS-1$
                Policy.bind("RepositoryManager.addErrorNotAssociated"));
            }
            Set<SVNTeamProvider> keySet = table.keySet();
            for (SVNTeamProvider provider : keySet) {
                List<IResource> list = table.get(provider);
                IResource[] providerResources = list.toArray(new IResource[list.size()]);
                provider.add(providerResources, IResource.DEPTH_ZERO, Policy.subMonitorFor(monitor, resourcesToAdd.length));
            }
        }
        if (resourcesToDelete.length > 0) {
            // use an adapter that will log to console
            ISVNClientAdapter svnDeleteClient = null;
            try {
                Map<SVNTeamProvider, List<IResource>> table = getProviderMapping(resourcesToDelete);
                if (table.get(null) != null) {
                    throw new SVNException(// $NON-NLS-1$
                    Policy.bind("RepositoryManager.addErrorNotAssociated"));
                }
                Set<SVNTeamProvider> keySet = table.keySet();
                for (SVNTeamProvider provider : keySet) {
                    List<IResource> list = table.get(provider);
                    File[] files = new File[list.size()];
                    int i = 0;
                    for (IResource resource : list) {
                        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                        if (svnDeleteClient == null)
                            svnDeleteClient = svnResource.getRepository().getSVNClient();
                        files[i] = svnResource.getFile();
                        i++;
                    }
                    svnDeleteClient.remove(files, true);
                }
            } catch (SVNClientException e) {
                throw new TeamException(e.getMessage());
            } finally {
                SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnDeleteClient);
            }
        }
        setAtomicCommitMode();
        Map<ProjectAndRepository, List<IResource>> table = getCommitProviderMapping(resourcesToCommit);
        Set<ProjectAndRepository> keySet = table.keySet();
        for (ProjectAndRepository mapKey : keySet) {
            SVNTeamProvider provider = mapKey.getTeamProvider();
            List<IResource> list = table.get(mapKey);
            IResource[] providerResources = new IResource[list.size()];
            list.toArray(providerResources);
            postCommitError = provider.checkin(providerResources, commitComment, keepLocks, IResource.DEPTH_ZERO, Policy.subMonitorFor(monitor, providerResources.length));
            for (IResource providerResource : providerResources) {
                if (!providerResource.exists()) {
                    SVNProviderPlugin.getPlugin().getStatusCacheManager().removeStatus(providerResource);
                }
            }
            if (postCommitError != null) {
                Display.getDefault().syncExec(new Runnable() {

                    public void run() {
                        MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("CommitDialog.title"), postCommitError);
                    }
                });
            }
        }
    } catch (TeamException e) {
        throw SVNException.wrapException(e);
    } finally {
        monitor.done();
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
        // refresh the Synch view
        SVNProviderPlugin.broadcastModificationStateChanges(resourcesToCommit);
    }
}
Also used : SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) TeamException(org.eclipse.team.core.TeamException) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 43 with ISVNClientAdapter

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

the class ExportOperation method execute.

protected void execute(SVNTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws SVNException, InterruptedException {
    ISVNClientAdapter client = null;
    ISVNRepositoryLocation repository = null;
    try {
        for (int i = 0; i < resources.length; i++) {
            if (client == null) {
                repository = SVNWorkspaceRoot.getSVNResourceFor(resources[i]).getRepository();
                client = repository.getSVNClient();
            }
            File srcPath = new File(resources[i].getLocation().toString());
            File destPath = new File(directory + File.separator + resources[i].getName());
            try {
                client.doExport(srcPath, destPath, true);
            } catch (SVNClientException e) {
                throw SVNException.wrapException(e);
            }
        }
    } catch (SVNException e) {
        if (e.operationInterrupted()) {
            showCancelledMessage();
        } else {
            collectStatus(e.getStatus());
        }
    } finally {
        if (repository != null) {
            repository.returnSVNClient(client);
        }
        monitor.done();
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SVNException(org.tigris.subversion.subclipse.core.SVNException) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 44 with ISVNClientAdapter

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

the class ExportRemoteFolderOperation method execute.

protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
    ISVNClientAdapter client = null;
    try {
        client = folder.getRepository().getSVNClient();
        try {
            client.doExport(folder.getUrl(), directory, revision, true);
        } catch (SVNClientException e) {
            throw SVNException.wrapException(e);
        }
    } catch (SVNException e) {
        if (e.operationInterrupted()) {
            showCancelledMessage();
        } else {
            collectStatus(e.getStatus());
        }
    } finally {
        folder.getRepository().returnSVNClient(client);
        monitor.done();
    }
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 45 with ISVNClientAdapter

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

the class SvnWizardNewRepositoryPage method performFinish.

public boolean performFinish() {
    success = true;
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            ISVNClientAdapter svnClient = null;
            try {
                SVNProviderPlugin provider = SVNProviderPlugin.getPlugin();
                String url = getUrl();
                if (provider.getRepositories().isKnownRepository(url, true)) {
                    MessageDialog.openError(getShell(), Policy.bind("NewRepositoryDialog.title"), // $NON-NLS-1$
                    Policy.bind("NewRepositoryDialog.alreadyExists"));
                    success = false;
                    return;
                }
                svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
                File path = new File(folderText.getText().trim());
                if (!path.exists())
                    path.mkdirs();
                svnClient.createRepository(path, ISVNClientAdapter.REPOSITORY_FSTYPE_FSFS);
                if (connectionButton.getSelection()) {
                    Properties properties = new Properties();
                    // $NON-NLS-1$
                    properties.setProperty("url", url);
                    ISVNRepositoryLocation repository = provider.getRepositories().createRepository(properties);
                    provider.getRepositories().addOrUpdateRepository(repository);
                }
            } catch (Exception e) {
                MessageDialog.openError(getShell(), Policy.bind("NewRepositoryDialog.title"), // $NON-NLS-1$
                e.getLocalizedMessage());
                success = false;
            } finally {
                SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
            }
        }
    });
    return success;
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNProviderPlugin(org.tigris.subversion.subclipse.core.SVNProviderPlugin) Properties(java.util.Properties) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)108 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)67 SVNException (org.tigris.subversion.subclipse.core.SVNException)37 File (java.io.File)28 IResource (org.eclipse.core.resources.IResource)27 CoreException (org.eclipse.core.runtime.CoreException)22 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)21 TeamException (org.eclipse.team.core.TeamException)21 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)20 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)20 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)19 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)19 ArrayList (java.util.ArrayList)18 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)13 OperationProgressNotifyListener (org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)9 IProject (org.eclipse.core.resources.IProject)8 List (java.util.List)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7