use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class GetRemoteResourceCommand method run.
/* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor) throws SVNException {
monitor = Policy.monitorFor(monitor);
// $NON-NLS-1$
monitor.beginTask(Policy.bind("GetRemoteResourceCommand.getLogEntries"), 100);
remoteResource = null;
ISVNClientAdapter svnClient = repository.getSVNClient();
ISVNInfo info;
try {
info = svnClient.getInfo(url, revision, revision);
} catch (SVNClientException e) {
throw new SVNException("Can't get remote resource " + url + " at revision " + revision, e);
} finally {
repository.returnSVNClient(svnClient);
}
if (info == null) {
// no remote file
remoteResource = null;
} else {
if (info.getNodeKind() == SVNNodeKind.FILE)
remoteResource = new RemoteFile(// we don't know its parent
null, repository, url, revision, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
else
remoteResource = new RemoteFolder(// we don't know its parent
null, repository, url, revision, info.getLastChangedRevision(), info.getLastChangedDate(), info.getLastCommitAuthor());
}
monitor.done();
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class GetStatusCommand method getURL.
// getStatuses returns null URL for svn:externals folder. This will
// get the URL using svn info command on the local resource
private String getURL(ISVNStatus status) {
ISVNClientAdapter svnClient = null;
String url = status.getUrlString();
if (url == null && !(status.getTextStatus() == SVNStatusKind.UNVERSIONED)) {
try {
svnClient = repository.getSVNClient();
ISVNInfo info = svnClient.getInfoFromWorkingCopy(status.getFile());
SVNUrl svnurl = info.getUrl();
url = (svnurl != null) ? svnurl.toString() : null;
} catch (SVNException e) {
} catch (SVNClientException e) {
} finally {
repository.returnSVNClient(svnClient);
}
}
return url;
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class PeekStatusCommand method execute.
public void execute() throws SVNException {
ISVNClientAdapter client = null;
ISVNNotifyListener revisionListener = new ISVNNotifyListener() {
public void setCommand(int command) {
}
public void logCommandLine(String commandLine) {
}
public void logMessage(String message) {
}
public void logError(String message) {
}
public void logRevision(long aRevision, String path) {
PeekStatusCommand.this.revision = new SVNRevision.Number(aRevision);
}
public void logCompleted(String message) {
}
public void onNotify(File path, SVNNodeKind kind) {
}
};
try {
client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
client.addNotifyListener(revisionListener);
File file;
if (resource != null)
file = resource.getLocation().toFile();
else
file = path.toFile();
status = null;
ISVNStatus[] statuses = client.getStatus(file, false, true, false);
for (int i = 0; i < statuses.length; i++) {
if (file.equals(statuses[i].getFile())) {
status = statuses[i];
if (status.getUrl() == null && !(status.getTextStatus() == SVNStatusKind.UNVERSIONED))
info = client.getInfo(status.getFile());
break;
}
}
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
if (client != null) {
client.removeNotifyListener(revisionListener);
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class StatusAndInfoCommand method run.
/* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor) throws SVNException {
ISVNClientAdapter svnClient = null;
try {
svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
execute(svnClient, monitor);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class AddResourcesCommand method run.
/* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.commands.ISVNCommand#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor) throws SVNException {
monitor = Policy.monitorFor(monitor);
// Visit the children of the resources using the depth in order to
// determine which folders, text files and binary files need to be added
// A TreeSet is needed for the folders so they are in the right order (i.e. parents created
// before children)
final SortedSet<ISVNLocalResource> folders = new TreeSet<ISVNLocalResource>();
// Sets are required for the files to ensure that files will not appear twice if there parent
// was added as well
// and the depth isn't zero
final HashSet<ISVNLocalResource> files = new HashSet<ISVNLocalResource>();
for (int i = 0; i < resources.length; i++) {
final IResource currentResource = resources[i];
try {
// Auto-add parents if they are not already managed
IContainer parent = currentResource.getParent();
ISVNLocalResource svnParentResource = SVNWorkspaceRoot.getSVNResourceFor(parent);
while (parent.getType() != IResource.ROOT && parent.getType() != IResource.PROJECT && !svnParentResource.isManaged()) {
folders.add(svnParentResource);
parent = parent.getParent();
svnParentResource = svnParentResource.getParent();
}
// Auto-add children accordingly to depth
final SVNException[] exception = new SVNException[] { null };
currentResource.accept(new IResourceVisitor() {
public boolean visit(IResource resource) {
try {
ISVNLocalResource mResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
// added explicitly (is equal currentResource) or is not ignored
if ((!mResource.isManaged()) && (currentResource.equals(resource) || !mResource.isIgnored())) {
if (resource.getType() == IResource.FILE) {
files.add(mResource);
} else {
folders.add(mResource);
}
}
// Always return true and let the depth determine if children are visited
return true;
} catch (SVNException e) {
exception[0] = e;
return false;
}
}
}, depth, false);
if (exception[0] != null) {
throw exception[0];
}
} catch (CoreException e) {
throw new SVNException(new Status(IStatus.ERROR, SVNProviderPlugin.ID, TeamException.UNABLE, Policy.bind("SVNTeamProvider.visitError", new Object[] { resources[i].getFullPath() }), // $NON-NLS-1$
e));
}
}
// for
// If an exception occured during the visit, throw it here
// Add the folders, followed by files!
ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
monitor.beginTask(null, files.size() + folders.size());
monitor.setTaskName("Adding...");
svnClient.addNotifyListener(operationResourceCollector);
OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor, svnClient));
try {
for (ISVNLocalResource localResource : folders) {
try {
svnClient.addDirectory(localResource.getIResource().getLocation().toFile(), false);
localResource.refreshStatus();
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
}
}
for (ISVNLocalResource localResource : files) {
try {
svnClient.addFile(localResource.getIResource().getLocation().toFile());
// If file has read-only attribute set, remove it
ResourceAttributes attrs = localResource.getIResource().getResourceAttributes();
if (localResource.getIResource().getType() == IResource.FILE && attrs.isReadOnly()) {
attrs.setReadOnly(false);
try {
localResource.getIResource().setResourceAttributes(attrs);
} catch (CoreException swallow) {
}
}
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
}
}
} finally {
Set<IResource> operationResources = operationResourceCollector.getOperationResources();
OperationManager.getInstance().endOperation(true, operationResources);
monitor.done();
if (svnClient != null) {
svnClient.removeNotifyListener(operationResourceCollector);
root.getRepository().returnSVNClient(svnClient);
}
}
}
Aggregations