use of org.tigris.subversion.subclipse.core.SVNException in project subclipse by subclipse.
the class LocalResource method getUrl.
/**
* get the url of the resource in the repository The resource does not need to exist in repository
*
* @return the url or null if cannot get the url (when project is not managed)
* @throws SVNException
*/
public SVNUrl getUrl() {
try {
LocalResourceStatus status = getStatusFromCache();
if (status.isManaged()) {
// if the resource is managed, get the url directly
return status.getUrl();
} else {
// otherwise, get the url of the parent
SVNUrl parentUrl = null;
ISVNLocalResource parent = getParent();
if (parent != null) {
parentUrl = parent.getUrl();
}
if (parentUrl == null) {
// we cannot find the url
return null;
}
return parentUrl.appendPath(resource.getName());
}
} catch (SVNException e) {
return null;
}
}
use of org.tigris.subversion.subclipse.core.SVNException 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.SVNException in project subclipse by subclipse.
the class SVNRepositoryLocation method getRemoteFile.
/*
* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.ISVNRepositoryLocation#getRemoteFile(org.tigris.subversion.svnclientadapter.SVNUrl)
*/
public ISVNRemoteFile getRemoteFile(SVNUrl url) throws SVNException {
ISVNClientAdapter svnClient = getSVNClient();
ISVNInfo info = null;
try {
if (this.getRepositoryRoot().equals(url))
return new RemoteFile(this, url, SVNRevision.HEAD);
else
info = svnClient.getInfo(url, SVNRevision.HEAD, SVNRevision.HEAD);
} catch (SVNClientException e) {
throw new SVNException("Can't get latest remote resource for " + url);
}
if (// no remote file
info == null)
// no remote file
return null;
else {
return new RemoteFile(// we don't know its parent
null, this, url, SVNRevision.HEAD, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
}
}
use of org.tigris.subversion.subclipse.core.SVNException in project subclipse by subclipse.
the class LocalFolder method getSVNFolders.
public IFolder[] getSVNFolders(IProgressMonitor monitor, final boolean unmanage) throws SVNException {
final ArrayList<IFolder> svnFolders = new ArrayList<IFolder>();
SVNProviderPlugin.run(new ISVNRunnable() {
public void run(IProgressMonitor pm) throws SVNException {
pm = Policy.monitorFor(pm);
pm.beginTask(null, 100);
ISVNResource[] members = members(Policy.subMonitorFor(pm, 20), FOLDER_MEMBERS | MANAGED_MEMBERS);
ArrayList<IContainer> dirs = new ArrayList<IContainer>();
for (ISVNResource member : members) {
dirs.add((IContainer) ((ISVNLocalResource) member).getIResource());
}
// we add the current folder to the
dirs.add((IContainer) getIResource());
// list : we want to add .svn dir
// for it too
IProgressMonitor monitorDel = Policy.subMonitorFor(pm, 80);
monitorDel.beginTask(null, dirs.size());
for (IContainer container : dirs) {
monitorDel.worked(1);
recursiveGetSVNFolders(container, monitorDel, unmanage);
}
monitorDel.done();
pm.done();
}
private void recursiveGetSVNFolders(IContainer container, IProgressMonitor pm, boolean unmanage) {
try {
// We must not add svn directories for linked resources.
if (container.isLinked())
return;
pm.beginTask(null, 10);
pm.subTask(container.getFullPath().toOSString());
IResource[] members = container.members(true);
for (IResource member : members) {
pm.worked(1);
if (member.getType() != IResource.FILE) {
recursiveGetSVNFolders((IContainer) member, pm, unmanage);
}
}
// Post order traversal
IFolder svnFolder = container.getFolder(new Path(SVNProviderPlugin.getPlugin().getAdminDirectoryName()));
if (svnFolder.exists()) {
svnFolders.add(svnFolder);
if (unmanage) {
try {
svnFolder.delete(true, null);
} catch (CoreException e) {
}
}
}
} catch (CoreException e) {
// Just ignore and continue
} finally {
pm.done();
}
}
}, Policy.subMonitorFor(monitor, 99));
IFolder[] folderArray = new IFolder[svnFolders.size()];
svnFolders.toArray(folderArray);
return folderArray;
}
use of org.tigris.subversion.subclipse.core.SVNException in project subclipse by subclipse.
the class AliasManager method getAliases.
private Alias[] getAliases(IResource resource, boolean checkParents) {
ArrayList<Alias> aliases = new ArrayList<Alias>();
if (resource != null) {
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
try {
if (svnResource.isManaged()) {
ISVNProperty property = null;
// $NON-NLS-1$
property = svnResource.getSvnProperty("subclipse:tags");
if (property != null && property.getValue() != null)
getAliases(aliases, property.getValue(), svnResource.getUrl().toString());
if (checkParents) {
IResource checkResource = resource;
while (checkResource.getParent() != null) {
checkResource = checkResource.getParent();
Alias[] parentAliases = getAliases(checkResource, false);
for (Alias parentAlias : parentAliases) {
if (aliases.contains(parentAlias)) {
Alias checkAlias = (Alias) aliases.get(aliases.indexOf(parentAlias));
if (parentAlias.getRevision() < checkAlias.getRevision()) {
aliases.remove(checkAlias);
aliases.add(parentAlias);
}
} else
aliases.add(parentAlias);
}
}
}
}
} catch (SVNException e) {
}
}
Alias[] aliasArray = new Alias[aliases.size()];
aliases.toArray(aliasArray);
return aliasArray;
}
Aggregations