Search in sources :

Example 6 with ISVNInfo

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

the class CheckoutCommand method scrubProject.

/*
   * Delete the target projects before checking out
   * @param monitor - may be null !
   */
private void scrubProject(ISVNRemoteFolder resource, IProject project, IProgressMonitor monitor) throws SVNException {
    if (project == null) {
        if (monitor != null) {
            monitor.done();
        }
        return;
    }
    if (monitor != null) {
        monitor.beginTask("", 100);
        monitor.subTask(// $NON-NLS-1$
        Policy.bind("SVNProvider.Scrubbing_local_project_1", project.getName()));
    }
    try {
        File destPath = null;
        if (projectRoot != null) {
            destPath = new File(projectRoot.toFile(), project.getName());
        }
        // New location, just delete the project but not the content.
        if (destPath != null && !destPath.exists() && project != null && project.exists()) {
            project.delete(IResource.NEVER_DELETE_PROJECT_CONTENT, monitor);
            project = null;
        }
        if (project != null && project.exists() && (destPath == null || destPath.exists())) {
            if (!project.isOpen()) {
                project.open((monitor != null) ? Policy.subMonitorFor(monitor, 10) : null);
            }
            // unmap the project from any previous repository provider
            if (RepositoryProvider.getProvider(project) != null)
                RepositoryProvider.unmap(project);
            IResource[] children = project.members(IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
            IProgressMonitor subMonitor = (monitor != null) ? Policy.subMonitorFor(monitor, 80) : null;
            if (subMonitor != null) {
                subMonitor.beginTask(null, children.length * 100);
            }
            ISVNClientAdapter clientSilent = null;
            try {
                for (int j = 0; j < children.length; j++) {
                    if (!children[j].getName().equals(".project")) {
                        // $NON-NLS-1$
                        if (clientSilent == null)
                            clientSilent = SVNProviderPlugin.getPlugin().getSVNClient();
                        ISVNInfo info = null;
                        try {
                            SVNUrl url = new SVNUrl(resource.getUrl().toString() + "/" + children[j].getProjectRelativePath());
                            try {
                                SVNProviderPlugin.disableConsoleLogging();
                                info = clientSilent.getInfo(url);
                            } catch (SVNClientException e2) {
                            } finally {
                                SVNProviderPlugin.enableConsoleLogging();
                            }
                        } catch (MalformedURLException e1) {
                        }
                        if (info != null)
                            children[j].delete(true, /* force */
                            (subMonitor != null) ? Policy.subMonitorFor(subMonitor, 100) : null);
                    }
                }
            } finally {
                if (subMonitor != null) {
                    subMonitor.done();
                }
                SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(clientSilent);
            }
        } else if (project != null) {
            // Make sure there is no directory in the local file system.
            File location = new File(project.getParent().getLocation().toFile(), project.getName());
            if (location.exists()) {
                deepDelete(location);
            }
        }
    } catch (CoreException e) {
        throw SVNException.wrapException(e);
    } finally {
        if (monitor != null) {
            monitor.subTask(" ");
            monitor.done();
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MalformedURLException(java.net.MalformedURLException) CoreException(org.eclipse.core.runtime.CoreException) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) File(java.io.File) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 7 with ISVNInfo

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

the class GetLogsCommand method run.

/**
 * execute the command
 *
 * @param aMonitor
 * @throws SVNException
 */
public void run(IProgressMonitor aMonitor) throws SVNException {
    ISVNRepositoryLocation repository = null;
    ISVNClientAdapter svnClient = null;
    logEntries = null;
    IProgressMonitor monitor = Policy.monitorFor(aMonitor);
    // $NON-NLS-1$
    monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100);
    ISVNLogMessage[] logMessages;
    try {
        if (callback == null) {
            logMessages = remoteResource.getLogMessages(pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions);
        } else {
            repository = remoteResource.getRepository();
            svnClient = repository.getSVNClient();
            if (remoteResource instanceof BaseResource) {
                boolean logMessagesRetrieved = false;
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(remoteResource.getResource());
                if (svnResource != null) {
                    LocalResourceStatus status = svnResource.getStatus();
                    if (status != null && status.isCopied()) {
                        ISVNInfo info = svnClient.getInfoFromWorkingCopy(svnResource.getFile());
                        SVNUrl copiedFromUrl = info.getCopyUrl();
                        if (copiedFromUrl != null) {
                            svnClient.getLogMessages(copiedFromUrl, SVNRevision.HEAD, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
                            logMessagesRetrieved = true;
                            GetRemoteResourceCommand getRemoteResourceCommand = new GetRemoteResourceCommand(remoteResource.getRepository(), copiedFromUrl, SVNRevision.HEAD);
                            getRemoteResourceCommand.run(null);
                            remoteResource = getRemoteResourceCommand.getRemoteResource();
                        }
                    }
                }
                if (!logMessagesRetrieved)
                    svnClient.getLogMessages(((BaseResource) remoteResource).getFile(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
            } else {
                svnClient.getLogMessages(remoteResource.getUrl(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
            }
            logMessages = callback.getLogMessages();
        }
        if (remoteResource.isFolder()) {
            logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFolder) remoteResource, logMessages, getTags(logMessages));
        } else {
            logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFile) remoteResource, logMessages, getTags(logMessages), getUrls(logMessages));
        }
    } catch (Exception e) {
        throw SVNException.wrapException(e);
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
        monitor.done();
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) BaseResource(org.tigris.subversion.subclipse.core.resources.BaseResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) ISVNLogMessage(org.tigris.subversion.svnclientadapter.ISVNLogMessage) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 8 with ISVNInfo

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

the class GetRemoteResourceCommand method run.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
   */
public void run(IProgressMonitor monitor) throws SVNException {
    monitor = Policy.monitorFor(monitor);
    // $NON-NLS-1$
    monitor.beginTask(Policy.bind("GetRemoteResourceCommand.getLogEntries"), 100);
    remoteResource = null;
    ISVNClientAdapter svnClient = repository.getSVNClient();
    ISVNInfo info;
    try {
        info = svnClient.getInfo(url, revision, revision);
    } catch (SVNClientException e) {
        throw new SVNException("Can't get remote resource " + url + " at revision " + revision, e);
    } finally {
        repository.returnSVNClient(svnClient);
    }
    if (info == null) {
        // no remote file
        remoteResource = null;
    } else {
        if (info.getNodeKind() == SVNNodeKind.FILE)
            remoteResource = new RemoteFile(// we don't know its parent
            null, repository, url, revision, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
        else
            remoteResource = new RemoteFolder(// we don't know its parent
            null, repository, url, revision, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
    }
    monitor.done();
}
Also used : RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNException(org.tigris.subversion.subclipse.core.SVNException) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 9 with ISVNInfo

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

the class GetStatusCommand method getURL.

// getStatuses returns null URL for svn:externals folder.  This will
// get the URL using svn info command on the local resource
private String getURL(ISVNStatus status) {
    ISVNClientAdapter svnClient = null;
    String url = status.getUrlString();
    if (url == null && !(status.getTextStatus() == SVNStatusKind.UNVERSIONED)) {
        try {
            svnClient = repository.getSVNClient();
            ISVNInfo info = svnClient.getInfoFromWorkingCopy(status.getFile());
            SVNUrl svnurl = info.getUrl();
            url = (svnurl != null) ? svnurl.toString() : null;
        } catch (SVNException e) {
        } catch (SVNClientException e) {
        } finally {
            repository.returnSVNClient(svnClient);
        }
    }
    return url;
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 10 with ISVNInfo

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

the class SVNRepositoryLocation method getRemoteFile.

/*
   * (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.ISVNRepositoryLocation#getRemoteFile(org.tigris.subversion.svnclientadapter.SVNUrl)
   */
public ISVNRemoteFile getRemoteFile(SVNUrl url) throws SVNException {
    ISVNClientAdapter svnClient = getSVNClient();
    ISVNInfo info = null;
    try {
        if (this.getRepositoryRoot().equals(url))
            return new RemoteFile(this, url, SVNRevision.HEAD);
        else
            info = svnClient.getInfo(url, SVNRevision.HEAD, SVNRevision.HEAD);
    } catch (SVNClientException e) {
        throw new SVNException("Can't get latest remote resource for " + url);
    }
    if (// no remote file
    info == null)
        // no remote file
        return null;
    else {
        return new RemoteFile(// we don't know its parent
        null, this, url, SVNRevision.HEAD, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
    }
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)26 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)19 SVNException (org.tigris.subversion.subclipse.core.SVNException)13 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)12 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)8 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)7 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)5 IResource (org.eclipse.core.resources.IResource)4 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)4 File (java.io.File)3 MalformedURLException (java.net.MalformedURLException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Alias (org.tigris.subversion.subclipse.core.history.Alias)3 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)3 RevisionGraphEditorInput (org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput)3 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)3 ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2 ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)2 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)2