Search in sources :

Example 1 with ISVNRemoteResource

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

the class BranchTagAction method run.

public void run() {
    BranchTagWizard wizard;
    final IResource resource = ((RevisionGraphEditorInput) editor.getEditorInput()).getResource();
    ISVNRemoteResource remoteResource = ((RevisionGraphEditorInput) editor.getEditorInput()).getRemoteResource();
    if (resource == null) {
        ISVNRemoteResource[] resources = { remoteResource };
        wizard = new BranchTagWizard(resources);
    } else {
        IResource[] resources = { resource };
        wizard = new BranchTagWizard(resources);
    }
    wizard.setRevisionNumber(node.getRevision());
    WizardDialog dialog = new ClosableWizardDialog(Display.getDefault().getActiveShell(), wizard);
    if (dialog.open() == WizardDialog.OK) {
        final SVNUrl sourceUrl = wizard.getUrl();
        final SVNUrl destinationUrl = wizard.getToUrl();
        final String message = wizard.getComment();
        final SVNRevision revision = wizard.getRevision();
        final boolean makeParents = wizard.isMakeParents();
        final SVNUrl[] sourceUrls = wizard.getUrls();
        final boolean createOnServer = wizard.isCreateOnServer();
        final Alias newAlias = wizard.getNewAlias();
        final boolean switchAfter = wizard.isSwitchAfterBranchTag();
        try {
            BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                public void run() {
                    ISVNClientAdapter client = null;
                    try {
                        if (resource == null) {
                            client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
                            client.copy(sourceUrl, destinationUrl, message, revision, makeParents);
                        } else {
                            IResource[] resources = { resource };
                            BranchTagOperation branchTagOperation = new BranchTagOperation(editor.getEditorSite().getPart(), resources, sourceUrls, destinationUrl, createOnServer, revision, message);
                            branchTagOperation.setMakeParents(makeParents);
                            branchTagOperation.setNewAlias(newAlias);
                            branchTagOperation.switchAfterTagBranchOperation(switchAfter);
                            branchTagOperation.run();
                        }
                    } catch (Exception e) {
                        MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.createTagFromRevision"), e.getMessage());
                    } finally {
                        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
                    }
                }
            });
        } catch (Exception e) {
            MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.createTagFromRevision"), e.getMessage());
        }
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) RevisionGraphEditorInput(org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput) BranchTagWizard(org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard) Alias(org.tigris.subversion.subclipse.core.history.Alias) BranchTagOperation(org.tigris.subversion.subclipse.ui.operations.BranchTagOperation) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 2 with ISVNRemoteResource

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

the class CompareRevisionsAction method run.

public void run() {
    RevisionGraphEditorInput input = (RevisionGraphEditorInput) editor.getEditorInput();
    boolean isFolder = (input.getResource() != null && input.getResource().getType() != IResource.FILE) || (input.getRemoteResource() != null && input.getRemoteResource().isFolder());
    ISVNInfo info = input.getInfo();
    try {
        ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(info.getRepository().toString());
        ISVNRemoteResource remoteResource1;
        ISVNRemoteResource remoteResource2;
        if (isFolder) {
            remoteResource1 = new RemoteFolder(repository, new SVNUrl(repository.getLocation() + node1.getBranch().getPath()), new SVNRevision.Number(node1.getRevision()));
            remoteResource2 = new RemoteFolder(repository, new SVNUrl(repository.getLocation() + node2.getBranch().getPath()), new SVNRevision.Number(node2.getRevision()));
        } else {
            remoteResource1 = new RemoteFile(repository, new SVNUrl(repository.getLocation() + node1.getBranch().getPath()), new SVNRevision.Number(node1.getRevision()));
            remoteResource2 = new RemoteFile(repository, new SVNUrl(repository.getLocation() + node2.getBranch().getPath()), new SVNRevision.Number(node2.getRevision()));
        }
        ISVNRemoteResource[] selectedResources = { remoteResource1, remoteResource2 };
        DifferencesDialog dialog = new DifferencesDialog(Display.getDefault().getActiveShell(), null, selectedResources, editor.getEditorSite().getPart());
        dialog.setFromRevision(Long.toString(node1.getRevision()));
        dialog.setToRevision(Long.toString(node2.getRevision()));
        dialog.open();
    } catch (Exception e) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), "Compare Revisions", e.getMessage());
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) RevisionGraphEditorInput(org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput) DifferencesDialog(org.tigris.subversion.subclipse.ui.dialogs.DifferencesDialog) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Example 3 with ISVNRemoteResource

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

the class ViewGraphAction method execute.

public void execute(IAction action) throws InterruptedException, InvocationTargetException {
    if (action != null && !action.isEnabled()) {
        action.setEnabled(true);
    } else {
        run(new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) {
                IResource[] resources = getSelectedResources();
                try {
                    if (resources.length > 0) {
                        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]);
                        ISVNRemoteResource remoteResource = svnResource.getBaseResource();
                        if (remoteResource != null) {
                            String repoPath = remoteResource.getRepositoryRelativePath();
                            if (repoPath == null || repoPath.length() == 0) {
                                MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("ViewGraphAction.0"), // $NON-NLS-1$ //$NON-NLS-2$
                                Policy.bind("ViewGraphAction.1"));
                                return;
                            }
                        }
                        // IEditorPart part =
                        getTargetPage().openEditor(new RevisionGraphEditorInput(resources[0]), // $NON-NLS-1$
                        "org.tigris.subversion.subclipse.graph.editors.revisionGraphEditor");
                    }
                } catch (Exception e) {
                    Activator.handleError(e);
                    Activator.showErrorDialog(getErrorTitle(), e);
                }
            }
        }, false, /* cancelable */
        PROGRESS_BUSYCURSOR);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RevisionGraphEditorInput(org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 4 with ISVNRemoteResource

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

the class RemoteFolder method getMembers.

/**
 * Get the members of this folder at the same revision than this resource
 *
 * @param monitor a progress monitor
 * @return ISVNRemoteResource[] an array of child remoteResources
 */
protected ISVNRemoteResource[] getMembers(IProgressMonitor monitor) throws SVNException {
    final IProgressMonitor progress = Policy.monitorFor(monitor);
    // $NON-NLS-1$
    progress.beginTask(Policy.bind("RemoteFolder.getMembers"), 100);
    // Try to hit the cache first.
    if (children != null) {
        progress.done();
        return children;
    }
    ISVNClientAdapter client = null;
    try {
        client = getRepository().getSVNClient();
        ISVNDirEntryWithLock[] list = client.getListWithLocks(url, getRevision(), SVNRevision.HEAD, false);
        List<RemoteResource> result = new ArrayList<RemoteResource>(list.length);
        // directories first
        for (ISVNDirEntryWithLock entryWithLock : list) {
            ISVNDirEntry entry = entryWithLock.getDirEntry();
            if (entry.getNodeKind() == SVNNodeKind.DIR) {
                result.add(new RemoteFolder(this, getRepository(), url.appendPath(entry.getPath()), getRevision(), entry.getLastChangedRevision(), entry.getLastChangedDate(), entry.getLastCommitAuthor()));
            }
        }
        // files then
        for (ISVNDirEntryWithLock entryWithLock : list) {
            ISVNDirEntry entry = entryWithLock.getDirEntry();
            ISVNLock lock = entryWithLock.getLock();
            if (entry.getNodeKind() == SVNNodeKind.FILE) {
                RemoteFile remoteFile = new RemoteFile(this, getRepository(), url.appendPath(entry.getPath()), getRevision(), entry.getLastChangedRevision(), entry.getLastChangedDate(), entry.getLastCommitAuthor());
                remoteFile.setPegRevision(getRevision());
                remoteFile.setLock(lock);
                result.add(remoteFile);
            }
        }
        // Save it to the cache
        children = (ISVNRemoteResource[]) result.toArray(new ISVNRemoteResource[result.size()]);
        return children;
    } catch (SVNClientException e) {
        throw new SVNException(new SVNStatus(IStatus.ERROR, SVNStatus.DOES_NOT_EXIST, Policy.bind("RemoteFolder.doesNotExist", // $NON-NLS-1$
        getRepositoryRelativePath())));
    } finally {
        getRepository().returnSVNClient(client);
        progress.done();
    }
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) ISVNLock(org.tigris.subversion.svnclientadapter.ISVNLock) ArrayList(java.util.ArrayList) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) SVNStatus(org.tigris.subversion.subclipse.core.SVNStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNDirEntryWithLock(org.tigris.subversion.svnclientadapter.ISVNDirEntryWithLock) ISVNDirEntry(org.tigris.subversion.svnclientadapter.ISVNDirEntry) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 5 with ISVNRemoteResource

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

the class RepositoryResourcesManager method deleteRemoteResources.

/**
 * delete some remote resources Resources can be from several RemoteRepositoryLocations
 */
public void deleteRemoteResources(ISVNRemoteResource[] remoteResources, String message, IProgressMonitor monitor) throws SVNException {
    IProgressMonitor progress = Policy.monitorFor(monitor);
    progress.beginTask(Policy.bind("RepositoryResourcesManager.deleteRemoteResources"), // $NON-NLS-1$
    100 * remoteResources.length);
    // the given remote resources can come from more than a repository and so needs
    // more than one svnClient
    // we associate each repository with the corresponding resources to delete
    HashMap<ISVNRepositoryLocation, List<ISVNRemoteResource>> mapRepositories = new HashMap<ISVNRepositoryLocation, List<ISVNRemoteResource>>();
    for (ISVNRemoteResource remoteResource : remoteResources) {
        ISVNRepositoryLocation repositoryLocation = remoteResource.getRepository();
        List<ISVNRemoteResource> resources = (List<ISVNRemoteResource>) mapRepositories.get(repositoryLocation);
        if (resources == null) {
            resources = new ArrayList<ISVNRemoteResource>();
            mapRepositories.put(repositoryLocation, resources);
        }
        resources.add(remoteResource);
    }
    ISVNClientAdapter svnClient = null;
    ISVNRepositoryLocation repository = null;
    try {
        for (List<ISVNRemoteResource> resources : mapRepositories.values()) {
            repository = (resources.get(0)).getRepository();
            svnClient = repository.getSVNClient();
            SVNUrl[] urls = new SVNUrl[resources.size()];
            for (int i = 0; i < resources.size(); i++) {
                ISVNRemoteResource resource = resources.get(i);
                urls[i] = resource.getUrl();
                // refresh just says that resource needs to be updated
                // it does not update immediatly
                resource.getParent().refresh();
            }
            svnClient.remove(urls, message);
            repository.returnSVNClient(svnClient);
            svnClient = null;
            repository = null;
            for (ISVNRemoteResource resource : resources) {
                remoteResourceDeleted(resource);
            }
            progress.worked(100 * urls.length);
        }
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
        progress.done();
    }
}
Also used : HashMap(java.util.HashMap) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ArrayList(java.util.ArrayList) List(java.util.List) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)69 SVNException (org.tigris.subversion.subclipse.core.SVNException)23 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)21 InvocationTargetException (java.lang.reflect.InvocationTargetException)16 TeamException (org.eclipse.team.core.TeamException)16 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)16 IResource (org.eclipse.core.resources.IResource)15 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)14 ArrayList (java.util.ArrayList)12 ParseException (java.text.ParseException)11 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)10 CoreException (org.eclipse.core.runtime.CoreException)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)8 MalformedURLException (java.net.MalformedURLException)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)7 HistoryDialog (org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog)6 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)6