Search in sources :

Example 46 with ISVNClientAdapter

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

the class RelocateWizard method performFinish.

public boolean performFinish() {
    ISVNClientAdapter client = null;
    try {
        SVNRepositoryLocation newRepository = SVNRepositoryLocation.fromString(urlPage.getNewUrl());
        newRepository.setUsername(repository.getUsername());
        newRepository.setLabel(repository.getLabel());
        newRepository.validateConnection(new NullProgressMonitor());
        client = repository.getSVNClient();
        for (int i = 0; i < sharedProjects.length; i++) {
            client.relocate(repository.getUrl().toString(), newRepository.getUrl().toString(), sharedProjects[i].getLocation().toString(), true);
        }
        SVNRepositories repositories = SVNProviderPlugin.getPlugin().getRepositories();
        repositories.addOrUpdateRepository(newRepository);
        for (int i = 0; i < sharedProjects.length; i++) {
            SVNProviderPlugin.getPlugin().getStatusCacheManager().refreshStatus(sharedProjects[i], true);
            sharedProjects[i].refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
            RepositoryProvider provider = RepositoryProvider.getProvider(sharedProjects[i], SVNProviderPlugin.getTypeId());
            provider.setProject(sharedProjects[i]);
        }
        repositories.disposeRepository(repository);
    } catch (Exception e) {
        MessageDialog.openError(getShell(), Policy.bind("RelocateWizard.heading"), // $NON-NLS-1$
        e.getMessage());
        return false;
    } finally {
        repository.returnSVNClient(client);
    }
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SVNRepositories(org.tigris.subversion.subclipse.core.repo.SVNRepositories) SVNRepositoryLocation(org.tigris.subversion.subclipse.core.repo.SVNRepositoryLocation) RepositoryProvider(org.eclipse.team.core.RepositoryProvider) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 47 with ISVNClientAdapter

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

the class BranchTagWizard method performFinish.

public boolean performFinish() {
    if (confirmUserData() == false) {
        return false;
    }
    svnExternals = copyPage.getSvnExternals();
    comment = commentPage.getComment();
    repositoryPage.saveUrl();
    createOnServer = !copyPage.workingCopyButton.getSelection();
    makeParents = repositoryPage.makeParentsButton.getSelection();
    sameStructure = repositoryPage.sameStructureButton != null && repositoryPage.sameStructureButton.getSelection();
    if (commentPage.switchAfterBranchTagCheckBox != null) {
        switchAfterBranchTag = commentPage.switchAfterBranchTagCheckBox.getSelection();
    }
    if (copyPage.serverButton.getSelection())
        revision = SVNRevision.HEAD;
    try {
        toUrl = new SVNUrl(repositoryPage.getToUrl());
        if (copyPage.revisionButton.getSelection())
            revision = SVNRevision.getRevision(copyPage.getRevision());
    } catch (Exception e) {
        MessageDialog.openError(getShell(), Policy.bind("BranchTagDialog.title"), // $NON-NLS-1$
        e.getMessage());
        return false;
    }
    if (!multipleSelections()) {
        BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

            public void run() {
                ISVNInfo svnInfo = null;
                SVNUrl[] sourceUrls = getUrls();
                ISVNClientAdapter svnClient = null;
                ISVNRepositoryLocation repository = null;
                try {
                    SVNProviderPlugin.disableConsoleLogging();
                    repository = SVNProviderPlugin.getPlugin().getRepository(sourceUrls[0].toString());
                    svnClient = repository.getSVNClient();
                    svnInfo = svnClient.getInfo(toUrl);
                } catch (Exception e) {
                } finally {
                    SVNProviderPlugin.enableConsoleLogging();
                    if (repository != null) {
                        repository.returnSVNClient(svnClient);
                    }
                }
                alreadyExists = svnInfo != null;
            }
        });
        if (alreadyExists) {
            MessageDialog.openError(getShell(), Policy.bind("BranchTagDialog.title"), Policy.bind("BranchTagDialog.alreadyExists", // $NON-NLS-1$ //$NON-NLS-2$
            toUrl.toString()));
            return false;
        }
    }
    if (resources != null)
        updateTagsProperty(toUrl);
    return true;
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 48 with ISVNClientAdapter

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

the class ResolveTreeConflictWizard method getLogMessages.

private ISVNLogMessage[] getLogMessages() throws Exception {
    if (logMessages == null) {
        ISVNClientAdapter svnClient = null;
        try {
            svnClient = svnResource.getRepository().getSVNClient();
            IProject project = treeConflict.getResource().getProject();
            ISVNLocalResource svnProject = SVNWorkspaceRoot.getSVNResourceFor(project);
            SVNRevision revision1 = new SVNRevision.Number(treeConflict.getConflictDescriptor().getSrcLeftVersion().getPegRevision());
            SVNRevision revision2 = new SVNRevision.Number(treeConflict.getConflictDescriptor().getSrcRightVersion().getPegRevision());
            logMessages = svnClient.getLogMessages(svnProject.getUrl(), revision1, revision2, true);
        } catch (Exception e) {
            throw e;
        } finally {
            svnResource.getRepository().returnSVNClient(svnClient);
        }
    }
    return logMessages;
}
Also used : SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 49 with ISVNClientAdapter

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

the class SVNLocalCompareInput method prepareCompareInput.

/**
 * Runs the compare operation and returns the compare result.
 *
 * @throws InterruptedException
 */
protected ICompareInput prepareCompareInput(IProgressMonitor monitor) throws InterruptedException {
    initLabels();
    if (resource instanceof LocalFolder) {
        try {
            if (monitor == null) {
                monitor = new NullProgressMonitor();
            }
            // $NON-NLS-1$
            monitor.beginTask(Policy.bind("SVNCompareEditorInput.comparing"), 30);
            IProgressMonitor sub = new SubProgressMonitor(monitor, 30);
            // $NON-NLS-1$
            sub.beginTask(Policy.bind("SVNCompareEditorInput.comparing"), 100);
            Object[] result = new Object[] { null };
            ArrayList resourceSummaryNodeList = new ArrayList();
            ArrayList summaryEditionNodeList = new ArrayList();
            ISVNClientAdapter client = null;
            if (resources == null) {
                resources = new ISVNLocalResource[] { resource };
            }
            if (remoteFolders == null) {
                remoteFolders = new ISVNRemoteFolder[] { (ISVNRemoteFolder) remoteResource };
            }
            try {
                for (int i = 0; i < resources.length; i++) {
                    ISVNLocalResource resource = resources[i];
                    ISVNRemoteFolder remoteFolder = remoteFolders[i];
                    SVNDiffSummary[] diffSummary = null;
                    client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
                    File file = new File(resource.getResource().getLocation().toString());
                    getUnadded(client, resource, file);
                    IResource[] unaddedResources = new IResource[unaddedList.size()];
                    unaddedList.toArray(unaddedResources);
                    SVNWorkspaceRoot workspaceRoot = new SVNWorkspaceRoot(resource.getResource().getProject());
                    AddResourcesCommand command = new AddResourcesCommand(workspaceRoot, unaddedResources, IResource.DEPTH_INFINITE);
                    command.run(monitor);
                    diffSummary = client.diffSummarize(file, remoteFolder.getUrl(), remoteFolder.getRevision(), true);
                    for (IResource unaddedResource : unaddedResources) {
                        try {
                            SVNWorkspaceRoot.getSVNResourceFor(unaddedResource).revert();
                        } catch (Exception e) {
                        }
                    }
                    SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
                    client = null;
                    if (diffSummary != null && diffSummary.length > 0) {
                        diffSummary = getDiffSummaryWithSubfolders(diffSummary);
                        ITypedElement left = new SVNLocalResourceSummaryNode(resource, diffSummary, resource.getResource().getLocation().toString());
                        SummaryEditionNode right = new SummaryEditionNode(remoteFolder);
                        right.setName(resource.getFile().getName());
                        right.setRootFolder((RemoteFolder) remoteFolder);
                        right.setNodeType(SummaryEditionNode.RIGHT);
                        right.setRoot(true);
                        right.setDiffSummary(diffSummary);
                        String localCharset = Utilities.getCharset(resource.getIResource());
                        try {
                            right.setCharset(localCharset);
                        } catch (CoreException e) {
                            SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
                        }
                        resourceSummaryNodeList.add(left);
                        summaryEditionNodeList.add(right);
                    }
                }
                if (resourceSummaryNodeList.size() == 0) {
                    result[0] = null;
                } else {
                    Object[] resourceSummaryNodes = new Object[resourceSummaryNodeList.size()];
                    resourceSummaryNodeList.toArray(resourceSummaryNodes);
                    Object[] summaryEditionNodes = new Object[summaryEditionNodeList.size()];
                    summaryEditionNodeList.toArray(summaryEditionNodes);
                    MultipleSelectionNode left = new MultipleSelectionNode(resourceSummaryNodes);
                    MultipleSelectionNode right = new MultipleSelectionNode(summaryEditionNodes);
                    result[0] = new SummaryDifferencer().findDifferences(false, monitor, null, null, left, right);
                    fRoot = result[0];
                }
            } finally {
                sub.done();
                if (client != null) {
                    SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
                }
            }
            if (result[0] instanceof DiffNode) {
                DiffNode diffNode = (DiffNode) result[0];
                if (!diffNode.hasChildren()) {
                    return null;
                }
            }
            return (ICompareInput) result[0];
        } catch (OperationCanceledException e) {
            throw new InterruptedException(e.getMessage());
        } catch (Exception e) {
            SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
            return null;
        } finally {
            monitor.done();
        }
    } else {
        ITypedElement left = new SVNLocalResourceNode(resource);
        ResourceEditionNode right = new ResourceEditionNode(remoteResource, pegRevision);
        if (left.getType() == ITypedElement.FOLDER_TYPE) {
            right.setLocalResource((SVNLocalResourceNode) left);
        }
        if (right.getType() == ITypedElement.FOLDER_TYPE) {
            ((SVNLocalResourceNode) left).setRemoteResource((ResourceEditionNode) right);
        }
        String localCharset = Utilities.getCharset(resource.getIResource());
        try {
            right.setCharset(localCharset);
        } catch (CoreException e) {
            SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
        }
        ICompareInput compareInput;
        if (SVNRevision.BASE.equals(remoteRevision)) {
            compareInput = (ICompareInput) new StatusAwareDifferencer().findDifferences(false, monitor, null, null, left, right);
        } else {
            compareInput = (ICompareInput) new RevisionAwareDifferencer((SVNLocalResourceNode) left, right, diffFile, pegRevision).findDifferences(false, monitor, null, null, left, right);
        }
        return compareInput;
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SVNWorkspaceRoot(org.tigris.subversion.subclipse.core.resources.SVNWorkspaceRoot) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ArrayList(java.util.ArrayList) DiffNode(org.eclipse.compare.structuremergeviewer.DiffNode) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) AddResourcesCommand(org.tigris.subversion.subclipse.core.commands.AddResourcesCommand) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter) ITypedElement(org.eclipse.compare.ITypedElement) ICompareInput(org.eclipse.compare.structuremergeviewer.ICompareInput) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) IOException(java.io.IOException) LocalFolder(org.tigris.subversion.subclipse.core.resources.LocalFolder) SVNDiffSummary(org.tigris.subversion.svnclientadapter.SVNDiffSummary) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) File(java.io.File) IResource(org.eclipse.core.resources.IResource)

Example 50 with ISVNClientAdapter

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

the class SVNLocalCompareSummaryInput method prepareInput.

/**
 * Runs the compare operation and returns the compare result.
 */
protected Object prepareInput(IProgressMonitor monitor) throws InterruptedException {
    initLabels();
    try {
        // $NON-NLS-1$
        monitor.beginTask(Policy.bind("SVNCompareEditorInput.comparing"), 30);
        IProgressMonitor sub = new SubProgressMonitor(monitor, 30);
        // $NON-NLS-1$
        sub.beginTask(Policy.bind("SVNCompareEditorInput.comparing"), 100);
        Object[] result = new Object[] { null };
        ArrayList resourceSummaryNodeList = new ArrayList();
        ArrayList summaryEditionNodeList = new ArrayList();
        ISVNClientAdapter client = null;
        try {
            for (int i = 0; i < resources.length; i++) {
                ISVNLocalResource resource = resources[i];
                ISVNRemoteFolder remoteFolder = remoteFolders[i];
                SVNDiffSummary[] diffSummary = null;
                client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
                diffSummary = client.diffSummarize(new File(resource.getResource().getLocation().toString()), remoteFolder.getUrl(), remoteFolder.getRevision(), true);
                SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
                client = null;
                if (diffSummary != null && diffSummary.length > 0) {
                    diffSummary = getDiffSummaryWithSubfolders(diffSummary);
                    ITypedElement left = new SVNLocalResourceSummaryNode(resource, diffSummary, resource.getResource().getLocation().toString());
                    SummaryEditionNode right = new SummaryEditionNode(remoteFolder);
                    right.setName(resource.getFile().getName());
                    right.setRootFolder((RemoteFolder) remoteFolder);
                    right.setNodeType(SummaryEditionNode.RIGHT);
                    right.setRoot(true);
                    right.setDiffSummary(diffSummary);
                    String localCharset = Utilities.getCharset(resource.getIResource());
                    try {
                        right.setCharset(localCharset);
                    } catch (CoreException e) {
                        SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
                    }
                    resourceSummaryNodeList.add(left);
                    summaryEditionNodeList.add(right);
                }
            }
            if (resourceSummaryNodeList.size() == 0) {
                result[0] = null;
            } else {
                Object[] resourceSummaryNodes = new Object[resourceSummaryNodeList.size()];
                resourceSummaryNodeList.toArray(resourceSummaryNodes);
                Object[] summaryEditionNodes = new Object[summaryEditionNodeList.size()];
                summaryEditionNodeList.toArray(summaryEditionNodes);
                MultipleSelectionNode left = new MultipleSelectionNode(resourceSummaryNodes);
                MultipleSelectionNode right = new MultipleSelectionNode(summaryEditionNodes);
                result[0] = new SummaryDifferencer().findDifferences(false, monitor, null, null, left, right);
                fRoot = result[0];
            }
        } finally {
            sub.done();
            if (client != null) {
                SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
            }
        }
        if (result[0] instanceof DiffNode) {
            DiffNode diffNode = (DiffNode) result[0];
            if (!diffNode.hasChildren()) {
                return null;
            }
        }
        return result[0];
    } catch (OperationCanceledException e) {
        throw new InterruptedException(e.getMessage());
    } catch (Exception e) {
        return e.getMessage();
    } finally {
        monitor.done();
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ArrayList(java.util.ArrayList) DiffNode(org.eclipse.compare.structuremergeviewer.DiffNode) ITypedElement(org.eclipse.compare.ITypedElement) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SVNDiffSummary(org.tigris.subversion.svnclientadapter.SVNDiffSummary) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IFile(org.eclipse.core.resources.IFile) 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