Search in sources :

Example 1 with SVNStatusSyncInfo

use of org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo in project subclipse by subclipse.

the class UpdateSynchronizeOperation method groupByRepository.

/**
 * This takes the items we are going to update and groups them by repository We need to do this in
 * case a project uses svn:externals to point to a different repository. If we do not do this,
 * then later when we find the highest revision number to update to, we can have a set of
 * resources that span multiple repositories (each with their own revision numbers)
 *
 * @param resourceArray - Complete list of resources we will update
 * @param set - The set of selected items in the synch view
 * @return Map - the resources grouped by ISVNRepositoryLocation
 */
private Map<ISVNRepositoryLocation, List<IResource>> groupByRepository(IResource[] resourceArray, SyncInfoSet set) {
    Map<ISVNRepositoryLocation, List<IResource>> resourceMap = new HashMap<ISVNRepositoryLocation, List<IResource>>();
    final SyncInfo[] syncInfos = set.getSyncInfos();
    for (int i = 0; i < syncInfos.length; i++) {
        SVNStatusSyncInfo syncInfo = (SVNStatusSyncInfo) syncInfos[i];
        IResource local = syncInfo.getLocal();
        resourceLoop: for (int j = 0; j < resourceArray.length; j++) {
            if (resourceArray[j].equals(local)) {
                IResourceVariant remote = syncInfo.getRemote();
                if (remote != null && remote instanceof ISVNRemoteResource) {
                    if (syncInfo.getRemoteResourceStatus() != null) {
                        ISVNRepositoryLocation repos = syncInfo.getRemoteResourceStatus().getRepository();
                        List<IResource> resList = (List<IResource>) resourceMap.get(repos);
                        if (resList == null)
                            resList = new ArrayList<IResource>(resourceArray.length);
                        resList.add(resourceArray[j]);
                        resourceMap.put(repos, resList);
                    }
                }
                break resourceLoop;
            }
        }
    }
    return resourceMap;
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) HashMap(java.util.HashMap) SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) ArrayList(java.util.ArrayList) List(java.util.List) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IResource(org.eclipse.core.resources.IResource) IResourceVariant(org.eclipse.team.core.variants.IResourceVariant)

Example 2 with SVNStatusSyncInfo

use of org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo in project subclipse by subclipse.

the class UpdateSynchronizeOperation method getRevisionForUpdate.

/**
 * This method returns the highest revision number in the set of items being updated or
 * SVNRevision.HEAD if there are deleted items
 *
 * @param resources - the resources being updated
 * @param set - the list of all selected items in synch view
 * @return
 */
private SVNRevision getRevisionForUpdate(IResource[] resources, SyncInfoSet set) {
    SVNRevision revision = null;
    final SyncInfo[] syncInfos = set.getSyncInfos();
    boolean useHEAD = false;
    syncInfoLoop: for (int i = 0; i < syncInfos.length; i++) {
        SVNStatusSyncInfo syncInfo = (SVNStatusSyncInfo) syncInfos[i];
        resourceLoop: for (int j = 0; j < resources.length; j++) {
            if (resources[j].equals(syncInfo.getLocal())) {
                IResourceVariant remote = syncInfo.getRemote();
                if (remote != null && remote instanceof ISVNRemoteResource) {
                    if (syncInfo.getRemoteResourceStatus() != null) {
                        if (syncInfo.getRemoteResourceStatus().getTextStatus() == SVNStatusKind.DELETED) {
                            // update contains deleted items
                            useHEAD = true;
                            break syncInfoLoop;
                        }
                    }
                    SVNRevision rev = ((ISVNRemoteResource) remote).getLastChangedRevision();
                    if (rev instanceof SVNRevision.Number) {
                        long nbr = ((SVNRevision.Number) rev).getNumber();
                        if (revision == null)
                            revision = rev;
                        else {
                            long revisionNumber = ((SVNRevision.Number) revision).getNumber();
                            if (nbr > revisionNumber)
                                revision = rev;
                        }
                    }
                }
                break resourceLoop;
            }
        }
    }
    if (revision == null || useHEAD)
        revision = SVNRevision.HEAD;
    return revision;
}
Also used : SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResourceVariant(org.eclipse.team.core.variants.IResourceVariant)

Example 3 with SVNStatusSyncInfo

use of org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo in project subclipse by subclipse.

the class OverrideAndUpdateSynchronizeOperation method getIncoming.

private IResource[] getIncoming(IResource[] resources) throws TeamException {
    List<IResource> incomingResources = new ArrayList<IResource>();
    for (int i = 0; i < resources.length; i++) {
        IResource resource = resources[i];
        SVNStatusSyncInfo info = (SVNStatusSyncInfo) SVNWorkspaceSubscriber.getInstance().getSyncInfo(resource);
        if (info != null) {
            if (SyncInfo.getDirection(info.getKind()) == SyncInfo.INCOMING || SyncInfo.getDirection(info.getKind()) == SyncInfo.CONFLICTING)
                incomingResources.add(resource);
        }
    }
    IResource[] incomingArray = new IResource[incomingResources.size()];
    incomingResources.toArray(incomingArray);
    return incomingArray;
}
Also used : SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) ArrayList(java.util.ArrayList) IResource(org.eclipse.core.resources.IResource)

Example 4 with SVNStatusSyncInfo

use of org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo in project subclipse by subclipse.

the class SVNChangeSetCollector method add.

/*
   * (non-Javadoc)
   * @see org.eclipse.team.internal.ui.synchronize.SyncInfoSetChangeSetCollector#add(org.eclipse.team.core.synchronize.SyncInfo[])
   */
protected void add(final SyncInfo[] infos) {
    final Map sets = new HashMap();
    Job job = new Job(Policy.bind("SynchronizeView.collectingChangeSets")) {

        protected IStatus run(IProgressMonitor monitor) {
            monitor.beginTask(null, infos.length);
            for (int i = 0; i < infos.length; i++) {
                SyncInfo syncInfo = infos[i];
                if (syncInfo instanceof SVNStatusSyncInfo) {
                    SVNStatusSyncInfo svnSyncInfo = (SVNStatusSyncInfo) syncInfo;
                    if (SyncInfo.getDirection(svnSyncInfo.getKind()) == SyncInfo.INCOMING && svnSyncInfo.getRemote() != null) {
                        SVNCheckedInChangeSet changeSet = (SVNCheckedInChangeSet) sets.get(svnSyncInfo.getRemote().getContentIdentifier());
                        if (changeSet == null) {
                            changeSet = new SVNCheckedInChangeSet(svnSyncInfo);
                            sets.put(svnSyncInfo.getRemote().getContentIdentifier(), changeSet);
                        } else {
                            changeSet.add(svnSyncInfo);
                        }
                    }
                }
                monitor.worked(1);
            }
            monitor.done();
            performUpdate(new IWorkspaceRunnable() {

                public void run(IProgressMonitor monitor) throws CoreException {
                    for (Iterator it = sets.values().iterator(); it.hasNext(); ) {
                        SVNCheckedInChangeSet set = (SVNCheckedInChangeSet) it.next();
                        SVNChangeSetCollector.this.add(set);
                    }
                }
            }, true, new NullProgressMonitor());
            return Status.OK_STATUS;
        }
    };
    job.schedule();
    try {
        job.join();
    } catch (InterruptedException ex) {
    // 
    }
}
Also used : IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) HashMap(java.util.HashMap) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) CoreException(org.eclipse.core.runtime.CoreException) SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) Iterator(java.util.Iterator) Job(org.eclipse.core.runtime.jobs.Job) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with SVNStatusSyncInfo

use of org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo in project subclipse by subclipse.

the class SubclipseLinkedTaskInfo method getText.

public String getText() {
    if (comment == null && changeSet != null) {
        try {
            SyncInfoTree syncInfoSet = changeSet.getSyncInfoSet();
            SVNStatusSyncInfo info = (SVNStatusSyncInfo) syncInfoSet.getSyncInfo(resource);
            ISVNRemoteResource remoteResource = (ISVNRemoteResource) info.getRemote();
            SVNRevision rev = remoteResource.getLastChangedRevision();
            ISVNLogMessage[] messages = remoteResource.getLogMessages(rev, rev, SVNRevision.START, false, false, 1, false);
            comment = messages[0].getMessage();
        } catch (TeamException ex) {
            comment = changeSet.getComment();
        }
    }
    return comment;
}
Also used : TeamException(org.eclipse.team.core.TeamException) SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) SyncInfoTree(org.eclipse.team.core.synchronize.SyncInfoTree) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ISVNLogMessage(org.tigris.subversion.svnclientadapter.ISVNLogMessage)

Aggregations

SVNStatusSyncInfo (org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo)5 SyncInfo (org.eclipse.team.core.synchronize.SyncInfo)3 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 IResource (org.eclipse.core.resources.IResource)2 IResourceVariant (org.eclipse.team.core.variants.IResourceVariant)2 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)2 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 TeamException (org.eclipse.team.core.TeamException)1 SyncInfoTree (org.eclipse.team.core.synchronize.SyncInfoTree)1 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)1 ISVNLogMessage (org.tigris.subversion.svnclientadapter.ISVNLogMessage)1