use of org.tigris.subversion.subclipse.core.commands.BranchTagCommand 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();
}
}
use of org.tigris.subversion.subclipse.core.commands.BranchTagCommand in project subclipse by subclipse.
the class RepositoryBranchTagOperation method execute.
protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
monitor.beginTask(null, 100);
try {
BranchTagCommand command = new BranchTagCommand(svnClient, null, sourceUrls, destinationUrl, message, true, revision);
command.setMakeParents(makeParents);
command.setMultipleTransactions(multipleTransactions);
command.run(Policy.subMonitorFor(monitor, 1000));
SVNUIPlugin.getPlugin().getRepositoryManager().resourceCreated(null, null);
} catch (SVNException e) {
if (e.operationInterrupted()) {
showCancelledMessage();
} else {
collectStatus(e.getStatus());
}
} finally {
monitor.done();
}
}
Aggregations