Search in sources :

Example 1 with GetRemoteResourceCommand

use of org.tigris.subversion.subclipse.core.commands.GetRemoteResourceCommand in project subclipse by subclipse.

the class LocalResource method getRemoteResource.

/**
 * get the remote resource corresponding to the given revision of this local resource
 *
 * @return null if there is no remote file corresponding to this local resource
 * @throws SVNException
 */
public ISVNRemoteResource getRemoteResource(SVNRevision revision) throws SVNException {
    if (SVNRevision.BASE.equals(revision)) {
        // if the user wants the base resource, we can't get it using the url
        return getBaseResource();
    }
    // even if file is not managed, there can be a corresponding resource
    GetRemoteResourceCommand command = new GetRemoteResourceCommand(getRepository(), getUrl(), revision);
    command.run(null);
    return command.getRemoteResource();
}
Also used : GetRemoteResourceCommand(org.tigris.subversion.subclipse.core.commands.GetRemoteResourceCommand)

Example 2 with GetRemoteResourceCommand

use of org.tigris.subversion.subclipse.core.commands.GetRemoteResourceCommand in project subclipse by subclipse.

the class ResolveTreeConflictWizardMainPage method getRemoteResource.

private void getRemoteResource(ResolveTreeConflictWizard wizard, final SVNTreeConflict treeConflict) {
    ISVNRepositoryLocation repository = wizard.getSvnResource().getRepository();
    SVNRevision revision = new SVNRevision.Number(treeConflict.getConflictDescriptor().getSrcRightVersion().getPegRevision());
    try {
        SVNUrl url = new SVNUrl(treeConflict.getConflictDescriptor().getSrcRightVersion().getReposURL() + "/" + treeConflict.getConflictDescriptor().getSrcRightVersion().getPathInRepos());
        GetRemoteResourceCommand command = new GetRemoteResourceCommand(repository, url, revision);
        command.run(new NullProgressMonitor());
        remoteResource = command.getRemoteResource();
    } catch (Exception e) {
        SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) GetRemoteResourceCommand(org.tigris.subversion.subclipse.core.commands.GetRemoteResourceCommand) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) SVNException(org.tigris.subversion.subclipse.core.SVNException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with GetRemoteResourceCommand

use of org.tigris.subversion.subclipse.core.commands.GetRemoteResourceCommand in project subclipse by subclipse.

the class LogEntryChangePath method getRemoteResource.

/**
 * get the remote resource corresponding to this changed path or null if it cannot be determined
 *
 * @return
 * @throws SVNException
 */
public ISVNRemoteResource getRemoteResource() throws SVNException {
    SVNRevision revision = getRevision();
    if (getAction() == 'D') {
        long rev = Long.parseLong(revision.toString());
        rev--;
        revision = new SVNRevision.Number(rev);
    }
    SVNUrl url = getUrl();
    if (url == null) {
        return null;
    }
    if (remoteResource == null) {
        GetRemoteResourceCommand command = new GetRemoteResourceCommand(getRepository(), url, revision);
        command.run(null);
        remoteResource = command.getRemoteResource();
    }
    return remoteResource;
}
Also used : GetRemoteResourceCommand(org.tigris.subversion.subclipse.core.commands.GetRemoteResourceCommand) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision)

Example 4 with GetRemoteResourceCommand

use of org.tigris.subversion.subclipse.core.commands.GetRemoteResourceCommand in project subclipse by subclipse.

the class BranchTagOperation method execute.

protected void execute(SVNTeamProvider provider, IResource[] resources, IProgressMonitor monitor) throws SVNException, InterruptedException {
    if (branchCreated)
        return;
    branchCreated = true;
    monitor.beginTask(null, 100);
    try {
        BranchTagCommand command = new BranchTagCommand(provider.getSVNWorkspaceRoot(), getResources(), sourceUrls, destinationUrl, message, createOnServer, revision);
        command.setMakeParents(makeParents);
        command.setMultipleTransactions(multipleTransactions);
        command.run(Policy.subMonitorFor(monitor, 1000));
        if (svnExternals != null) {
            List<SVNUrl> copyToUrls = new ArrayList<SVNUrl>();
            List<String> fileList = new ArrayList<String>();
            Map<String, String> copyToMap = new HashMap<String, String>();
            for (SVNExternal svnExternal : svnExternals) {
                if (svnExternal.isSelected()) {
                    if (!fileList.contains(svnExternal.getFile().getAbsolutePath())) {
                        fileList.add(svnExternal.getFile().getAbsolutePath());
                        IResource[] localResources = SVNWorkspaceRoot.getResourcesFor(new Path(svnExternal.getFile().getPath()));
                        ISVNRemoteResource remoteResource = SVNWorkspaceRoot.getBaseResourceFor(localResources[0]);
                        for (SVNUrl sourceUrl : sourceUrls) {
                            if (remoteResource.getUrl().toString().startsWith(sourceUrl.toString())) {
                                SVNUrl copyToUrl = null;
                                SVNUrl destinationUrl = command.getDestinationUrl(sourceUrl.toString());
                                if (remoteResource.getUrl().toString().equals(sourceUrl.toString())) {
                                    copyToUrl = destinationUrl;
                                } else {
                                    try {
                                        copyToUrl = new SVNUrl(destinationUrl + remoteResource.getUrl().toString().substring(sourceUrl.toString().length()));
                                    } catch (MalformedURLException e) {
                                    }
                                }
                                if (copyToUrl != null) {
                                    copyToUrls.add(copyToUrl);
                                    copyToMap.put(copyToUrl.toString(), svnExternal.getFile().getAbsolutePath());
                                }
                                break;
                            }
                        }
                    }
                }
            }
            if (copyToUrls.size() > 0) {
                ISVNClientAdapter svnClient = null;
                try {
                    svnClient = provider.getSVNWorkspaceRoot().getRepository().getSVNClient();
                    for (SVNUrl copyToUrl : copyToUrls) {
                        String updatedProperty = getUpdatedSvnExternalsProperty(copyToUrl, copyToMap);
                        ISVNInfo info = svnClient.getInfo(copyToUrl);
                        svnClient.propertySet(copyToUrl, info.getRevision(), "svn:externals", updatedProperty, // $NON-NLS-1$
                        Policy.bind("BranchTagOperation.3"));
                    }
                } catch (Exception e) {
                    throw SVNException.wrapException(e);
                } finally {
                    provider.getSVNWorkspaceRoot().getRepository().returnSVNClient(svnClient);
                }
            }
        }
        SVNUIPlugin.getPlugin().getRepositoryManager().resourceCreated(null, null);
        if (newAlias != null)
            updateBranchTagProperty(resources[0]);
        if (switchAfterTagBranch) {
            for (int i = 0; i < sourceUrls.length; i++) {
                SVNUrl switchDestinationUrl = command.getDestinationUrl(sourceUrls[i].toString());
                // the copy command's destination URL can either be a path to an existing directory
                // or a path to a new directory. In the former case the last path segment of the
                // source path is automatically created at the destination
                GetRemoteResourceCommand getRemoteResourceCommand = new GetRemoteResourceCommand(provider.getSVNWorkspaceRoot().getRepository(), switchDestinationUrl, SVNRevision.HEAD);
                try {
                    getRemoteResourceCommand.run(null);
                } catch (SVNException e) {
                    if (e.getStatus().getCode() == TeamException.UNABLE) {
                        switchDestinationUrl = destinationUrl;
                    } else {
                        throw e;
                    }
                }
                resources = getResources();
                SwitchToUrlCommand switchToUrlCommand = new SwitchToUrlCommand(provider.getSVNWorkspaceRoot(), resources[i], switchDestinationUrl, SVNRevision.HEAD);
                switchToUrlCommand.run(Policy.subMonitorFor(monitor, 100));
            }
        }
    } catch (SVNException e) {
        if (e.operationInterrupted()) {
            showCancelledMessage();
        } else {
            collectStatus(e.getStatus());
        }
    } finally {
        monitor.done();
    }
}
Also used : Path(org.eclipse.core.runtime.Path) MalformedURLException(java.net.MalformedURLException) SwitchToUrlCommand(org.tigris.subversion.subclipse.core.commands.SwitchToUrlCommand) HashMap(java.util.HashMap) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ArrayList(java.util.ArrayList) SVNExternal(org.tigris.subversion.subclipse.core.SVNExternal) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) SVNException(org.tigris.subversion.subclipse.core.SVNException) MalformedURLException(java.net.MalformedURLException) TeamException(org.eclipse.team.core.TeamException) BranchTagCommand(org.tigris.subversion.subclipse.core.commands.BranchTagCommand) GetRemoteResourceCommand(org.tigris.subversion.subclipse.core.commands.GetRemoteResourceCommand) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

GetRemoteResourceCommand (org.tigris.subversion.subclipse.core.commands.GetRemoteResourceCommand)4 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)3 SVNException (org.tigris.subversion.subclipse.core.SVNException)2 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 IResource (org.eclipse.core.resources.IResource)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Path (org.eclipse.core.runtime.Path)1 TeamException (org.eclipse.team.core.TeamException)1 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)1 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)1 SVNExternal (org.tigris.subversion.subclipse.core.SVNExternal)1 BranchTagCommand (org.tigris.subversion.subclipse.core.commands.BranchTagCommand)1 SwitchToUrlCommand (org.tigris.subversion.subclipse.core.commands.SwitchToUrlCommand)1 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)1 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)1