Search in sources :

Example 86 with ISVNClientAdapter

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

the class UpdateResourcesCommand method run.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
   */
public void run(final IProgressMonitor monitor) throws SVNException {
    final ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
    OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor, svnClient));
    try {
        List<IProject> projectList = new ArrayList<IProject>();
        for (IResource currentResource : resources) {
            IProject project = currentResource.getProject();
            if (!projectList.contains(project)) {
                projectList.add(project);
            }
        }
        if (conflictResolver != null) {
            svnClient.addConflictResolutionCallback(conflictResolver);
        }
        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 {
                    monitor.beginTask(null, 100 * resources.length);
                    svnClient.addNotifyListener(operationResourceCollector);
                    if (resources.length == 1) {
                        monitor.subTask(resources[0].getName());
                        svnClient.update(resources[0].getLocation().toFile(), revision, depth, setDepth, ignoreExternals, force);
                        updatedResources.add(resources[0]);
                        monitor.worked(100);
                    } else {
                        File[] files = new File[resources.length];
                        for (int i = 0; i < resources.length; i++) {
                            files[i] = resources[i].getLocation().toFile();
                            updatedResources.add(resources[i]);
                        }
                        svnClient.update(files, revision, depth, setDepth, ignoreExternals, force);
                        monitor.worked(100);
                    }
                } catch (SVNClientException e) {
                    throw SVNException.wrapException(e);
                } finally {
                    monitor.done();
                    if (svnClient != null) {
                        if (conflictResolver != null) {
                            svnClient.addConflictResolutionCallback(null);
                        }
                        svnClient.removeNotifyListener(operationResourceCollector);
                        root.getRepository().returnSVNClient(svnClient);
                    }
                }
            }
        }, rule, Policy.monitorFor(monitor));
    } finally {
        OperationManager.getInstance().endOperation(true, operationResourceCollector.getOperationResources());
    }
}
Also used : ISVNRunnable(org.tigris.subversion.subclipse.core.ISVNRunnable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter) OperationProgressNotifyListener(org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Example 87 with ISVNClientAdapter

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

the class UpgradeResourcesCommand 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 = null;
    try {
        monitor.beginTask(null, 100 * resources.length);
        svnClient = root.getRepository().getSVNClient();
        OperationManager.getInstance().beginOperation(svnClient);
        for (int i = 0; i < resources.length; i++) {
            svnClient.upgrade(resources[i].getLocation().toFile());
            monitor.worked(100);
        }
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        root.getRepository().returnSVNClient(svnClient);
        OperationManager.getInstance().endOperation();
        monitor.done();
    }
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 88 with ISVNClientAdapter

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

the class AliasManager method getAliases.

private Alias[] getAliases(SVNUrl url, boolean checkParents) {
    ArrayList<Alias> aliases = new ArrayList<Alias>();
    ISVNClientAdapter client = null;
    try {
        client = SVNProviderPlugin.getPlugin().getSVNClient();
        ISVNProperty property = null;
        SVNProviderPlugin.disableConsoleLogging();
        property = client.propertyGet(url, "subclipse:tags");
        SVNProviderPlugin.enableConsoleLogging();
        if (property != null && property.getValue() != null) {
            getAliases(aliases, property.getValue(), url.toString());
        } else {
            if (url.getParent() != null && checkParents)
                return getAliases(url.getParent(), checkParents);
        }
    } catch (SVNClientException e) {
    } catch (SVNException e) {
    } finally {
        SVNProviderPlugin.enableConsoleLogging();
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
    }
    Alias[] aliasArray = new Alias[aliases.size()];
    aliases.toArray(aliasArray);
    return aliasArray;
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ArrayList(java.util.ArrayList) ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 89 with ISVNClientAdapter

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

the class LogEntry method getPathsOnDemand.

private ISVNLogMessageChangePath[] getPathsOnDemand(SVNUrl url) {
    ISVNLogMessage[] tmpMessage;
    ISVNClientAdapter client = null;
    try {
        // errors will not log to console
        client = SVNProviderPlugin.getPlugin().getSVNClient();
        SVNProviderPlugin.disableConsoleLogging();
        tmpMessage = client.getLogMessages(url, getRevision(), getRevision(), true);
        SVNProviderPlugin.enableConsoleLogging();
        if (tmpMessage != null && tmpMessage.length > 0)
            return tmpMessage[0].getChangedPaths();
        else
            return null;
    } catch (Exception e) {
        SVNProviderPlugin.enableConsoleLogging();
        return null;
    } finally {
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
    }
}
Also used : ISVNLogMessage(org.tigris.subversion.svnclientadapter.ISVNLogMessage) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 90 with ISVNClientAdapter

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

the class MergeWizardAdvancedPage method initializeLocations.

private void initializeLocations() {
    combosInitialized = true;
    MergeWizard wizard = (MergeWizard) getWizard();
    resource = wizard.getResource();
    resources = wizard.getResources();
    svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
    mergeInfoPaths = null;
    repositoryLocation = svnResource.getRepository().getLocation();
    if (((MergeWizard) getWizard()).suggestMergeSources()) {
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.setTaskName(Messages.MergeWizardStandardPage_retrievingMergeSourceInfo);
                monitor.beginTask(Messages.MergeWizardStandardPage_retrievingMergeSourceInfo, IProgressMonitor.UNKNOWN);
                // $NON-NLS-1$
                monitor.subTask("");
                ISVNClientAdapter svnClient = null;
                try {
                    svnClient = svnResource.getRepository().getSVNClient();
                    try {
                        mergeInfoPaths = svnClient.suggestMergeSources(new SVNUrl(commonRoot), SVNRevision.HEAD);
                    } catch (Exception e1) {
                    }
                } catch (Exception e) {
                    Activator.handleError(e);
                } finally {
                    svnResource.getRepository().returnSVNClient(svnClient);
                }
                monitor.done();
            }
        };
        try {
            getContainer().run(true, false, runnable);
        } catch (Exception e2) {
            Activator.handleError(e2);
        }
    }
    boolean valueAdded = false;
    List<String> fromUrls = new ArrayList<String>();
    if (mergeInfoPaths != null) {
        for (int i = 0; i < mergeInfoPaths.length; i++) {
            String url = mergeInfoPaths[i].substring(repositoryLocation.length());
            if (!fromUrls.contains(url))
                fromUrls.add(url);
            valueAdded = true;
        }
    }
    String previousFromUrls = null;
    String previousFromUrl = null;
    try {
        previousFromUrls = Activator.getDefault().getDialogSettings().get("mergeFromUrls_" + commonRoot);
    } catch (Exception e) {
    }
    if (previousFromUrls != null) {
        String[] urls = previousFromUrls.split("\\,");
        for (String url : urls) {
            if (!fromUrls.contains(url))
                fromUrls.add(url);
            valueAdded = true;
        }
        if (urls.length > 0)
            previousFromUrl = urls[0];
    }
    if (!valueAdded && commonRoot != null) {
        fromUrls.add(commonRoot.substring(repositoryLocation.length()));
    }
    for (String url : fromUrls) {
        fromCombo.add(url);
        toCombo.add(url);
    }
    if (previousFromUrl != null)
        fromCombo.setText(previousFromUrl);
    else if (fromCombo.getItemCount() > 0)
        fromCombo.setText(fromCombo.getItem(0));
    if (fromCombo.getText() != null && fromCombo.getText().length() > 0) {
        try {
            String previousToUrl = Activator.getDefault().getDialogSettings().get("mergeToUrl_" + fromCombo.getText());
            if (previousToUrl != null) {
                if (toCombo.indexOf(previousToUrl) == -1) {
                    toCombo.add(previousToUrl);
                }
                try {
                    boolean useFromDeselected = Activator.getDefault().getDialogSettings().getBoolean("mergeUseFromDeselected_" + fromCombo.getText());
                    if (useFromDeselected) {
                        useFromButton.setSelection(false);
                    }
                } catch (Exception e) {
                }
                if (!useFromButton.getSelection()) {
                    toCombo.setVisible(true);
                    toCombo.setText(previousToUrl);
                }
            }
        } catch (Exception e) {
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MalformedURLException(java.net.MalformedURLException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) 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