Search in sources :

Example 6 with SVNUrl

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

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

the class PeekStatusCommand 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 && info != null) {
        SVNUrl svnurl = info.getUrl();
        url = (svnurl != null) ? svnurl.toString() : null;
    }
    return url;
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl)

Example 8 with SVNUrl

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

the class ShareProjectCommand 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 {
    // Determine if the repository is known
    boolean alreadyExists = SVNProviderPlugin.getPlugin().getRepositories().isKnownRepository(location.getLocation(), false);
    final ISVNClientAdapter svnClient = location.getSVNClient();
    try {
        // perform the workspace modifications in a runnable
        SVNProviderPlugin.run(new ISVNRunnable() {

            public void run(IProgressMonitor pm) throws SVNException {
                String message;
                if (comment == null)
                    // $NON-NLS-1$
                    message = Policy.bind("SVNProvider.initialImport");
                else
                    message = comment;
                try {
                    // create the remote dir
                    SVNUrl url = location.getUrl().appendPath(remoteDirName);
                    if (createDirectory)
                        svnClient.mkdir(url, true, message);
                    try {
                        OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(pm, svnClient));
                        // checkout it so that we have .svn
                        // If directory already existed in repository, do recursive checkout.
                        svnClient.checkout(url, project.getLocation().toFile(), SVNRevision.HEAD, !createDirectory);
                    } finally {
                        OperationManager.getInstance().endOperation();
                    }
                } catch (SVNClientException e) {
                    throw new SVNException("Error while creating module: " + e.getMessage(), e);
                }
                // SharingWizard.doesSVNDirectoryExist calls
                // getStatus on the folder which populates the
                // status cache
                // Need to clear the cache so we can get the new
                // hasRemote value
                SVNProviderPlugin.getPlugin().getStatusCacheManager().refreshStatus(project, true);
                try {
                    // Register it with Team.
                    RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
                } catch (TeamException e) {
                    throw new SVNException("Cannot register project with svn provider", e);
                }
            }
        }, monitor);
    } catch (SVNException e) {
        // its cache
        if (!alreadyExists)
            SVNProviderPlugin.getPlugin().getRepositories().disposeRepository(location);
        throw e;
    } finally {
        location.returnSVNClient(svnClient);
    }
    // Add the repository if it didn't exist already
    if (!alreadyExists)
        SVNProviderPlugin.getPlugin().getRepositories().addOrUpdateRepository(location);
}
Also used : ISVNRunnable(org.tigris.subversion.subclipse.core.ISVNRunnable) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter) OperationProgressNotifyListener(org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)

Example 9 with SVNUrl

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

the class LocalResource method getUrl.

/**
 * get the url of the resource in the repository The resource does not need to exist in repository
 *
 * @return the url or null if cannot get the url (when project is not managed)
 * @throws SVNException
 */
public SVNUrl getUrl() {
    try {
        LocalResourceStatus status = getStatusFromCache();
        if (status.isManaged()) {
            // if the resource is managed, get the url directly
            return status.getUrl();
        } else {
            // otherwise, get the url of the parent
            SVNUrl parentUrl = null;
            ISVNLocalResource parent = getParent();
            if (parent != null) {
                parentUrl = parent.getUrl();
            }
            if (parentUrl == null) {
                // we cannot find the url
                return null;
            }
            return parentUrl.appendPath(resource.getName());
        }
    } catch (SVNException e) {
        return null;
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource)

Example 10 with SVNUrl

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

the class RepositoryResourcesManager method moveRemoteResource.

public void moveRemoteResource(ISVNRemoteResource resource, ISVNRemoteFolder destinationFolder, String destinationResourceName, String message, IProgressMonitor monitor) throws SVNException {
    IProgressMonitor progress = Policy.monitorFor(monitor);
    progress.beginTask(Policy.bind("RepositoryResourcesManager.moveRemoteResources"), // $NON-NLS-1$
    100);
    ISVNClientAdapter svnClient = null;
    try {
        svnClient = resource.getRepository().getSVNClient();
        SVNUrl destUrl = destinationFolder.getUrl().appendPath(destinationResourceName);
        svnClient.move(resource.getUrl(), destUrl, message, SVNRevision.HEAD);
        resource.getParent().refresh();
        destinationFolder.refresh();
        remoteResourceMoved(resource, destinationFolder, destinationResourceName);
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        resource.getRepository().returnSVNClient(svnClient);
        progress.done();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

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