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();
}
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);
}
}
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;
}
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();
}
}
Aggregations