use of org.tigris.subversion.subclipse.core.commands.AddResourcesCommand in project subclipse by subclipse.
the class SVNLocalCompareInput method prepareCompareInput.
/**
* Runs the compare operation and returns the compare result.
*
* @throws InterruptedException
*/
protected ICompareInput prepareCompareInput(IProgressMonitor monitor) throws InterruptedException {
initLabels();
if (resource instanceof LocalFolder) {
try {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
// $NON-NLS-1$
monitor.beginTask(Policy.bind("SVNCompareEditorInput.comparing"), 30);
IProgressMonitor sub = new SubProgressMonitor(monitor, 30);
// $NON-NLS-1$
sub.beginTask(Policy.bind("SVNCompareEditorInput.comparing"), 100);
Object[] result = new Object[] { null };
ArrayList resourceSummaryNodeList = new ArrayList();
ArrayList summaryEditionNodeList = new ArrayList();
ISVNClientAdapter client = null;
if (resources == null) {
resources = new ISVNLocalResource[] { resource };
}
if (remoteFolders == null) {
remoteFolders = new ISVNRemoteFolder[] { (ISVNRemoteFolder) remoteResource };
}
try {
for (int i = 0; i < resources.length; i++) {
ISVNLocalResource resource = resources[i];
ISVNRemoteFolder remoteFolder = remoteFolders[i];
SVNDiffSummary[] diffSummary = null;
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
File file = new File(resource.getResource().getLocation().toString());
getUnadded(client, resource, file);
IResource[] unaddedResources = new IResource[unaddedList.size()];
unaddedList.toArray(unaddedResources);
SVNWorkspaceRoot workspaceRoot = new SVNWorkspaceRoot(resource.getResource().getProject());
AddResourcesCommand command = new AddResourcesCommand(workspaceRoot, unaddedResources, IResource.DEPTH_INFINITE);
command.run(monitor);
diffSummary = client.diffSummarize(file, remoteFolder.getUrl(), remoteFolder.getRevision(), true);
for (IResource unaddedResource : unaddedResources) {
try {
SVNWorkspaceRoot.getSVNResourceFor(unaddedResource).revert();
} catch (Exception e) {
}
}
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
client = null;
if (diffSummary != null && diffSummary.length > 0) {
diffSummary = getDiffSummaryWithSubfolders(diffSummary);
ITypedElement left = new SVNLocalResourceSummaryNode(resource, diffSummary, resource.getResource().getLocation().toString());
SummaryEditionNode right = new SummaryEditionNode(remoteFolder);
right.setName(resource.getFile().getName());
right.setRootFolder((RemoteFolder) remoteFolder);
right.setNodeType(SummaryEditionNode.RIGHT);
right.setRoot(true);
right.setDiffSummary(diffSummary);
String localCharset = Utilities.getCharset(resource.getIResource());
try {
right.setCharset(localCharset);
} catch (CoreException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
resourceSummaryNodeList.add(left);
summaryEditionNodeList.add(right);
}
}
if (resourceSummaryNodeList.size() == 0) {
result[0] = null;
} else {
Object[] resourceSummaryNodes = new Object[resourceSummaryNodeList.size()];
resourceSummaryNodeList.toArray(resourceSummaryNodes);
Object[] summaryEditionNodes = new Object[summaryEditionNodeList.size()];
summaryEditionNodeList.toArray(summaryEditionNodes);
MultipleSelectionNode left = new MultipleSelectionNode(resourceSummaryNodes);
MultipleSelectionNode right = new MultipleSelectionNode(summaryEditionNodes);
result[0] = new SummaryDifferencer().findDifferences(false, monitor, null, null, left, right);
fRoot = result[0];
}
} finally {
sub.done();
if (client != null) {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
if (result[0] instanceof DiffNode) {
DiffNode diffNode = (DiffNode) result[0];
if (!diffNode.hasChildren()) {
return null;
}
}
return (ICompareInput) result[0];
} catch (OperationCanceledException e) {
throw new InterruptedException(e.getMessage());
} catch (Exception e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
return null;
} finally {
monitor.done();
}
} else {
ITypedElement left = new SVNLocalResourceNode(resource);
ResourceEditionNode right = new ResourceEditionNode(remoteResource, pegRevision);
if (left.getType() == ITypedElement.FOLDER_TYPE) {
right.setLocalResource((SVNLocalResourceNode) left);
}
if (right.getType() == ITypedElement.FOLDER_TYPE) {
((SVNLocalResourceNode) left).setRemoteResource((ResourceEditionNode) right);
}
String localCharset = Utilities.getCharset(resource.getIResource());
try {
right.setCharset(localCharset);
} catch (CoreException e) {
SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
}
ICompareInput compareInput;
if (SVNRevision.BASE.equals(remoteRevision)) {
compareInput = (ICompareInput) new StatusAwareDifferencer().findDifferences(false, monitor, null, null, left, right);
} else {
compareInput = (ICompareInput) new RevisionAwareDifferencer((SVNLocalResourceNode) left, right, diffFile, pegRevision).findDifferences(false, monitor, null, null, left, right);
}
return compareInput;
}
}
use of org.tigris.subversion.subclipse.core.commands.AddResourcesCommand in project subclipse by subclipse.
the class SVNTeamProvider method add.
/**
* Add the given resources to the project.
*
* <p>The sematics follow that of SVN in the sense that any folders and files are created remotely
* on the next commit.
*/
public void add(IResource[] resources, int depth, IProgressMonitor progress) throws SVNException {
AddResourcesCommand command = new AddResourcesCommand(getSVNWorkspaceRoot(), resources, depth);
command.run(progress);
}
Aggregations