use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class SVNMoveDeleteHook method moveFile.
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.team.IMoveDeleteHook#moveFile(org.eclipse.core.resources.team.IResourceTree,
* org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile,
* int, org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean moveFile(IResourceTree tree, IFile source, IFile destination, int updateFlags, IProgressMonitor monitor) {
if (SVNWorkspaceRoot.isLinkedResource(source))
return false;
try {
RepositoryProvider repositoryProvider = RepositoryProvider.getProvider(destination.getProject());
if (repositoryProvider == null || // target is not SVN project
!(repositoryProvider instanceof SVNTeamProvider))
return false;
ISVNLocalFile resource = new LocalFile(source);
// pass
if (!resource.isManaged())
return false;
ISVNRepositoryLocation sourceRepository = resource.getRepository();
ISVNClientAdapter svnClient = sourceRepository.getSVNClient();
ISVNLocalResource parent = SVNWorkspaceRoot.getSVNResourceFor(destination.getParent());
ISVNRepositoryLocation targetRepository = parent.getRepository();
if (!sourceRepository.equals(targetRepository)) {
return false;
}
monitor.beginTask(null, 1000);
try {
OperationManager.getInstance().beginOperation(svnClient);
// see bug #15
if (!SVNWorkspaceRoot.getSVNFolderFor(destination.getParent()).isManaged()) {
SVNTeamProvider provider = (SVNTeamProvider) repositoryProvider;
provider.add(new IResource[] { destination.getParent() }, IResource.DEPTH_ZERO, new NullProgressMonitor());
if (parent != null)
parent.refreshStatus();
}
// force is set to true because when we rename (refactor) a
// java class, the file is modified before being moved
// A modified file cannot be moved without force
svnClient.move(source.getLocation().toFile(), destination.getLocation().toFile(), true);
// movedFile must be done before endOperation because
// destination file must not already exist in the workspace
// resource tree.
tree.movedFile(source, destination);
destination.refreshLocal(IResource.DEPTH_ZERO, monitor);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} catch (TeamException e) {
throw SVNException.wrapException(e);
} catch (CoreException e) {
throw SVNException.wrapException(e);
} finally {
resource.getRepository().returnSVNClient(svnClient);
OperationManager.getInstance().endOperation(false, null, false);
}
} catch (SVNException e) {
tree.failed(e.getStatus());
} finally {
monitor.done();
}
return true;
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class SVNMoveDeleteHook method moveFolder.
public boolean moveFolder(IResourceTree tree, IFolder source, IFolder destination, int updateFlags, IProgressMonitor monitor) {
if (SVNWorkspaceRoot.isLinkedResource(source))
return false;
try {
ISVNLocalFolder resource = new LocalFolder(source);
if (!resource.isManaged())
return false;
RepositoryProvider repositoryProvider = RepositoryProvider.getProvider(destination.getProject());
if (repositoryProvider == null || // target is not SVN project
!(repositoryProvider instanceof SVNTeamProvider))
return false;
ISVNRepositoryLocation sourceRepository = resource.getRepository();
ISVNLocalResource parent = SVNWorkspaceRoot.getSVNResourceFor(destination.getParent());
ISVNRepositoryLocation targetRepository = parent.getRepository();
if (!sourceRepository.equals(targetRepository)) {
return false;
}
monitor.beginTask(null, 1000);
ISVNClientAdapter svnClient = sourceRepository.getSVNClient();
try {
OperationManager.getInstance().beginOperation(svnClient);
// see bug #15
if (!SVNWorkspaceRoot.getSVNFolderFor(destination.getParent()).isManaged()) {
SVNTeamProvider provider = (SVNTeamProvider) repositoryProvider;
provider.add(new IResource[] { destination.getParent() }, IResource.DEPTH_ZERO, new NullProgressMonitor());
if (parent != null)
parent.refreshStatus();
}
svnClient.move(source.getLocation().toFile(), destination.getLocation().toFile(), true);
tree.movedFolderSubtree(source, destination);
destination.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} catch (CoreException e) {
throw SVNException.wrapException(e);
} finally {
resource.getRepository().returnSVNClient(svnClient);
OperationManager.getInstance().endOperation(false);
}
} catch (SVNException e) {
tree.failed(e.getStatus());
} finally {
monitor.done();
}
return true;
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class SVNWorkspaceRoot method setSharing.
/**
* Set the sharing for a project to enable it to be used with the SVNTeamProvider. This is used
* when a project has .svn directory but is not shared in Eclipse. An exception is thrown if
* project does not have a remote directory counterpart
*/
public static void setSharing(IProject project, IProgressMonitor monitor) throws TeamException {
// Ensure provided info matches that of the project
LocalResourceStatus status = peekResourceStatusFor(project);
// we will change this exception !
if (!status.hasRemote())
throw new SVNException(new SVNStatus(IStatus.ERROR, // $NON-NLS-1$
Policy.bind("SVNProvider.infoMismatch", project.getName())));
String repositoryURL = null;
ISVNClientAdapter client = SVNProviderPlugin.getPlugin().getSVNClient();
try {
SVNProviderPlugin.disableConsoleLogging();
ISVNInfo info = client.getInfoFromWorkingCopy(project.getLocation().toFile());
if (info.getRepository() != null)
repositoryURL = info.getRepository().toString();
} catch (SVNClientException e) {
} finally {
SVNProviderPlugin.enableConsoleLogging();
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
}
if (repositoryURL == null)
repositoryURL = status.getUrlString();
// Ensure that the provided location is managed
SVNProviderPlugin.getPlugin().getRepositories().getRepository(repositoryURL, false);
// Register the project with Team
RepositoryProvider.map(project, SVNProviderPlugin.getTypeId());
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class RevertResourceManager method revert.
/**
* Like revert on ISVNLocalFile but without updating the local history. Non recursive revert for
* folders
*
* @param resource
* @throws SVNException
*/
private void revert(ISVNLocalResource resource) throws SVNException {
ISVNClientAdapter svnClient = null;
try {
svnClient = resource.getRepository().getSVNClient();
OperationManager.getInstance().beginOperation(svnClient);
svnClient.revert(resource.getFile(), false);
} catch (SVNClientException e) {
throw SVNException.wrapException(e);
} finally {
resource.getRepository().returnSVNClient(svnClient);
OperationManager.getInstance().endOperation();
}
}
use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.
the class NonRecursiveStatusUpdateStrategy method statusesToUpdate.
/* (non-Javadoc)
* @see org.tigris.subversion.subclipse.core.status.StatusUpdateStrategy#statusesToUpdate(org.eclipse.core.resources.IResource)
*/
protected ISVNStatus[] statusesToUpdate(IResource resource) throws SVNException {
// we update the parent and its immediate children
IResource resourceToUpdate = resource;
if ((resource.getType() == IResource.FILE)) {
resourceToUpdate = resource.getParent();
}
if (Policy.DEBUG_STATUS) {
System.out.println(// $NON-NLS-1$
"[svn] getting status for : " + resourceToUpdate.getFullPath());
}
// don't do getRepository().getSVNClient() as we can ask the status of a file
// that is not associated with a known repository
// we don't need login & password so this is not a problem
ISVNStatus[] statuses = null;
ISVNClientAdapter svnClientAdapterStatus = null;
try {
svnClientAdapterStatus = SVNProviderPlugin.getPlugin().getSVNClient();
SVNProviderPlugin.disableConsoleLogging();
statuses = svnClientAdapterStatus.getStatus(resourceToUpdate.getLocation().toFile(), // do only immediate children.
false, // retrieve all entries
true);
} catch (SVNClientException e1) {
throw SVNException.wrapException(e1);
} finally {
SVNProviderPlugin.enableConsoleLogging();
SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClientAdapterStatus);
}
return collectUnversionedFolders(statuses, false);
}
Aggregations