use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class BranchTagAction method run.
public void run() {
BranchTagWizard wizard;
final IResource resource = ((RevisionGraphEditorInput) editor.getEditorInput()).getResource();
ISVNRemoteResource remoteResource = ((RevisionGraphEditorInput) editor.getEditorInput()).getRemoteResource();
if (resource == null) {
ISVNRemoteResource[] resources = { remoteResource };
wizard = new BranchTagWizard(resources);
} else {
IResource[] resources = { resource };
wizard = new BranchTagWizard(resources);
}
wizard.setRevisionNumber(node.getRevision());
WizardDialog dialog = new ClosableWizardDialog(Display.getDefault().getActiveShell(), wizard);
if (dialog.open() == WizardDialog.OK) {
final SVNUrl sourceUrl = wizard.getUrl();
final SVNUrl destinationUrl = wizard.getToUrl();
final String message = wizard.getComment();
final SVNRevision revision = wizard.getRevision();
final boolean makeParents = wizard.isMakeParents();
final SVNUrl[] sourceUrls = wizard.getUrls();
final boolean createOnServer = wizard.isCreateOnServer();
final Alias newAlias = wizard.getNewAlias();
final boolean switchAfter = wizard.isSwitchAfterBranchTag();
try {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ISVNClientAdapter client = null;
try {
if (resource == null) {
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
client.copy(sourceUrl, destinationUrl, message, revision, makeParents);
} else {
IResource[] resources = { resource };
BranchTagOperation branchTagOperation = new BranchTagOperation(editor.getEditorSite().getPart(), resources, sourceUrls, destinationUrl, createOnServer, revision, message);
branchTagOperation.setMakeParents(makeParents);
branchTagOperation.setNewAlias(newAlias);
branchTagOperation.switchAfterTagBranchOperation(switchAfter);
branchTagOperation.run();
}
} catch (Exception e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.createTagFromRevision"), e.getMessage());
} finally {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
});
} catch (Exception e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.createTagFromRevision"), e.getMessage());
}
}
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class CompareRevisionsAction method run.
public void run() {
RevisionGraphEditorInput input = (RevisionGraphEditorInput) editor.getEditorInput();
boolean isFolder = (input.getResource() != null && input.getResource().getType() != IResource.FILE) || (input.getRemoteResource() != null && input.getRemoteResource().isFolder());
ISVNInfo info = input.getInfo();
try {
ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(info.getRepository().toString());
ISVNRemoteResource remoteResource1;
ISVNRemoteResource remoteResource2;
if (isFolder) {
remoteResource1 = new RemoteFolder(repository, new SVNUrl(repository.getLocation() + node1.getBranch().getPath()), new SVNRevision.Number(node1.getRevision()));
remoteResource2 = new RemoteFolder(repository, new SVNUrl(repository.getLocation() + node2.getBranch().getPath()), new SVNRevision.Number(node2.getRevision()));
} else {
remoteResource1 = new RemoteFile(repository, new SVNUrl(repository.getLocation() + node1.getBranch().getPath()), new SVNRevision.Number(node1.getRevision()));
remoteResource2 = new RemoteFile(repository, new SVNUrl(repository.getLocation() + node2.getBranch().getPath()), new SVNRevision.Number(node2.getRevision()));
}
ISVNRemoteResource[] selectedResources = { remoteResource1, remoteResource2 };
DifferencesDialog dialog = new DifferencesDialog(Display.getDefault().getActiveShell(), null, selectedResources, editor.getEditorSite().getPart());
dialog.setFromRevision(Long.toString(node1.getRevision()));
dialog.setToRevision(Long.toString(node2.getRevision()));
dialog.open();
} catch (Exception e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Compare Revisions", e.getMessage());
}
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class ViewGraphAction method execute.
public void execute(IAction action) throws InterruptedException, InvocationTargetException {
if (action != null && !action.isEnabled()) {
action.setEnabled(true);
} else {
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
IResource[] resources = getSelectedResources();
try {
if (resources.length > 0) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]);
ISVNRemoteResource remoteResource = svnResource.getBaseResource();
if (remoteResource != null) {
String repoPath = remoteResource.getRepositoryRelativePath();
if (repoPath == null || repoPath.length() == 0) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("ViewGraphAction.0"), // $NON-NLS-1$ //$NON-NLS-2$
Policy.bind("ViewGraphAction.1"));
return;
}
}
// IEditorPart part =
getTargetPage().openEditor(new RevisionGraphEditorInput(resources[0]), // $NON-NLS-1$
"org.tigris.subversion.subclipse.graph.editors.revisionGraphEditor");
}
} catch (Exception e) {
Activator.handleError(e);
Activator.showErrorDialog(getErrorTitle(), e);
}
}
}, false, /* cancelable */
PROGRESS_BUSYCURSOR);
}
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class RemoteFolder method getMembers.
/**
* Get the members of this folder at the same revision than this resource
*
* @param monitor a progress monitor
* @return ISVNRemoteResource[] an array of child remoteResources
*/
protected ISVNRemoteResource[] getMembers(IProgressMonitor monitor) throws SVNException {
final IProgressMonitor progress = Policy.monitorFor(monitor);
// $NON-NLS-1$
progress.beginTask(Policy.bind("RemoteFolder.getMembers"), 100);
// Try to hit the cache first.
if (children != null) {
progress.done();
return children;
}
ISVNClientAdapter client = null;
try {
client = getRepository().getSVNClient();
ISVNDirEntryWithLock[] list = client.getListWithLocks(url, getRevision(), SVNRevision.HEAD, false);
List<RemoteResource> result = new ArrayList<RemoteResource>(list.length);
// directories first
for (ISVNDirEntryWithLock entryWithLock : list) {
ISVNDirEntry entry = entryWithLock.getDirEntry();
if (entry.getNodeKind() == SVNNodeKind.DIR) {
result.add(new RemoteFolder(this, getRepository(), url.appendPath(entry.getPath()), getRevision(), entry.getLastChangedRevision(), entry.getLastChangedDate(), entry.getLastCommitAuthor()));
}
}
// files then
for (ISVNDirEntryWithLock entryWithLock : list) {
ISVNDirEntry entry = entryWithLock.getDirEntry();
ISVNLock lock = entryWithLock.getLock();
if (entry.getNodeKind() == SVNNodeKind.FILE) {
RemoteFile remoteFile = new RemoteFile(this, getRepository(), url.appendPath(entry.getPath()), getRevision(), entry.getLastChangedRevision(), entry.getLastChangedDate(), entry.getLastCommitAuthor());
remoteFile.setPegRevision(getRevision());
remoteFile.setLock(lock);
result.add(remoteFile);
}
}
// Save it to the cache
children = (ISVNRemoteResource[]) result.toArray(new ISVNRemoteResource[result.size()]);
return children;
} catch (SVNClientException e) {
throw new SVNException(new SVNStatus(IStatus.ERROR, SVNStatus.DOES_NOT_EXIST, Policy.bind("RemoteFolder.doesNotExist", // $NON-NLS-1$
getRepositoryRelativePath())));
} finally {
getRepository().returnSVNClient(client);
progress.done();
}
}
use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.
the class RepositoryResourcesManager method deleteRemoteResources.
/**
* delete some remote resources Resources can be from several RemoteRepositoryLocations
*/
public void deleteRemoteResources(ISVNRemoteResource[] remoteResources, String message, IProgressMonitor monitor) throws SVNException {
IProgressMonitor progress = Policy.monitorFor(monitor);
progress.beginTask(Policy.bind("RepositoryResourcesManager.deleteRemoteResources"), // $NON-NLS-1$
100 * remoteResources.length);
// the given remote resources can come from more than a repository and so needs
// more than one svnClient
// we associate each repository with the corresponding resources to delete
HashMap<ISVNRepositoryLocation, List<ISVNRemoteResource>> mapRepositories = new HashMap<ISVNRepositoryLocation, List<ISVNRemoteResource>>();
for (ISVNRemoteResource remoteResource : remoteResources) {
ISVNRepositoryLocation repositoryLocation = remoteResource.getRepository();
List<ISVNRemoteResource> resources = (List<ISVNRemoteResource>) mapRepositories.get(repositoryLocation);
if (resources == null) {
resources = new ArrayList<ISVNRemoteResource>();
mapRepositories.put(repositoryLocation, resources);
}
resources.add(remoteResource);
}
ISVNClientAdapter svnClient = null;
ISVNRepositoryLocation repository = null;
try {
for (List<ISVNRemoteResource> resources : mapRepositories.values()) {
repository = (resources.get(0)).getRepository();
svnClient = repository.getSVNClient();
SVNUrl[] urls = new SVNUrl[resources.size()];
for (int i = 0; i < resources.size(); i++) {
ISVNRemoteResource resource = resources.get(i);
urls[i] = resource.getUrl();
// refresh just says that resource needs to be updated
// it does not update immediatly
resource.getParent().refresh();
}
svnClient.remove(urls, message);
repository.returnSVNClient(svnClient);
svnClient = null;
repository = null;
for (ISVNRemoteResource resource : resources) {
remoteResourceDeleted(resource);
}
progress.worked(100 * urls.length);
}
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
progress.done();
}
}
Aggregations