Search in sources :

Example 71 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class Cache method refresh.

public void refresh(List refreshedNodes, ISVNInfo info, IProgressMonitor monitor, int unitWorked) {
    ISVNLogMessageCallback callback = new ISVNLogMessageCallback() {

        public void singleMessage(ISVNLogMessage message) {
            update(message, true);
        }
    };
    revisionsTempFile = new File(root, "revisionsTemp");
    logMessagesTempFile = new File(root, "logMessagesTemp");
    revisionsTempFile.delete();
    logMessagesTempFile.delete();
    try {
        revisionsTempFile.createNewFile();
        logMessagesTempFile.createNewFile();
    } catch (IOException e) {
        Activator.handleError(e);
    }
    List revisions = new ArrayList();
    Iterator iter = refreshedNodes.iterator();
    while (iter.hasNext()) {
        Node node = (Node) iter.next();
        revisions.add(Long.toString(node.getRevision()));
    }
    startTempUpdate();
    RandomAccessFile file = null;
    ISVNClientAdapter client = null;
    try {
        client = SVNProviderPlugin.getPlugin().getSVNClient();
        file = new RandomAccessFile(logMessagesFile, "r");
        int revInt = new Long(getLatestRevision()).intValue();
        while (file.getFilePointer() < file.length()) {
            ISVNLogMessage lm = readNext(file, true);
            level = 0;
            int index = revisions.indexOf(lm.getRevision().toString());
            if (index == -1) {
                update(lm, true);
                if (lm.hasChildren() && lm.getChildMessages() != null) {
                    updateChildren(lm, true);
                }
                monitor.worked(unitWorked / revInt);
            } else {
                Node updateNode = (Node) refreshedNodes.get(index);
                SVNRevision updateRevision = new SVNRevision.Number(updateNode.getRevision());
                client.getLogMessages(new SVNUrl(info.getRepository() + updateNode.getPath()), updateRevision, updateRevision, updateRevision, false, true, 0, true, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
                monitor.worked(unitWorked);
            // updateRevision = (ISVNLogMessage)refreshedMessages.get(index);
            // monitor.worked(unitWorked);
            }
            if (monitor.isCanceled()) {
                break;
            }
        }
    } catch (Exception e) {
    } finally {
        closeFile(file);
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
    }
    finishTempUpdate();
    if (monitor.isCanceled()) {
        revisionsTempFile.delete();
        logMessagesTempFile.delete();
        return;
    }
    revisionsFile.delete();
    logMessagesFile.delete();
    revisionsTempFile.renameTo(revisionsFile);
    logMessagesTempFile.renameTo(logMessagesFile);
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ISVNLogMessage(org.tigris.subversion.svnclientadapter.ISVNLogMessage) IOException(java.io.IOException) ISVNLogMessageCallback(org.tigris.subversion.svnclientadapter.ISVNLogMessageCallback) RandomAccessFile(java.io.RandomAccessFile) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 72 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class DeleteCacheAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    final ISVNRemoteFolder[] selectedFolders = getSelectedRemoteFolders();
    error = null;
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            ISVNClientAdapter client = null;
            try {
                client = SVNProviderPlugin.getPlugin().getSVNClient();
                info = client.getInfo(selectedFolders[0].getUrl());
            } catch (Exception e) {
                error = e;
            } finally {
                SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
            }
        }
    });
    if (error != null) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("DeleteCacheAction.title"), // $NON-NLS-1$
        error.getMessage());
        return;
    }
    String uuid = info.getUuid();
    File f = Cache.getCacheDirectory(null);
    f = new File(f, uuid);
    if (!f.exists()) {
        MessageDialog.openInformation(Display.getDefault().getActiveShell(), Policy.bind("DeleteCacheAction.title"), // $NON-NLS-1$ //$NON-NLS-2$
        Policy.bind("DeleteCacheAction.noCache"));
        return;
    }
    String[] url = { selectedFolders[0].getUrl().toString() };
    if (!MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Policy.bind("DeleteCacheAction.title"), Policy.bind("DeleteCacheAction.confirm", url)))
        // $NON-NLS-1$ //$NON-NLS-2$
        return;
    // $NON-NLS-1$
    File revisionsFile = new File(f, "revisions");
    if (!deleteFile(revisionsFile, true))
        return;
    // $NON-NLS-1$
    File logMessagesFile = new File(f, "logMessages");
    if (!deleteFile(logMessagesFile, true))
        return;
    // Just in case of a failed refresh
    // $NON-NLS-1$
    File revisionsTempFile = new File(f, "revisionsTemp");
    deleteFile(revisionsTempFile, false);
    // $NON-NLS-1$
    File logMessagesTempFile = new File(f, "logMessagesTemp");
    deleteFile(logMessagesTempFile, false);
    deleteFile(f, true);
}
Also used : ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 73 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class ResolveTreeConflictWizard method getLocalCopiedTo.

public ISVNStatus getLocalCopiedTo(boolean getAll) throws SVNException, SVNClientException {
    String endsWithCheck = treeConflict.getConflictDescriptor().getSrcRightVersion().getPathInRepos();
    IProject project = svnResource.getResource().getProject();
    if (project != null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        int index = endsWithCheck.indexOf("/" + project.getName() + "/");
        if (index != -1)
            endsWithCheck = endsWithCheck.substring(index);
    }
    if (copiedTo == null && !copiedToRetrieved) {
        statuses = getStatuses(getAll);
        ISVNClientAdapter svnClient = svnResource.getRepository().getSVNClient();
        for (int i = 0; i < statuses.length; i++) {
            if (statuses[i].isCopied() && statuses[i].getTextStatus().equals(SVNStatusKind.ADDED)) {
                ISVNInfo info = svnClient.getInfoFromWorkingCopy(statuses[i].getFile());
                if (info.getCopyUrl() != null) {
                    if ((svnResource.getUrl() != null && info.getCopyUrl().toString().equals(svnResource.getUrl().toString())) || (info.getCopyUrl().toString().endsWith(endsWithCheck))) {
                        copiedTo = statuses[i];
                        break;
                    }
                }
            }
        }
        svnResource.getRepository().returnSVNClient(svnClient);
    }
    copiedToRetrieved = true;
    return copiedTo;
}
Also used : ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) IProject(org.eclipse.core.resources.IProject) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 74 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class PropertyCompareLocalResourceNode method getProperties.

public void getProperties(boolean recursive) {
    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
    ISVNClientAdapter svnClient = null;
    try {
        svnClient = svnResource.getRepository().getSVNClient();
        properties = svnClient.getProperties(resource.getLocation().toFile(), recursive);
    } catch (Exception e) {
        SVNUIPlugin.log(Status.ERROR, e.getMessage(), e);
    } finally {
        svnResource.getRepository().returnSVNClient(svnClient);
    }
}
Also used : ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) CoreException(org.eclipse.core.runtime.CoreException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 75 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter in project subclipse by subclipse.

the class SVNFolderCompareEditorInput method prepareInput.

protected Object prepareInput(IProgressMonitor monitor) throws InterruptedException {
    final boolean threeWay = ancestor != null;
    if (right == null || left == null) {
        // $NON-NLS-1$
        setMessage(Policy.bind("SVNCompareEditorInput.different"));
        return null;
    }
    initLabels();
    final Object[] result = new Object[] { null };
    ISVNClientAdapter svnClient = null;
    try {
        // do the diff
        // $NON-NLS-1$
        monitor.beginTask(Policy.bind("SVNCompareEditorInput.comparing"), 30);
        IProgressMonitor sub = new SubProgressMonitor(monitor, 30);
        // $NON-NLS-1$
        sub.beginTask(Policy.bind("SVNCompareEditorInput.comparing"), 100);
        try {
            svnClient = folder1.getRepository().getSVNClient();
            SVNDiffSummary[] diffSummary = null;
            if (folder1.getRepositoryRelativePath().equals(folder2.getRepositoryRelativePath()) && localResource1 != null) {
                IResource resource1 = localResource1.getResource();
                if (resource1 != null) {
                    ISVNLocalResource svnResource1 = SVNWorkspaceRoot.getSVNResourceFor(resource1);
                    if (svnResource1 != null) {
                        SVNRevision pegRevision = svnResource1.getRevision();
                        if (pegRevision != null) {
                            diffSummary = svnClient.diffSummarize(folder1.getUrl(), pegRevision, folder2.getRevision(), folder1.getRevision(), Depth.infinity, true);
                        }
                    }
                } else {
                    diffSummary = svnClient.diffSummarize(folder1.getUrl(), SVNRevision.HEAD, folder2.getRevision(), folder1.getRevision(), Depth.infinity, true);
                }
            }
            if (diffSummary == null)
                diffSummary = svnClient.diffSummarize(folder1.getUrl(), folder1.getRevision(), folder2.getUrl(), folder2.getRevision(), Depth.infinity, true);
            diffSummary = getDiffSummaryWithSubfolders(diffSummary);
            left.setDiffSummary(diffSummary);
            right.setDiffSummary(diffSummary);
            left.setRoot(true);
            right.setRoot(true);
            result[0] = new SummaryDifferencer().findDifferences(threeWay, sub, null, ancestor, left, right);
        } finally {
            sub.done();
        }
        if (result[0] instanceof DiffNode) {
            IDiffElement[] diffs = ((DiffNode) result[0]).getChildren();
            if (diffs == null || diffs.length == 0) {
                result[0] = null;
            }
        }
        return result[0];
    } catch (OperationCanceledException e) {
        throw new InterruptedException(e.getMessage());
    } catch (Exception e) {
        return e.getMessage();
    } finally {
        folder1.getRepository().returnSVNClient(svnClient);
        monitor.done();
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) DiffNode(org.eclipse.compare.structuremergeviewer.DiffNode) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IDiffElement(org.eclipse.compare.structuremergeviewer.IDiffElement) SVNDiffSummary(org.tigris.subversion.svnclientadapter.SVNDiffSummary) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) 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