Search in sources :

Example 91 with ISVNClientAdapter

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

the class MergeWizardBestPracticesPage method performChecks.

public void performChecks(boolean refreshPage) {
    try {
        getContainer().run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                needsChecks = false;
                localMods = false;
                switchedChildren = false;
                mixedRevisions = false;
                incompleteWorkingCopy = false;
                localModsList = new ArrayList();
                switchedChildrenList = new ArrayList();
                mixedRevisionsList = new ArrayList();
                incompleteList = new ArrayList();
                IResource[] resources = ((MergeWizard) getWizard()).getResources();
                if (resources == null)
                    return;
                monitor.beginTask(Messages.MergeWizardBestPracticesPage_0, resources.length);
                for (int i = 0; i < resources.length; i++) {
                    monitor.subTask(resources[i].getName());
                    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
                    ISVNClientAdapter svnClient = null;
                    try {
                        svnClient = svnResource.getRepository().getSVNClient();
                        File fileProject = new File(resources[i].getLocation().toString());
                        List incompleteInfoList = new ArrayList();
                        ISVNInfo[] infos = svnClient.getInfo(fileProject, true);
                        for (int j = 0; j < infos.length; j++) {
                            if (infos[j].getDepth() != Depth.infinity && infos[j].getDepth() != Depth.unknown) {
                                incompleteWorkingCopy = true;
                                incompleteInfoList.add(infos[j].getUrl().toString());
                            }
                        }
                        File file = new File(resources[i].getLocation().toString());
                        ISVNStatus status = svnClient.getSingleStatus(file);
                        highestRevision = status.getRevision().getNumber();
                        ISVNStatus[] statuses = svnClient.getStatus(file, true, true, false, true);
                        for (int j = 0; j < statuses.length; j++) {
                            if (statuses[j].getUrl() != null && incompleteInfoList.contains(statuses[j].getUrl().toString())) {
                                incompleteList.add(SVNWorkspaceRoot.getResourceFor(resources[i], statuses[j]));
                            }
                            if (statuses[j].getTextStatus().equals(SVNStatusKind.MODIFIED) | statuses[j].getPropStatus().equals(SVNStatusKind.MODIFIED)) {
                                localMods = true;
                                localModsList.add(SVNWorkspaceRoot.getResourceFor(resources[i], statuses[j]));
                            }
                            if (statuses[j].isSwitched()) {
                                switchedChildren = true;
                                switchedChildrenList.add(SVNWorkspaceRoot.getResourceFor(resources[i], statuses[j]));
                            }
                            if (!statuses[j].getTextStatus().equals(SVNStatusKind.EXTERNAL) && !statuses[j].isFileExternal() && statuses[j].getRevision() != null) {
                                if (!statuses[j].getRevision().equals(status.getRevision())) {
                                    mixedRevisions = true;
                                    if (!mixedRevisionsList.contains(resources[i]))
                                        mixedRevisionsList.add(resources[i]);
                                    if (statuses[j].getRevision().getNumber() > highestRevision) {
                                        highestRevision = statuses[j].getRevision().getNumber();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        Activator.handleError(e);
                    } finally {
                        svnResource.getRepository().returnSVNClient(svnClient);
                    }
                    monitor.worked(1);
                }
                monitor.done();
            }
        });
    } catch (Exception e) {
        Activator.handleError(e);
    }
    if (refreshPage)
        refreshPage(true, false);
    if (localMods || switchedChildren || mixedRevisions || incompleteWorkingCopy) {
        setMessage(Messages.MergeWizardBestPracticesPage_notReady);
        setPageComplete(false);
    } else {
        setMessage(Messages.MergeWizardBestPracticesPage_ready);
        setPageComplete(true);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ISVNStatus(org.tigris.subversion.svnclientadapter.ISVNStatus) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 92 with ISVNClientAdapter

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

the class MergeCommand method run.

public void run(IProgressMonitor monitor) throws SVNException {
    mergeAborted = false;
    MergeListener mergeListener = null;
    ISVNClientAdapter svnClient = null;
    ISVNRepositoryLocation repository = null;
    try {
        monitor.beginTask(null, 100);
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        repository = svnResource.getRepository();
        svnClient = repository.getSVNClient();
        SVNConflictResolver conflictResolver = new SVNConflictResolver(resource, textConflictHandling, binaryConflictHandling, propertyConflictHandling, treeConflictHandling);
        conflictResolver.setPart(part);
        svnClient.addConflictResolutionCallback(conflictResolver);
        MergeOptions mergeOptions = new MergeOptions();
        mergeOptions.setFromUrl(svnUrl1);
        mergeOptions.setFromRevision(svnRevision1);
        mergeOptions.setToUrl(svnUrl2);
        mergeOptions.setToRevision(svnRevision2);
        mergeOptions.setRevisions(revisions);
        mergeOptions.setForce(force);
        mergeOptions.setIgnoreAncestry(ignoreAncestry);
        mergeOptions.setDepth(depth);
        mergeListener = new MergeListener(resource, mergeOptions, conflictResolver, mergeOutput);
        svnClient.addNotifyListener(mergeListener);
        svnClient.addNotifyListener(operationResourceCollector);
        OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor));
        monitor.subTask(resource.getName());
        File file = resource.getLocation().toFile();
        if (revisions == null) {
            svnClient.merge(svnUrl1, svnRevision1, svnUrl2, svnRevision2, file, force, depth, false, ignoreAncestry, recordOnly);
        } else {
            SVNUrlWithPegRevision svnUrlWithPegRevision = new SVNUrlWithPegRevision(svnUrl1);
            SVNRevision pegRevision = svnUrlWithPegRevision.getPegRevision();
            if (pegRevision == null)
                pegRevision = SVNRevision.HEAD;
            svnClient.merge(svnUrlWithPegRevision.getUrl(), pegRevision, revisions, file, force, depth, ignoreAncestry, false, recordOnly);
        }
        monitor.worked(100);
    } catch (SVNClientException e) {
        if (e.getAprError() == SVNClientException.MERGE_CONFLICT) {
            mergeAborted = true;
            errorMessage = // $NON-NLS-1$ //$NON-NLS-2$
            e.getCause().getLocalizedMessage().replaceAll("\n", " ");
        } else
            throw SVNException.wrapException(e);
    } finally {
        if (mergeListener != null)
            mergeOutput = mergeListener.getMergeOutput();
        Set<IResource> operationResources = operationResourceCollector.getOperationResources();
        OperationManager.getInstance().endOperation(true, operationResources);
        monitor.done();
        svnClient.removeNotifyListener(mergeListener);
        svnClient.removeNotifyListener(operationResourceCollector);
        svnClient.addConflictResolutionCallback(null);
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
    }
}
Also used : ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SVNUrlWithPegRevision(org.tigris.subversion.subclipse.core.util.SVNUrlWithPegRevision) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) 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 93 with ISVNClientAdapter

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

the class SubclipseLinkedTaskInfo method init.

private void init() {
    TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager();
    String[] urls = null;
    ProjectProperties props = null;
    try {
        if (resource != null) {
            props = ProjectProperties.getProjectProperties(resource);
        } else if (logEntry != null) {
            ISVNResource svnres = logEntry.getResource();
            if (svnres != null) {
                if (svnres.getResource() != null) {
                    props = ProjectProperties.getProjectProperties(svnres.getResource());
                } else {
                    ISVNClientAdapter client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
                    SVNProviderPlugin.disableConsoleLogging();
                    ISVNProperty[] properties = client.getProperties(svnres.getUrl());
                    SVNProviderPlugin.enableConsoleLogging();
                    for (int i = 0; i < properties.length; i++) {
                        ISVNProperty property = properties[i];
                        if ("bugtraq:url".equals(property.getName())) {
                            repositoryUrl = SubclipseTeamPlugin.getRepository(property.getValue(), repositoryManager).getRepositoryUrl();
                        // comments?
                        }
                    }
                }
            }
        }
    } catch (Exception ex) {
        // ignore?
        SVNProviderPlugin.enableConsoleLogging();
    }
    if (props != null) {
        if (repositoryUrl == null) {
            repositoryUrl = SubclipseTeamPlugin.getRepository(props.getUrl(), repositoryManager).getRepositoryUrl();
        }
        urls = props.getLinkList(getText()).getUrls();
    }
    if (urls == null || urls.length == 0) {
        urls = ProjectProperties.getUrls(getText()).getUrls();
    }
    if (urls != null && urls.length > 0) {
        taskFullUrl = urls[0];
    }
}
Also used : TaskRepositoryManager(org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager) ISVNResource(org.tigris.subversion.subclipse.core.ISVNResource) ProjectProperties(org.tigris.subversion.subclipse.ui.settings.ProjectProperties) ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) TeamException(org.eclipse.team.core.TeamException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 94 with ISVNClientAdapter

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

the class CopyCommand method run.

public void run(IProgressMonitor monitor) throws SVNException {
    ISVNClientAdapter svnClient = null;
    try {
        monitor.beginTask(null, 100);
        svnClient = root.getRepository().getSVNClient();
        OperationManager.getInstance().beginOperation(svnClient);
        monitor.subTask(destPath.getName());
        svnClient.copy(srcUrl, destPath, svnRevision, false, true);
        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 95 with ISVNClientAdapter

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

the class BranchTagWizardCopyPage method getSvnExternalsProperties.

private boolean getSvnExternalsProperties() {
    List<SVNExternal> externalsList = new ArrayList<SVNExternal>();
    ISVNClientAdapter svnClient = null;
    ISVNRepositoryLocation repository = null;
    try {
        repository = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository();
        svnClient = repository.getSVNClient();
        IResource[] resources = ((BranchTagWizard) getWizard()).getResources();
        for (IResource res : resources) {
            ISVNProperty[] properties = svnClient.getProperties(res.getLocation().toFile(), true);
            for (ISVNProperty property : properties) {
                if (property.getName().equals(Policy.bind("BranchTagWizardCopyPage.8"))) {
                    // $NON-NLS-1$
                    // $NON-NLS-1$
                    String[] propertyLines = property.getValue().split("\\n");
                    for (String propertyLine : propertyLines) {
                        SVNExternal svnExternal = new SVNExternal(property.getFile(), propertyLine);
                        externalsList.add(svnExternal);
                    }
                }
            }
        }
    } catch (Exception e) {
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
    }
    svnExternals = new SVNExternal[externalsList.size()];
    externalsList.toArray(svnExternals);
    return externalsList.size() > 0;
}
Also used : ArrayList(java.util.ArrayList) SVNExternal(org.tigris.subversion.subclipse.core.SVNExternal) ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) IResource(org.eclipse.core.resources.IResource) 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