Search in sources :

Example 31 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.

the class UndoMergeCommand method run.

public void run(IProgressMonitor monitor) throws SVNException {
    ISVNClientAdapter svnClient = null;
    ISVNRepositoryLocation repository = null;
    try {
        final OperationManager operationManager = OperationManager.getInstance();
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        repository = svnResource.getRepository();
        svnClient = repository.getSVNClient();
        svnClient.addNotifyListener(operationResourceCollector);
        operationManager.beginOperation(svnClient);
        LocalResourceStatus status = SVNWorkspaceRoot.getSVNResourceFor(resource).getStatus();
        if (!status.isManaged()) {
            try {
                resource.delete(true, monitor);
            } catch (CoreException ex) {
                throw SVNException.wrapException(ex);
            }
        } else {
            File path = resource.getLocation().toFile();
            svnClient.revert(path, true);
            if (resource.getType() != IResource.FILE)
                operationManager.onNotify(path, SVNNodeKind.UNKNOWN);
            monitor.worked(100);
        }
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
        OperationManager.getInstance().endOperation(true, operationResourceCollector.getOperationResources());
        monitor.done();
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) CoreException(org.eclipse.core.runtime.CoreException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) OperationManager(org.tigris.subversion.subclipse.core.client.OperationManager) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 32 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.

the class MergeAction method isEnabledForMultipleResources.

/*
   * (non-Javadoc)
   * @see org.tigris.subversion.subclipse.ui.actions.WorkspaceAction#isEnabledForMultipleResources()
   */
protected boolean isEnabledForMultipleResources() {
    try {
        // Must all be from same repository.
        ISVNRepositoryLocation repository = null;
        IResource[] selectedResources = getSelectedResources();
        for (int i = 0; i < selectedResources.length; i++) {
            ISVNRepositoryLocation compareToRepository = null;
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(selectedResources[i]);
            if (svnResource == null || !svnResource.isManaged()) {
                return false;
            }
            LocalResourceStatus status = svnResource.getStatusFromCache();
            if (status != null) {
                compareToRepository = status.getRepository();
            }
            if (compareToRepository == null) {
                return false;
            }
            if (repository != null && !compareToRepository.equals(repository)) {
                return false;
            }
            repository = compareToRepository;
        }
        return true;
    } catch (Exception e) {
        return false;
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) IResource(org.eclipse.core.resources.IResource) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 33 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.

the class RemoteAnnotationStorage method getFullPath.

/*
   * (non-Javadoc)
   * @see org.eclipse.core.resources.IStorage#getFullPath()
   */
public IPath getFullPath() {
    ISVNRepositoryLocation location = file.getRepository();
    SVNUrl repositoryUrl = location.getRepositoryRoot();
    String[] segments = repositoryUrl.getPathSegments();
    IPath path = new Path(null, "/");
    for (int i = 0; i < segments.length; i++) {
        path = path.append(segments[i]);
    }
    path = path.setDevice(repositoryUrl.getHost() + IPath.DEVICE_SEPARATOR);
    path = path.append(file.getRepositoryRelativePath());
    return path;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) IPath(org.eclipse.core.runtime.IPath) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl)

Example 34 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.

the class RemoteResourceTransfer method fromByteArray.

public Object fromByteArray(byte[] buffer) {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(buffer);
        DataInputStream readIn = new DataInputStream(in);
        boolean isFolder = readIn.readBoolean();
        // first, we read the url of the remote resource
        SVNUrl urlResource = new SVNUrl(readIn.readUTF());
        // then we read the url of the repository
        String location = readIn.readUTF();
        // we read the revision
        SVNRevision revision = SVNRevision.getRevision(readIn.readUTF());
        // we read the last changed revision
        SVNRevision.Number lastChangedRevision = (Number) SVNRevision.getRevision(readIn.readUTF());
        Date date = new Date(readIn.readLong());
        String author = null;
        try {
            author = readIn.readUTF();
        } catch (Exception e) {
        // Ignore null author
        }
        ISVNRepositoryLocation repositoryLocation = SVNProviderPlugin.getPlugin().getRepository(location);
        if (isFolder) {
            return new RemoteFolder(null, repositoryLocation, urlResource, revision, lastChangedRevision, date, author);
        }
        return new RemoteFile(null, repositoryLocation, urlResource, revision, lastChangedRevision, date, author);
    } catch (Exception ex) {
        return null;
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) DataInputStream(java.io.DataInputStream) Date(java.util.Date) IOException(java.io.IOException) Number(org.tigris.subversion.svnclientadapter.SVNRevision.Number) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) Number(org.tigris.subversion.svnclientadapter.SVNRevision.Number) ByteArrayInputStream(java.io.ByteArrayInputStream) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Example 35 with ISVNRepositoryLocation

use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.

the class RepositoryBranchTagAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    ISVNRemoteResource[] resources = getSelectedRemoteResources();
    BranchTagWizard wizard = new BranchTagWizard(resources);
    WizardDialog dialog = // $NON-NLS-1$
    new SizePersistedWizardDialog(getShell(), wizard, "BranchTag");
    if (dialog.open() == WizardDialog.OK) {
        SVNUrl[] sourceUrls = wizard.getUrls();
        SVNUrl destinationUrl = wizard.getToUrl();
        String message = wizard.getComment();
        SVNRevision revision = wizard.getRevision();
        boolean makeParents = wizard.isMakeParents();
        ISVNClientAdapter client = null;
        try {
            ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(sourceUrls[0].toString());
            if (repository != null)
                client = repository.getSVNClient();
            if (client == null)
                client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
            RepositoryBranchTagOperation branchTagOperation = new RepositoryBranchTagOperation(getTargetPart(), client, sourceUrls, destinationUrl, revision, message, makeParents);
            branchTagOperation.setMultipleTransactions(wizard.isSameStructure());
            branchTagOperation.run();
        } catch (Exception e) {
            MessageDialog.openError(getShell(), Policy.bind("BranchTagDialog.title"), e.getMessage());
        } finally {
        // BranchTagCommand will dispose.
        // SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
        }
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RepositoryBranchTagOperation(org.tigris.subversion.subclipse.ui.operations.RepositoryBranchTagOperation) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) BranchTagWizard(org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)69 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IResource (org.eclipse.core.resources.IResource)15 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)15 TeamException (org.eclipse.team.core.TeamException)14 ArrayList (java.util.ArrayList)13 SVNException (org.tigris.subversion.subclipse.core.SVNException)13 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 File (java.io.File)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)8 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)8 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)8 Iterator (java.util.Iterator)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 List (java.util.List)6