Search in sources :

Example 56 with ISVNClientAdapter

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;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TeamException(org.eclipse.team.core.TeamException) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) ISVNLocalFile(org.tigris.subversion.subclipse.core.ISVNLocalFile) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) CoreException(org.eclipse.core.runtime.CoreException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNLocalFile(org.tigris.subversion.subclipse.core.ISVNLocalFile) SVNException(org.tigris.subversion.subclipse.core.SVNException) RepositoryProvider(org.eclipse.team.core.RepositoryProvider) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 57 with ISVNClientAdapter

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;
}
Also used : ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) CoreException(org.eclipse.core.runtime.CoreException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SVNException(org.tigris.subversion.subclipse.core.SVNException) RepositoryProvider(org.eclipse.team.core.RepositoryProvider) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 58 with ISVNClientAdapter

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());
}
Also used : SVNStatus(org.tigris.subversion.subclipse.core.SVNStatus) ISVNStatus(org.tigris.subversion.svnclientadapter.ISVNStatus) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 59 with ISVNClientAdapter

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();
    }
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 60 with ISVNClientAdapter

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);
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNStatus(org.tigris.subversion.svnclientadapter.ISVNStatus) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)108 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)67 SVNException (org.tigris.subversion.subclipse.core.SVNException)37 File (java.io.File)28 IResource (org.eclipse.core.resources.IResource)27 CoreException (org.eclipse.core.runtime.CoreException)22 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)21 TeamException (org.eclipse.team.core.TeamException)21 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)20 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)20 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)19 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)19 ArrayList (java.util.ArrayList)18 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)13 OperationProgressNotifyListener (org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)9 IProject (org.eclipse.core.resources.IProject)8 List (java.util.List)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7