Search in sources :

Example 1 with ISVNLocalResource

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

the class SVNMoveDeleteHook method getDeferFileDelete.

// Get the DeferFileDelete Property for selected resource.
private boolean getDeferFileDelete(IResource resource) {
    ISVNProperty property = null;
    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
    ISVNLocalResource parent = svnResource;
    try {
        while (parent != null) {
            if (parent.isManaged()) {
                break;
            }
            parent = parent.getParent();
        }
        if (parent == null || !parent.isManaged()) {
            return false;
        }
        ISVNProperty[] deferFileDeleteProperties = parent.getPropertiesIncludingInherited(false, true, deferFileDeleteFilterList);
        if (deferFileDeleteProperties != null && deferFileDeleteProperties.length > 0) {
            return deferFileDeleteProperties[0].getValue().equalsIgnoreCase("true");
        }
    } catch (SVNException e) {
        return false;
    }
    return false;
}
Also used : ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource)

Example 2 with ISVNLocalResource

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

the class RevertResourceManager method processResources.

/**
 * Revert previously deleted resources that are added again. When a file is reverted, it's parent
 * directories are also reverted. When new files are added in folders that are scheduled for
 * deletion, the parent folder tree is reverted.
 *
 * @param resources
 */
private ISVNLocalResource[] processResources(IResourceDelta[] resources) throws CoreException {
    List<ISVNLocalResource> revertedResources = new ArrayList<ISVNLocalResource>();
    for (IResourceDelta resourceDelta : resources) {
        IResource resource = resourceDelta.getResource();
        if (resource.getType() == IResource.FILE) {
            ISVNLocalFile res = SVNWorkspaceRoot.getSVNFileFor((IFile) resource);
            if (res.getFile().exists()) {
                boolean deleted;
                if (resourceDelta.getKind() == IResourceDelta.ADDED)
                    deleted = res.getStatusFromCache().isDeleted();
                else {
                    deleted = SVNMoveDeleteHook.isDeleted((IFile) resource);
                    if (deleted)
                        SVNMoveDeleteHook.removeFromDeletedFileList((IFile) resource);
                }
                if (deleted) {
                    revertedResources.add(res);
                }
                ISVNLocalFolder parentFolder = res.getParent();
                while (parentFolder != null) {
                    if (parentFolder.getStatusFromCache().isDeleted() && !parentFolder.getResource().exists() && !revertedResources.contains(parentFolder)) {
                        revertedResources.add(parentFolder);
                    } else {
                        break;
                    }
                    if (parentFolder.getParent() == null) {
                        break;
                    }
                    parentFolder = parentFolder.getParent();
                }
            }
        }
    }
    return (ISVNLocalResource[]) revertedResources.toArray(new ISVNLocalResource[revertedResources.size()]);
}
Also used : ISVNLocalFolder(org.tigris.subversion.subclipse.core.ISVNLocalFolder) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) ISVNLocalFile(org.tigris.subversion.subclipse.core.ISVNLocalFile) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Example 3 with ISVNLocalResource

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

the class ViewGraphAction method execute.

public void execute(IAction action) throws InterruptedException, InvocationTargetException {
    if (action != null && !action.isEnabled()) {
        action.setEnabled(true);
    } else {
        run(new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) {
                IResource[] resources = getSelectedResources();
                try {
                    if (resources.length > 0) {
                        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]);
                        ISVNRemoteResource remoteResource = svnResource.getBaseResource();
                        if (remoteResource != null) {
                            String repoPath = remoteResource.getRepositoryRelativePath();
                            if (repoPath == null || repoPath.length() == 0) {
                                MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("ViewGraphAction.0"), // $NON-NLS-1$ //$NON-NLS-2$
                                Policy.bind("ViewGraphAction.1"));
                                return;
                            }
                        }
                        // IEditorPart part =
                        getTargetPage().openEditor(new RevisionGraphEditorInput(resources[0]), // $NON-NLS-1$
                        "org.tigris.subversion.subclipse.graph.editors.revisionGraphEditor");
                    }
                } catch (Exception e) {
                    Activator.handleError(e);
                    Activator.showErrorDialog(getErrorTitle(), e);
                }
            }
        }, false, /* cancelable */
        PROGRESS_BUSYCURSOR);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RevisionGraphEditorInput(org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 4 with ISVNLocalResource

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

the class CheckinResourcesCommand 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 {
    commitError = false;
    postCommitError = null;
    final ISVNClientAdapter svnClient = root.getRepository().getSVNClient();
    OperationManager.getInstance().beginOperation(svnClient, new OperationProgressNotifyListener(monitor, svnClient));
    try {
        // Prepare the parents list
        // we will Auto-commit parents if they are not already commited
        List<IContainer> parentsList = new ArrayList<IContainer>();
        List<IProject> projectList = new ArrayList<IProject>();
        for (IResource currentResource : resources) {
            IProject project = currentResource.getProject();
            if (!projectList.contains(project)) {
                projectList.add(project);
            }
            IContainer parent = currentResource.getParent();
            ISVNLocalResource svnParentResource = SVNWorkspaceRoot.getSVNResourceFor(parent);
            while (parent.getType() != IResource.ROOT && parent.getType() != IResource.PROJECT && !svnParentResource.hasRemote()) {
                if (!inCommitList(parent))
                    parentsList.add(parent);
                parent = parent.getParent();
                svnParentResource = svnParentResource.getParent();
            }
        }
        // convert parents and resources to an array of File
        int parents = parentsList.size();
        // change commit to non-recursive!!
        if (parents > 0)
            depth = IResource.DEPTH_ZERO;
        final File[] resourceFiles = new File[parents + resources.length];
        for (int i = 0; i < parents; i++) {
            resourceFiles[i] = ((IResource) parentsList.get(i)).getLocation().toFile();
        }
        for (int i = 0, j = parents; i < resources.length; i++, j++) {
            resourceFiles[j] = resources[i].getLocation().toFile();
        }
        IProject[] projects = new IProject[projectList.size()];
        projectList.toArray(projects);
        ISchedulingRule rule = MultiRule.combine(projects);
        SVNProviderPlugin.run(new ISVNRunnable() {

            public void run(final IProgressMonitor pm) throws SVNException {
                try {
                    notifyListener = new ISVNNotifyListener() {

                        public void logCommandLine(String commandLine) {
                        }

                        public void logCompleted(String message) {
                        }

                        public void logError(String message) {
                        }

                        public void logMessage(String message) {
                            if (message.startsWith("Transmitting file data"))
                                pm.subTask(message);
                        }

                        public void logRevision(long revision, String path) {
                        }

                        public void onNotify(File path, SVNNodeKind kind) {
                        }

                        public void setCommand(int command) {
                        }
                    };
                    pm.beginTask(null, resourceFiles.length);
                    pm.setTaskName("Checking in...");
                    svnClient.addNotifyListener(operationResourceCollector);
                    svnClient.addNotifyListener(notifyListener);
                    // then the resources the user has requested to commit
                    if (svnClient.canCommitAcrossWC())
                        svnClient.commitAcrossWC(resourceFiles, message, depth == IResource.DEPTH_INFINITE, keepLocks, true);
                    else
                        svnClient.commit(resourceFiles, message, depth == IResource.DEPTH_INFINITE, keepLocks);
                    postCommitError = svnClient.getPostCommitError();
                } catch (SVNClientException e) {
                    commitError = true;
                    throw SVNException.wrapException(e);
                } finally {
                    pm.done();
                    if (svnClient != null) {
                        svnClient.removeNotifyListener(operationResourceCollector);
                        svnClient.removeNotifyListener(notifyListener);
                        root.getRepository().returnSVNClient(svnClient);
                    }
                }
            }
        }, rule, Policy.monitorFor(monitor));
    } finally {
        OperationManager.getInstance().endOperation(true, operationResourceCollector.getOperationResources(), !commitError);
    }
}
Also used : ISVNRunnable(org.tigris.subversion.subclipse.core.ISVNRunnable) ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IProject(org.eclipse.core.resources.IProject) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNNodeKind(org.tigris.subversion.svnclientadapter.SVNNodeKind) ISVNNotifyListener(org.tigris.subversion.svnclientadapter.ISVNNotifyListener) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) IContainer(org.eclipse.core.resources.IContainer) File(java.io.File) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter) OperationProgressNotifyListener(org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)

Example 5 with ISVNLocalResource

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

the class GetLogsCommand method run.

/**
 * execute the command
 *
 * @param aMonitor
 * @throws SVNException
 */
public void run(IProgressMonitor aMonitor) throws SVNException {
    ISVNRepositoryLocation repository = null;
    ISVNClientAdapter svnClient = null;
    logEntries = null;
    IProgressMonitor monitor = Policy.monitorFor(aMonitor);
    // $NON-NLS-1$
    monitor.beginTask(Policy.bind("RemoteFile.getLogEntries"), 100);
    ISVNLogMessage[] logMessages;
    try {
        if (callback == null) {
            logMessages = remoteResource.getLogMessages(pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions);
        } else {
            repository = remoteResource.getRepository();
            svnClient = repository.getSVNClient();
            if (remoteResource instanceof BaseResource) {
                boolean logMessagesRetrieved = false;
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(remoteResource.getResource());
                if (svnResource != null) {
                    LocalResourceStatus status = svnResource.getStatus();
                    if (status != null && status.isCopied()) {
                        ISVNInfo info = svnClient.getInfoFromWorkingCopy(svnResource.getFile());
                        SVNUrl copiedFromUrl = info.getCopyUrl();
                        if (copiedFromUrl != null) {
                            svnClient.getLogMessages(copiedFromUrl, SVNRevision.HEAD, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
                            logMessagesRetrieved = true;
                            GetRemoteResourceCommand getRemoteResourceCommand = new GetRemoteResourceCommand(remoteResource.getRepository(), copiedFromUrl, SVNRevision.HEAD);
                            getRemoteResourceCommand.run(null);
                            remoteResource = getRemoteResourceCommand.getRemoteResource();
                        }
                    }
                }
                if (!logMessagesRetrieved)
                    svnClient.getLogMessages(((BaseResource) remoteResource).getFile(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
            } else {
                svnClient.getLogMessages(remoteResource.getUrl(), pegRevision, revisionStart, revisionEnd, stopOnCopy, !SVNProviderPlugin.getPlugin().getSVNClientManager().isFetchChangePathOnDemand(), limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
            }
            logMessages = callback.getLogMessages();
        }
        if (remoteResource.isFolder()) {
            logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFolder) remoteResource, logMessages, getTags(logMessages));
        } else {
            logEntries = LogEntry.createLogEntriesFrom((ISVNRemoteFile) remoteResource, logMessages, getTags(logMessages), getUrls(logMessages));
        }
    } catch (Exception e) {
        throw SVNException.wrapException(e);
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
        monitor.done();
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) BaseResource(org.tigris.subversion.subclipse.core.resources.BaseResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ISVNRemoteFolder(org.tigris.subversion.subclipse.core.ISVNRemoteFolder) ISVNLogMessage(org.tigris.subversion.svnclientadapter.ISVNLogMessage) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)120 IResource (org.eclipse.core.resources.IResource)77 SVNException (org.tigris.subversion.subclipse.core.SVNException)76 ArrayList (java.util.ArrayList)39 CoreException (org.eclipse.core.runtime.CoreException)24 Iterator (java.util.Iterator)20 IFile (org.eclipse.core.resources.IFile)20 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 List (java.util.List)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)17 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)17 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)17 File (java.io.File)16 TeamException (org.eclipse.team.core.TeamException)16 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)15 ISynchronizeModelElement (org.eclipse.team.ui.synchronize.ISynchronizeModelElement)14 IContainer (org.eclipse.core.resources.IContainer)13 SyncInfo (org.eclipse.team.core.synchronize.SyncInfo)11