Search in sources :

Example 1 with ISVNInfo

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

the class FileModificationManager method autoShareProjectIfSVNWorkingCopy.

private void autoShareProjectIfSVNWorkingCopy(IProject project) {
    ISVNClientAdapter client = null;
    try {
        client = SVNProviderPlugin.getPlugin().getSVNClient();
        SVNProviderPlugin.disableConsoleLogging();
        ISVNInfo info = client.getInfoFromWorkingCopy(project.getLocation().toFile());
        if (info != null && info.getRepository() != null) {
            SVNTeamProviderType.getAutoShareJob().share(project);
        }
    } catch (Exception e) {
    } finally {
        SVNProviderPlugin.enableConsoleLogging();
        if (client != null) {
            SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
        }
    }
}
Also used : ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 2 with ISVNInfo

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

the class GraphBackgroundTask method execute.

protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
    boolean error = false;
    Cache cache = null;
    monitor.beginTask("Calculating graph information", TOTAL_STEPS);
    monitor.worked(SHORT_TASK_STEPS);
    ISVNClientAdapter client = null;
    try {
        client = SVNProviderPlugin.getPlugin().getSVNClient();
        ISVNInfo info;
        if (resource == null)
            info = client.getInfo(remoteResource.getUrl());
        else {
            if (resource.getRawLocation() == null)
                info = client.getInfoFromWorkingCopy(resource.getLocation().toFile());
            else
                info = client.getInfoFromWorkingCopy(resource.getRawLocation().toFile());
            if (info.getUuid() == null) {
                info = client.getInfo(info.getUrl());
            }
        }
        if (editor != null)
            ((RevisionGraphEditorInput) editor.getEditorInput()).setInfo(info);
        long revision = info.getRevision().getNumber();
        String path = info.getUrl().toString().substring(info.getRepository().toString().length());
        monitor.setTaskName("Initializating cache");
        cache = getCache(info.getUuid());
        monitor.worked(SHORT_TASK_STEPS);
        // update the cache
        long latestRevisionStored = cache.getLatestRevision();
        SVNRevision latest = null;
        SVNRevision endRevision = null;
        monitor.setTaskName("Connecting to the repository");
        // TODO: try-catch this line and make it work off-line
        long latestRevisionInRepository = client.getInfo(info.getRepository()).getLastChangedRevision().getNumber();
        monitor.worked(SHORT_TASK_STEPS);
        if (refreshRevision != null || refreshRevisions != null || latestRevisionInRepository > latestRevisionStored) {
            if (refreshRevision == null) {
                if (latestRevisionStored >= latestRevisionInRepository)
                    latest = new SVNRevision.Number(latestRevisionInRepository);
                else
                    latest = new SVNRevision.Number(latestRevisionStored + 1);
            } else {
                latest = refreshRevision;
            }
            if (refreshRevision == null)
                endRevision = SVNRevision.HEAD;
            else
                endRevision = refreshRevision;
            try {
                monitor.setTaskName("Retrieving revision history");
                int unitWork;
                if (refreshRevision == null && refreshRevisions == null)
                    unitWork = VERY_LONG_TASK / (int) (latestRevisionInRepository - latestRevisionStored);
                else if (refreshRevisions != null)
                    unitWork = VERY_LONG_TASK / refreshRevisions.length;
                else
                    unitWork = VERY_LONG_TASK;
                if (refreshRevisions != null) {
                    if (monitor.isCanceled())
                        return;
                    monitor.setTaskName("Refreshing cache");
                    List refreshedNodes = new ArrayList();
                    for (int i = 0; i < refreshNodes.length; i++) {
                        if (refreshNodes[i].getAction() != 'D')
                            refreshedNodes.add(refreshNodes[i]);
                    }
                    cache.refresh(refreshedNodes, info, monitor, unitWork);
                } else if (refreshRevision != null) {
                    if (monitor.isCanceled())
                        return;
                    monitor.setTaskName("Refreshing cache");
                    revision = refreshNode.getRevision();
                    path = refreshNode.getPath();
                    List refreshedNodes = new ArrayList();
                    refreshedNodes.add(refreshNode);
                    cache.refresh(refreshedNodes, info, monitor, unitWork);
                }
                if (getNewRevisions) {
                    CallbackUpdater callbackUpdater = new CallbackUpdater(cache, monitor, unitWork, client);
                    cache.startUpdate();
                    client.getLogMessages(info.getRepository(), latest, latest, endRevision, false, true, 0, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callbackUpdater);
                    cache.finishUpdate();
                }
            } catch (Exception e) {
                Activator.handleError(e);
                error = true;
                Activator.showErrorDialog("Calculate Revision Graph Information", e, false);
            }
        } else {
            monitor.worked(VERY_LONG_TASK);
        }
        if (editor != null) {
            if (error == true || monitor.isCanceled()) {
                if (refreshRevision == null && refreshRevisions == null) {
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            IWorkbenchWindow window = editor.getEditorSite().getWorkbenchWindow();
                            IWorkbenchPage page = window.getActivePage();
                            page.activate(editor);
                            page.closeEditor(editor, false);
                        }
                    });
                }
            } else {
                updateView(monitor, cache, path, revision);
            }
        }
        monitor.done();
    } catch (Exception e) {
        Activator.handleError(e);
        Activator.showErrorDialog("Calculate Revision Graph Information", e, false);
        return;
    } finally {
        if (cache != null)
            cache.close();
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ArrayList(java.util.ArrayList) List(java.util.List) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) Cache(org.tigris.subversion.subclipse.graph.cache.Cache) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 3 with ISVNInfo

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

the class StatusCacheManager method getResourceRevision.

/**
 * The cached statuses do not provide revision numbers anymore. This method is the only place how
 * to query for the revision of the resource explicitely.
 *
 * @param resource
 * @return
 * @throws SVNException
 */
public SVNRevision getResourceRevision(ISVNLocalResource resource) throws SVNException {
    if (resource == null)
        return null;
    GetInfoCommand command = new GetInfoCommand(resource);
    command.run(null);
    final ISVNInfo info = command.getInfo();
    return (info != null) ? info.getRevision() : null;
}
Also used : GetInfoCommand(org.tigris.subversion.subclipse.core.commands.GetInfoCommand) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo)

Example 4 with ISVNInfo

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

the class StatusCacheManager 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) {
    String url = status.getUrlString();
    if (url == null && !(status.getTextStatus() == SVNStatusKind.UNVERSIONED) && !(status.getTextStatus() == SVNStatusKind.IGNORED)) {
        ISVNClientAdapter svnClient = null;
        try {
            svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
            SVNProviderPlugin.disableConsoleLogging();
            ISVNInfo info = svnClient.getInfoFromWorkingCopy(status.getFile());
            SVNUrl svnurl = info.getUrl();
            url = (svnurl != null) ? svnurl.toString() : null;
        } catch (SVNException e) {
        } catch (SVNClientException e) {
        } finally {
            SVNProviderPlugin.enableConsoleLogging();
            SVNProviderPlugin.getPlugin().getSVNClientManager().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 5 with ISVNInfo

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

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