Search in sources :

Example 1 with SVNTeamProvider

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

the class SVNWorkspaceRoot method getRepositoryFor.

/**
 * Gets the repository which the local filesystem <code>location</code> belongs to.
 */
public static ISVNRepositoryLocation getRepositoryFor(IPath location) {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject[] projects = root.getProjects();
    for (IProject project : projects) {
        if (SVNWorkspaceRoot.isManagedBySubclipse(project) && project.getLocation().isPrefixOf(location)) {
            try {
                SVNTeamProvider teamProvider = (SVNTeamProvider) RepositoryProvider.getProvider(project, SVNProviderPlugin.getTypeId());
                return teamProvider.getSVNWorkspaceRoot().getRepository();
            } catch (SVNException e) {
                // an exception is thrown when resource	is not managed
                SVNProviderPlugin.log(e);
                return null;
            }
        }
    }
    return null;
}
Also used : SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) SVNException(org.tigris.subversion.subclipse.core.SVNException) IProject(org.eclipse.core.resources.IProject)

Example 2 with SVNTeamProvider

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

the class SVNWorkspaceSubscriber method refresh.

/* (non-Javadoc)
   * @see org.eclipse.team.core.subscribers.Subscriber#refresh(org.eclipse.core.resources.IResource[], int, org.eclipse.core.runtime.IProgressMonitor)
   */
public void refresh(IResource[] resources, int depth, IProgressMonitor monitor) throws TeamException {
    monitor = Policy.monitorFor(monitor);
    List<IStatus> errors = new ArrayList<IStatus>();
    try {
        monitor.beginTask("", 1000 * resources.length);
        for (IResource resource : resources) {
            // Make certain that resource is still connected with SVN.  When
            // Synch is on a schedule it is possible for the project to become disconnected
            SVNTeamProvider teamProvider = (SVNTeamProvider) RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
            if (teamProvider != null) {
                monitor.subTask(resource.getName());
                IStatus status = refresh(resource, depth, monitor);
                if (!status.isOK()) {
                    errors.add(status);
                }
            }
        }
    } finally {
        monitor.done();
    }
    if (!errors.isEmpty()) {
        int numSuccess = resources.length - errors.size();
        throw new TeamException(new MultiStatus(SVNProviderPlugin.ID, 0, (IStatus[]) errors.toArray(new IStatus[errors.size()]), Policy.bind("SVNWorkspaceSubscriber.errorWhileSynchronizing.1", new Object[] { getName(), Integer.toString(numSuccess), Integer.toString(resources.length) }), // $NON-NLS-1$
        null));
    }
}
Also used : TeamException(org.eclipse.team.core.TeamException) IStatus(org.eclipse.core.runtime.IStatus) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) ArrayList(java.util.ArrayList) MultiStatus(org.eclipse.core.runtime.MultiStatus) IResource(org.eclipse.core.resources.IResource)

Example 3 with SVNTeamProvider

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

the class SVNPropertyPage method getStatus.

private void getStatus() {
    ISVNRepositoryLocation repository = null;
    ISVNClientAdapter svnClient = null;
    try {
        IResource resource = (IResource) getElement();
        SVNTeamProvider svnProvider = (SVNTeamProvider) RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
        if (svnProvider == null)
            return;
        svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        if (svnResource == null)
            return;
        status = svnResource.getStatus();
        if (status != null && !status.isIgnored()) {
            repository = svnResource.getRepository();
            svnClient = repository.getSVNClient();
            ISVNInfo info = svnClient.getInfoFromWorkingCopy(svnResource.getFile());
            urlCopiedFrom = info.getCopyUrl();
            revision = svnResource.getRevision();
            lockOwnerText = status.getLockOwner();
            lockCommentText = status.getLockComment();
            if (status.getLockCreationDate() != null)
                lockDateText = status.getLockCreationDate().toString();
            if (!status.isAdded()) {
                try {
                    info = svnClient.getInfo(status.getUrl());
                } catch (Exception e) {
                }
            }
            // Get lock information from server if svn:needs-lock property is set
            if (info != null && status.getLockOwner() == null && status.getUrlString() != null) {
                ISVNProperty prop = svnResource.getSvnProperty("svn:needs-lock");
                if (prop != null) {
                    lockOwnerText = info.getLockOwner();
                    if (info.getLockCreationDate() != null)
                        lockDateText = info.getLockCreationDate().toString();
                    lockCommentText = info.getLockComment();
                }
            }
        }
    } catch (Exception e) {
        SVNUIPlugin.log(new Status(IStatus.ERROR, SVNUIPlugin.ID, TeamException.UNABLE, "Property Exception", // $NON-NLS-1$
        e));
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) Status(org.eclipse.core.runtime.Status) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) IResource(org.eclipse.core.resources.IResource) TeamException(org.eclipse.team.core.TeamException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 4 with SVNTeamProvider

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

the class GenerateDiffFileSynchronizeOperation method run.

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    SyncInfoSet syncSet = getSyncInfoSet();
    final Map projectSyncInfos = getProjectSyncInfoSetMap(syncSet);
    Iterator iter = projectSyncInfos.keySet().iterator();
    final IProject project = (IProject) iter.next();
    SVNTeamProvider provider = (SVNTeamProvider) RepositoryProvider.getProvider(project, SVNUIPlugin.PROVIDER_ID);
    monitor.beginTask(null, projectSyncInfos.size() * 100);
    run(provider, syncSet, Policy.subMonitorFor(monitor, 100));
    monitor.done();
}
Also used : SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) Iterator(java.util.Iterator) SyncInfoSet(org.eclipse.team.core.synchronize.SyncInfoSet) HashMap(java.util.HashMap) Map(java.util.Map) IProject(org.eclipse.core.resources.IProject)

Example 5 with SVNTeamProvider

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

the class RepositoryProviderOperation method execute.

/* (non-Javadoc)
   * @see org.eclipse.team.internal.cSVN.ui.operations.SVNOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
   */
public void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
    Map table = getProviderMapping(getResources());
    Set keySet = table.keySet();
    monitor.beginTask(null, keySet.size() * 1000);
    Iterator iterator = keySet.iterator();
    while (iterator.hasNext()) {
        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
        SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
        List list = (List) table.get(provider);
        IResource[] providerResources = (IResource[]) list.toArray(new IResource[list.size()]);
        ISchedulingRule rule = getSchedulingRule(provider);
        try {
            Job.getJobManager().beginRule(rule, monitor);
            monitor.setTaskName(getTaskName(provider));
            execute(provider, providerResources, subMonitor);
        } finally {
            Job.getJobManager().endRule(rule);
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IResource(org.eclipse.core.resources.IResource) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Aggregations

SVNTeamProvider (org.tigris.subversion.subclipse.core.SVNTeamProvider)24 IResource (org.eclipse.core.resources.IResource)14 Iterator (java.util.Iterator)12 ArrayList (java.util.ArrayList)11 List (java.util.List)9 TeamException (org.eclipse.team.core.TeamException)9 HashMap (java.util.HashMap)8 Set (java.util.Set)8 IProject (org.eclipse.core.resources.IProject)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 SVNException (org.tigris.subversion.subclipse.core.SVNException)8 Map (java.util.Map)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 Hashtable (java.util.Hashtable)5 CoreException (org.eclipse.core.runtime.CoreException)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 RepositoryProvider (org.eclipse.team.core.RepositoryProvider)5 SyncInfoSet (org.eclipse.team.core.synchronize.SyncInfoSet)5 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)5 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)5