use of org.tigris.subversion.svnclientadapter.SVNUrl 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();
}
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class SVNRepositories method readState.
/**
* read the state of the plugin, ie the repositories locations
*
* @param dis
* @throws IOException
* @throws SVNException
*/
private void readState(DataInputStream dis) throws IOException, SVNException {
int version = dis.readInt();
if ((version < REPOSITORIES_STATE_FILE_VERSION_1) || (version > REPOSITORIES_STATE_FILE_VERSION_3)) {
Util.logError(Policy.bind("SVNProviderPlugin.unknownStateFileVersion", new Integer(version).toString()), // $NON-NLS-1$
null);
return;
}
int count = dis.readInt();
for (int i = 0; i < count; i++) {
ISVNRepositoryLocation root = SVNRepositoryLocation.fromString(dis.readUTF());
addToRepositoriesCache(root);
if (version >= REPOSITORIES_STATE_FILE_VERSION_2) {
String label = dis.readUTF();
if (!label.equals("")) {
root.setLabel(label);
}
}
if (version >= REPOSITORIES_STATE_FILE_VERSION_3) {
String repositoryRoot = dis.readUTF();
if (!repositoryRoot.equals("")) {
root.setRepositoryRoot(new SVNUrl(repositoryRoot));
}
}
}
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class LogEntry method getLogEntryChangePaths.
/*
* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.history.ILogEntry#getLogEntryChangePaths()
*/
public LogEntryChangePath[] getLogEntryChangePaths() {
ISVNLogMessageChangePath[] changePaths = null;
if (SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand()) {
SVNUrl url = resource.getRepository().getRepositoryRoot();
if (url == null)
url = updateRootUrl(resource);
changePaths = getPathsOnDemand(url);
if (changePaths == null) {
// Root URL is probably bad. Run svn info to retrieve the root URL and
// update it in the repository.
SVNUrl url2 = updateRootUrl(resource);
if (!url.toString().equals(url2.toString()))
changePaths = getPathsOnDemand(url);
// one last try using the resource URL
if (changePaths == null)
changePaths = getPathsOnDemand(resource.getUrl());
// Still nothing, just return an empty array
if (changePaths == null)
changePaths = new ISVNLogMessageChangePath[0];
}
} else {
changePaths = logMessage.getChangedPaths();
}
LogEntryChangePath[] logEntryChangePaths = new LogEntryChangePath[changePaths.length];
for (int i = 0; i < changePaths.length; i++) {
logEntryChangePaths[i] = new LogEntryChangePath(this, changePaths[i]);
}
return logEntryChangePaths;
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class SVNRepositoryLocation method fromString.
/*
* Parse a location string and return a SVNRepositoryLocation.
* If useRootUrl is true, use the repository root URL.
*/
public static SVNRepositoryLocation fromString(String location, boolean validateOnly, boolean useRootUrl) throws SVNException {
if (!useRootUrl)
return fromString(location, validateOnly);
ISVNClientAdapter svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
try {
SVNUrl url = new SVNUrl(location);
ISVNInfo info = svnClient.getInfo(url);
SVNUrl rootUrl = info.getRepository();
return fromString(rootUrl.toString());
} catch (MalformedURLException e) {
throw SVNException.wrapException(e);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
}
}
use of org.tigris.subversion.svnclientadapter.SVNUrl in project subclipse by subclipse.
the class SVNHistoryPage method getCompareWithPreviousChangedPathAction.
private IAction getCompareWithPreviousChangedPathAction() {
if (compareWithPreviousChangedPathAction == null) {
compareWithPreviousChangedPathAction = new Action() {
public void run() {
CompareRemoteResourcesAction delegate = new CompareRemoteResourcesAction();
delegate.init(this);
ISVNRemoteResource remoteResource1 = null;
Object firstSelection = ((IStructuredSelection) changePathsViewer.getSelection()).getFirstElement();
if (firstSelection instanceof LogEntryChangePath) {
LogEntryChangePath logEntryChangePath = (LogEntryChangePath) firstSelection;
try {
remoteResource1 = logEntryChangePath.getRemoteResource();
} catch (SVNException e1) {
SVNUIPlugin.openError(getSite().getShell(), null, null, e1, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
return;
}
} else if (firstSelection instanceof HistoryFolder) {
HistoryFolder historyFolder = (HistoryFolder) firstSelection;
Object[] children = historyFolder.getChildren();
if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
LogEntryChangePath logEntryChangePath = (LogEntryChangePath) children[0];
try {
SVNUrl svnUrl = logEntryChangePath.getRemoteResource().getRepository().getRemoteFolder(historyFolder.getPath()).getUrl();
SVNRevision.Number selectedRevision = (SVNRevision.Number) getSelectedRevision();
remoteResource1 = new RemoteFolder(null, logEntryChangePath.getLogEntry().getRemoteResource().getRepository(), svnUrl, selectedRevision, selectedRevision, null, null);
} catch (Exception e) {
}
}
}
if (remoteResource1 == null) {
return;
}
int from = Integer.parseInt(remoteResource1.getRevision().toString());
from--;
String to = Integer.toString(from);
SVNRevision toRevision = null;
try {
toRevision = SVNRevision.getRevision(to);
} catch (ParseException e) {
}
ISVNRemoteResource[] remoteResources = new ISVNRemoteResource[2];
ISVNRemoteResource remoteResource2;
if (firstSelection instanceof HistoryFolder || remoteResource1.getResource() instanceof IContainer) {
remoteResource2 = new RemoteFolder(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
} else {
remoteResource2 = new RemoteFile(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
}
remoteResources[0] = remoteResource1;
remoteResources[1] = remoteResource2;
delegate.selectionChanged(this, new StructuredSelection(remoteResources));
delegate.setRemoteResources(remoteResources);
delegate.setLocalResource(remoteResource1.getResource());
delegate.setLocalResources(remoteResources);
SVNRevision[] pegRevisions = { remoteResource1.getRevision() };
delegate.setPegRevisions(pegRevisions);
delegate.run(this);
}
};
}
return compareWithPreviousChangedPathAction;
}
Aggregations