Search in sources :

Example 11 with SVNUrl

use of org.tigris.subversion.svnclientadapter.SVNUrl 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)

Example 12 with SVNUrl

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

the class SVNRepositories method readState.

/**
 * read the state of the plugin, ie the repositories locations
 *
 * @param dis
 * @throws IOException
 * @throws SVNException
 */
private void readState(DataInputStream dis) throws IOException, SVNException {
    int version = dis.readInt();
    if ((version < REPOSITORIES_STATE_FILE_VERSION_1) || (version > REPOSITORIES_STATE_FILE_VERSION_3)) {
        Util.logError(Policy.bind("SVNProviderPlugin.unknownStateFileVersion", new Integer(version).toString()), // $NON-NLS-1$
        null);
        return;
    }
    int count = dis.readInt();
    for (int i = 0; i < count; i++) {
        ISVNRepositoryLocation root = SVNRepositoryLocation.fromString(dis.readUTF());
        addToRepositoriesCache(root);
        if (version >= REPOSITORIES_STATE_FILE_VERSION_2) {
            String label = dis.readUTF();
            if (!label.equals("")) {
                root.setLabel(label);
            }
        }
        if (version >= REPOSITORIES_STATE_FILE_VERSION_3) {
            String repositoryRoot = dis.readUTF();
            if (!repositoryRoot.equals("")) {
                root.setRepositoryRoot(new SVNUrl(repositoryRoot));
            }
        }
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl)

Example 13 with SVNUrl

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

the class LogEntry method getLogEntryChangePaths.

/*
   * (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.history.ILogEntry#getLogEntryChangePaths()
   */
public LogEntryChangePath[] getLogEntryChangePaths() {
    ISVNLogMessageChangePath[] changePaths = null;
    if (SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand()) {
        SVNUrl url = resource.getRepository().getRepositoryRoot();
        if (url == null)
            url = updateRootUrl(resource);
        changePaths = getPathsOnDemand(url);
        if (changePaths == null) {
            // Root URL is probably bad.  Run svn info to retrieve the root URL and
            // update it in the repository.
            SVNUrl url2 = updateRootUrl(resource);
            if (!url.toString().equals(url2.toString()))
                changePaths = getPathsOnDemand(url);
            // one last try using the resource URL
            if (changePaths == null)
                changePaths = getPathsOnDemand(resource.getUrl());
            // Still nothing, just return an empty array
            if (changePaths == null)
                changePaths = new ISVNLogMessageChangePath[0];
        }
    } else {
        changePaths = logMessage.getChangedPaths();
    }
    LogEntryChangePath[] logEntryChangePaths = new LogEntryChangePath[changePaths.length];
    for (int i = 0; i < changePaths.length; i++) {
        logEntryChangePaths[i] = new LogEntryChangePath(this, changePaths[i]);
    }
    return logEntryChangePaths;
}
Also used : ISVNLogMessageChangePath(org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl)

Example 14 with SVNUrl

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

the class SVNRepositoryLocation method fromString.

/*
   * Parse a location string and return a SVNRepositoryLocation.
   * If useRootUrl is true, use the repository root URL.
   */
public static SVNRepositoryLocation fromString(String location, boolean validateOnly, boolean useRootUrl) throws SVNException {
    if (!useRootUrl)
        return fromString(location, validateOnly);
    ISVNClientAdapter svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
    try {
        SVNUrl url = new SVNUrl(location);
        ISVNInfo info = svnClient.getInfo(url);
        SVNUrl rootUrl = info.getRepository();
        return fromString(rootUrl.toString());
    } catch (MalformedURLException e) {
        throw SVNException.wrapException(e);
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 15 with SVNUrl

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

the class SVNHistoryPage method getCompareWithPreviousChangedPathAction.

private IAction getCompareWithPreviousChangedPathAction() {
    if (compareWithPreviousChangedPathAction == null) {
        compareWithPreviousChangedPathAction = new Action() {

            public void run() {
                CompareRemoteResourcesAction delegate = new CompareRemoteResourcesAction();
                delegate.init(this);
                ISVNRemoteResource remoteResource1 = null;
                Object firstSelection = ((IStructuredSelection) changePathsViewer.getSelection()).getFirstElement();
                if (firstSelection instanceof LogEntryChangePath) {
                    LogEntryChangePath logEntryChangePath = (LogEntryChangePath) firstSelection;
                    try {
                        remoteResource1 = logEntryChangePath.getRemoteResource();
                    } catch (SVNException e1) {
                        SVNUIPlugin.openError(getSite().getShell(), null, null, e1, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
                        return;
                    }
                } else if (firstSelection instanceof HistoryFolder) {
                    HistoryFolder historyFolder = (HistoryFolder) firstSelection;
                    Object[] children = historyFolder.getChildren();
                    if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
                        LogEntryChangePath logEntryChangePath = (LogEntryChangePath) children[0];
                        try {
                            SVNUrl svnUrl = logEntryChangePath.getRemoteResource().getRepository().getRemoteFolder(historyFolder.getPath()).getUrl();
                            SVNRevision.Number selectedRevision = (SVNRevision.Number) getSelectedRevision();
                            remoteResource1 = new RemoteFolder(null, logEntryChangePath.getLogEntry().getRemoteResource().getRepository(), svnUrl, selectedRevision, selectedRevision, null, null);
                        } catch (Exception e) {
                        }
                    }
                }
                if (remoteResource1 == null) {
                    return;
                }
                int from = Integer.parseInt(remoteResource1.getRevision().toString());
                from--;
                String to = Integer.toString(from);
                SVNRevision toRevision = null;
                try {
                    toRevision = SVNRevision.getRevision(to);
                } catch (ParseException e) {
                }
                ISVNRemoteResource[] remoteResources = new ISVNRemoteResource[2];
                ISVNRemoteResource remoteResource2;
                if (firstSelection instanceof HistoryFolder || remoteResource1.getResource() instanceof IContainer) {
                    remoteResource2 = new RemoteFolder(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
                } else {
                    remoteResource2 = new RemoteFile(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
                }
                remoteResources[0] = remoteResource1;
                remoteResources[1] = remoteResource2;
                delegate.selectionChanged(this, new StructuredSelection(remoteResources));
                delegate.setRemoteResources(remoteResources);
                delegate.setLocalResource(remoteResource1.getResource());
                delegate.setLocalResources(remoteResources);
                SVNRevision[] pegRevisions = { remoteResource1.getRevision() };
                delegate.setPegRevisions(pegRevisions);
                delegate.run(this);
            }
        };
    }
    return compareWithPreviousChangedPathAction;
}
Also used : CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) ExportRemoteFolderAction(org.tigris.subversion.subclipse.ui.actions.ExportRemoteFolderAction) ShowDifferencesAsUnifiedDiffAction(org.tigris.subversion.subclipse.ui.actions.ShowDifferencesAsUnifiedDiffAction) TextViewerAction(org.tigris.subversion.subclipse.ui.console.TextViewerAction) ShowAnnotationAction(org.tigris.subversion.subclipse.ui.actions.ShowAnnotationAction) ShowHistoryAction(org.tigris.subversion.subclipse.ui.actions.ShowHistoryAction) WorkspaceAction(org.tigris.subversion.subclipse.ui.actions.WorkspaceAction) IAction(org.eclipse.jface.action.IAction) OpenRemoteFileAction(org.tigris.subversion.subclipse.ui.actions.OpenRemoteFileAction) GenerateChangeLogAction(org.tigris.subversion.subclipse.ui.actions.GenerateChangeLogAction) Action(org.eclipse.jface.action.Action) CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ParseException(java.text.ParseException) ParseException(java.text.ParseException) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IContainer(org.eclipse.core.resources.IContainer) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile)

Aggregations

SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)83 SVNException (org.tigris.subversion.subclipse.core.SVNException)29 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)26 MalformedURLException (java.net.MalformedURLException)25 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)21 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)19 ParseException (java.text.ParseException)18 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)17 IResource (org.eclipse.core.resources.IResource)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)14 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)14 TeamException (org.eclipse.team.core.TeamException)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)13 ArrayList (java.util.ArrayList)12 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)12 File (java.io.File)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 RemoteFolder (org.tigris.subversion.subclipse.core.resources.RemoteFolder)8