Search in sources :

Example 76 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.

the class SvnWizardCompareMultipleResourcesWithBranchTagPage method getCommonRoot.

private String getCommonRoot() {
    ArrayList urlList = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
        try {
            String anUrl = svnResource.getStatus().getUrlString();
            if (anUrl != null)
                urlList.add(anUrl);
        } catch (SVNException e1) {
        }
    }
    urlStrings = new String[urlList.size()];
    urlList.toArray(urlStrings);
    if (urlStrings.length == 0)
        return null;
    String urlString = urlStrings[0];
    if (urlStrings.length == 1)
        return urlString;
    String commonRoot = null;
    tag1: for (int i = 0; i < urlString.length(); i++) {
        String partialPath = urlString.substring(0, i + 1);
        if (partialPath.endsWith("/")) {
            // $NON-NLS-1$
            for (int j = 1; j < urlStrings.length; j++) {
                if (!urlStrings[j].startsWith(partialPath))
                    break tag1;
            }
            commonRoot = partialPath.substring(0, i);
        }
    }
    compareResources = new CompareResource[resources.length];
    for (int i = 0; i < resources.length; i++) {
        compareResources[i] = new CompareResource(resources[i], urlStrings[i].substring(commonRoot.length() + 1));
    }
    return commonRoot;
}
Also used : ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource)

Example 77 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.

the class BaseFile method getAnnotations.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.ISVNRemoteFile#getAnnotations(org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision)
   */
public ISVNAnnotations getAnnotations(SVNRevision fromRevision, SVNRevision toRevision, boolean includeMergedRevisions, boolean ignoreMimeType) throws TeamException {
    ISVNClientAdapter svnClient = getRepository().getSVNClient();
    try {
        SVNRevision pegRevision = null;
        ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        if (localResource != null) {
            pegRevision = localResource.getRevision();
        }
        return svnClient.annotate(localResourceStatus.getFile(), fromRevision, toRevision, pegRevision, ignoreMimeType, includeMergedRevisions);
    } catch (SVNClientException e) {
        throw new TeamException("Failed in BaseFile.getAnnotations()", e);
    } finally {
        getRepository().returnSVNClient(svnClient);
    }
}
Also used : TeamException(org.eclipse.team.core.TeamException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 78 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource 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 79 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.

the class MergeResultsView method createPartControl.

public void createPartControl(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.verticalSpacing = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 2;
    parent.setLayout(layout);
    treeViewer = new TreeViewer(parent);
    treeViewer.setLabelProvider(labelProvider);
    treeViewer.setContentProvider(new MergeResultsViewContentProvider());
    treeViewer.setUseHashlookup(true);
    GridData layoutData = new GridData();
    layoutData.grabExcessHorizontalSpace = true;
    layoutData.grabExcessVerticalSpace = true;
    layoutData.horizontalAlignment = GridData.FILL;
    layoutData.verticalAlignment = GridData.FILL;
    treeViewer.getControl().setLayoutData(layoutData);
    treeViewer.setInput(this);
    treeViewer.addOpenListener(new IOpenListener() {

        public void open(OpenEvent event) {
            treeConflict = null;
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            Object selectedItem = selection.getFirstElement();
            MergeResult mergeResult = null;
            if (selectedItem instanceof AdaptableMergeResult)
                mergeResult = (MergeResult) selectedItem;
            if (selectedItem instanceof AdaptableMergeResultsFolder) {
                MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) selectedItem;
                mergeResult = mergeResultsFolder.getMergeResult();
            }
            if (mergeResult != null) {
                if (mergeResult.getResource() instanceof IFile && mergeResult.isConflicted() && !mergeResult.isResolved()) {
                    editConflicts(mergeResult);
                    return;
                }
                if (mergeResult.getResource() instanceof IFile && mergeResult.hasTreeConflict() && !mergeResult.isTreeConflictResolved()) {
                    boolean addAddConflict = false;
                    if (mergeResult.getResource() != null && mergeResult.getResource().exists()) {
                        treeConflict = getTreeConflict(mergeResult.getResource());
                        if (treeConflict != null && treeConflict.getDescription() != null && treeConflict.getDescription().contains("local add") && treeConflict.getDescription().contains("incoming add")) {
                            // $NON-NLS-1$ //$NON-NLS-2$
                            addAddConflict = true;
                        }
                        if (!addAddConflict) {
                            openAction.run();
                        }
                    }
                    if (!addAddConflict) {
                        return;
                    }
                }
                if (!mergeResult.getAction().equals(MergeResult.ACTION_DELETE)) {
                    final ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(mergeResult.getResource());
                    if (!localResource.exists()) {
                        return;
                    }
                    BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                        public void run() {
                            try {
                                if (treeConflict != null) {
                                    if (!localResource.isFolder()) {
                                        SVNConflictDescriptor descriptor = treeConflict.getConflictDescriptor();
                                        SVNConflictVersion rightVersion = descriptor.getSrcRightVersion();
                                        try {
                                            ISVNRemoteFile remoteFile = new RemoteFile(localResource.getRepository(), new SVNUrl(rightVersion.getReposURL() + "/" + rightVersion.getPathInRepos()), new SVNRevision.Number(rightVersion.getPegRevision()));
                                            SVNLocalCompareInput compareInput = new SVNLocalCompareInput(localResource, remoteFile);
                                            CompareUI.openCompareEditorOnPage(compareInput, getSite().getPage());
                                        } catch (Exception e) {
                                        }
                                    }
                                    return;
                                }
                                CompareUI.openCompareEditorOnPage(new SVNLocalCompareInput(localResource, SVNRevision.BASE), getSite().getPage());
                            } catch (SVNException e) {
                                if (!e.operationInterrupted()) {
                                    Activator.handleError(Messages.MergeResultsView_compareError, e);
                                    MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MergeResultsView_compareWithLatest, e.getLocalizedMessage());
                                }
                            } catch (SVNClientException e) {
                                Activator.handleError(Messages.MergeResultsView_compareError, e);
                                MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MergeResultsView_compareWithLatest, e.getLocalizedMessage());
                            }
                        }
                    });
                }
            }
        }
    });
    treeViewer.getTree().addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            boolean mergeOutputSelected = false;
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                if (iter.next() instanceof MergeOutput) {
                    mergeOutputSelected = true;
                    break;
                }
            }
            removeAction.setEnabled(mergeOutputSelected);
        }
    });
    createMenus();
    createToolbar();
    getSite().setSelectionProvider(treeViewer);
    if (Activator.getDefault().getPreferenceStore().getBoolean(CONFLICTS_ONLY_PREFERENCE))
        setContentDescription(Messages.MergeResultsView_conflictsMode);
}
Also used : IFile(org.eclipse.core.resources.IFile) TreeViewer(org.eclipse.jface.viewers.TreeViewer) MergeResult(com.collabnet.subversion.merge.MergeResult) AdaptableMergeResult(com.collabnet.subversion.merge.AdaptableMergeResult) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) GridLayout(org.eclipse.swt.layout.GridLayout) AdaptableMergeResultsFolder(com.collabnet.subversion.merge.AdaptableMergeResultsFolder) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) MergeOutput(com.collabnet.subversion.merge.MergeOutput) SVNConflictVersion(org.tigris.subversion.svnclientadapter.SVNConflictVersion) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) AdaptableMergeResultsFolder(com.collabnet.subversion.merge.AdaptableMergeResultsFolder) MergeResultsFolder(com.collabnet.subversion.merge.MergeResultsFolder) AdaptableMergeResult(com.collabnet.subversion.merge.AdaptableMergeResult) SVNLocalCompareInput(org.tigris.subversion.subclipse.ui.compare.SVNLocalCompareInput) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SVNConflictDescriptor(org.tigris.subversion.svnclientadapter.SVNConflictDescriptor) SVNException(org.tigris.subversion.subclipse.core.SVNException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) IOpenListener(org.eclipse.jface.viewers.IOpenListener) GridData(org.eclipse.swt.layout.GridData) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 80 with ISVNLocalResource

use of org.tigris.subversion.subclipse.core.ISVNLocalResource in project subclipse by subclipse.

the class ShowRemoteHistoryAction method getSelectedRemoteResources.

protected ISVNRemoteResource[] getSelectedRemoteResources() {
    MergeOutput mergeOutput = null;
    ISVNRemoteResource remoteResource = null;
    Iterator iter = fSelection.iterator();
    while (iter.hasNext()) {
        Object object = iter.next();
        if (object instanceof MergeResult) {
            MergeResult mergeResult = (MergeResult) object;
            IResource resource = mergeResult.getResource();
            mergeOutput = mergeResult.getMergeOutput();
            MergeOptions mergeOptions = mergeOutput.getMergeOptions();
            SVNUrl svnUrl = mergeOptions.getFromUrl();
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                String resourceSubString = resource.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
                if (!resourceSubString.startsWith("/"))
                    // $NON-NLS-1$ //$NON-NLS-2$
                    resourceSubString = "/" + resourceSubString;
                SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
                resourceSubString.replaceAll("\\\\", "/"));
                remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
            } catch (Exception e) {
                Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
                MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
            }
            break;
        }
        if (object instanceof MergeResultsFolder) {
            MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) object;
            IContainer folder = mergeResultsFolder.getFolder();
            mergeOutput = mergeResultsFolder.getMergeOutput();
            MergeOptions mergeOptions = mergeOutput.getMergeOptions();
            SVNUrl svnUrl = mergeOptions.getFromUrl();
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(folder);
            try {
                String resourceSubString = folder.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
                if (!resourceSubString.startsWith("/"))
                    // $NON-NLS-1$ //$NON-NLS-2$
                    resourceSubString = "/" + resourceSubString;
                SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
                resourceSubString.replaceAll("\\\\", "/"));
                remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
            } catch (Exception e) {
                Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
                MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
            }
            break;
        }
    }
    if (remoteResource != null) {
        ISVNRemoteResource[] selectedResource = { remoteResource };
        SVNRevision.Number startRevision = null;
        try {
            startRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getLowerRevision()));
        } catch (ParseException e) {
        }
        SVNRevision.Number endRevision = null;
        if (mergeOutput.getUpperRevision() > 0) {
            try {
                endRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getUpperRevision()));
            } catch (ParseException e) {
            }
        }
        HistorySearchViewerFilter historySearchViewerFilter = new HistorySearchViewerFilter(null, null, null, null, true, startRevision, endRevision);
        SVNHistoryPage.setHistorySearchViewerFilter(historySearchViewerFilter);
        return selectedResource;
    }
    return new ISVNRemoteResource[0];
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) MergeResult(com.collabnet.subversion.merge.MergeResult) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ParseException(java.text.ParseException) MergeOutput(com.collabnet.subversion.merge.MergeOutput) Iterator(java.util.Iterator) HistorySearchViewerFilter(org.tigris.subversion.subclipse.ui.history.HistorySearchViewerFilter) MergeOptions(com.collabnet.subversion.merge.MergeOptions) ParseException(java.text.ParseException) IContainer(org.eclipse.core.resources.IContainer) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource) MergeResultsFolder(com.collabnet.subversion.merge.MergeResultsFolder)

Aggregations

ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)120 IResource (org.eclipse.core.resources.IResource)77 SVNException (org.tigris.subversion.subclipse.core.SVNException)76 ArrayList (java.util.ArrayList)39 CoreException (org.eclipse.core.runtime.CoreException)24 Iterator (java.util.Iterator)20 IFile (org.eclipse.core.resources.IFile)20 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 List (java.util.List)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)17 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)17 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)17 File (java.io.File)16 TeamException (org.eclipse.team.core.TeamException)16 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)15 ISynchronizeModelElement (org.eclipse.team.ui.synchronize.ISynchronizeModelElement)14 IContainer (org.eclipse.core.resources.IContainer)13 SyncInfo (org.eclipse.team.core.synchronize.SyncInfo)11