Search in sources :

Example 51 with ISVNRepositoryLocation

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

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

the class BranchTagWizardCopyPage method showLog.

private void showLog() {
    ISVNRemoteResource remoteResource = null;
    if (((BranchTagWizard) getWizard()).multipleSelections()) {
        ISVNRepositoryLocation repository = null;
        if (resource == null)
            repository = this.remoteResource.getRepository();
        else
            repository = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository();
        try {
            remoteResource = repository.getRemoteFile(new SVNUrl(((BranchTagWizard) getWizard()).getCommonRoot()));
        } catch (Exception e) {
            MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
            e.toString());
            return;
        }
    } else {
        if (resource == null)
            remoteResource = this.remoteResource;
        else {
            try {
                remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().getRemoteFile(((BranchTagWizard) getWizard()).getUrl());
            } catch (Exception e) {
                MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
                e.toString());
                return;
            }
        }
        if (remoteResource == null) {
            MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + ((BranchTagWizard) getWizard()).getUrlText());
            return;
        }
    }
    HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
    if (dialog.open() == HistoryDialog.CANCEL)
        return;
    ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
    if (selectedEntries.length == 0)
        return;
    revisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
    setPageComplete(canFinish());
}
Also used : HistoryDialog(org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Example 53 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation 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)

Example 54 with ISVNRepositoryLocation

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

the class CheckoutWizardSelectionPage method refreshViewerNode.

protected void refreshViewerNode() {
    IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
    Iterator iter = selection.iterator();
    while (iter.hasNext()) {
        Object object = iter.next();
        if (object instanceof ISVNRepositoryLocation)
            ((ISVNRepositoryLocation) object).refreshRootFolder();
        if (object instanceof ISVNRemoteFolder)
            ((ISVNRemoteFolder) object).refresh();
        treeViewer.refresh(object);
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder)

Example 55 with ISVNRepositoryLocation

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

the class CheckoutWizardSelectionPage method createControl.

public void createControl(Composite parent) {
    Composite outerContainer = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    outerContainer.setLayout(layout);
    outerContainer.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    treeViewer = new TreeViewer(outerContainer, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER);
    RepositoryContentProvider contentProvider = new RepositoryContentProvider();
    treeViewer.setContentProvider(contentProvider);
    treeViewer.addFilter(RepositoryFilters.FOLDERS_ONLY);
    treeViewer.setLabelProvider(new WorkbenchLabelProvider());
    treeViewer.setInput(repositoryLocation);
    GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
    data.heightHint = LIST_HEIGHT_HINT;
    data.widthHint = LIST_WIDTH_HINT;
    treeViewer.getControl().setLayoutData(data);
    treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            CheckoutWizard wizard = (CheckoutWizard) getWizard();
            ArrayList folderArray = new ArrayList();
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            Iterator iter = selection.iterator();
            while (iter.hasNext()) {
                Object object = iter.next();
                if (object instanceof ISVNRemoteFolder || object instanceof ISVNRepositoryLocation) {
                    if (object instanceof ISVNRepositoryLocation)
                        folderArray.add(((ISVNRepositoryLocation) object).getRootFolder());
                    else
                        folderArray.add(object);
                }
            }
            ISVNRemoteFolder[] remoteFolders = new ISVNRemoteFolder[folderArray.size()];
            folderArray.toArray(remoteFolders);
            wizard.setRemoteFolders(remoteFolders);
            setPageComplete(!treeViewer.getSelection().isEmpty());
        }
    });
    final Action refreshAction = new Action(Policy.bind("RepositoriesView.refreshPopup"), SVNUIPlugin.getPlugin().getImageDescriptor(// $NON-NLS-1$
    ISVNUIConstants.IMG_REFRESH)) {

        public void run() {
            refreshViewerNode();
        }
    };
    MenuManager menuMgr = new MenuManager();
    Tree tree = treeViewer.getTree();
    Menu menu = menuMgr.createContextMenu(tree);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            manager.add(refreshAction);
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    tree.setMenu(menu);
    // $NON-NLS-1$
    setMessage(Policy.bind("CheckoutWizardSelectionPage.text"));
    setControl(outerContainer);
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Action(org.eclipse.jface.action.Action) Composite(org.eclipse.swt.widgets.Composite) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) IMenuListener(org.eclipse.jface.action.IMenuListener) GridLayout(org.eclipse.swt.layout.GridLayout) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) GridData(org.eclipse.swt.layout.GridData) Iterator(java.util.Iterator) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Tree(org.eclipse.swt.widgets.Tree) Menu(org.eclipse.swt.widgets.Menu) IMenuManager(org.eclipse.jface.action.IMenuManager)

Aggregations

ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)69 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IResource (org.eclipse.core.resources.IResource)15 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)15 TeamException (org.eclipse.team.core.TeamException)14 ArrayList (java.util.ArrayList)13 SVNException (org.tigris.subversion.subclipse.core.SVNException)13 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 File (java.io.File)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)8 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)8 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)8 Iterator (java.util.Iterator)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 List (java.util.List)6