Search in sources :

Example 16 with ISVNRemoteResource

use of org.tigris.subversion.subclipse.core.ISVNRemoteResource 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 17 with ISVNRemoteResource

use of org.tigris.subversion.subclipse.core.ISVNRemoteResource 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 18 with ISVNRemoteResource

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

the class SvnRevPropertiesView method getSvnRevProperties.

private ISVNProperty[] getSvnRevProperties() throws SVNException {
    if (resource != null && resource.isManaged()) {
        SVNRevision rev = resource.getRevision();
        ISVNRemoteResource remoteResource = resource.getRemoteResource(rev);
        return UnversionedCustomProperty.getSvnRevisionProperties(remoteResource.getUrl(), rev, null);
    }
    if (remoteResource != null) {
        SVNRevision rev = remoteResource.getRevision();
        return UnversionedCustomProperty.getSvnRevisionProperties(remoteResource.getUrl(), rev, null);
    }
    return null;
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision)

Example 19 with ISVNRemoteResource

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

the class SvnWizardUpdatePage method showLog.

protected void showLog() {
    ISVNRemoteResource remoteResource = null;
    try {
        remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]).getRepository().getRemoteFile(new SVNUrl(commonRoot));
    } catch (Exception e) {
        MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
        e.toString());
        return;
    }
    if (remoteResource == null) {
        MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        commonRoot);
        return;
    }
    HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
    if (dialog.open() == HistoryDialog.CANCEL)
        return;
    ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
    if (selectedEntries.length == 0)
        return;
    revisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
    setPageComplete(canFinish());
}
Also used : HistoryDialog(org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) ParseException(java.text.ParseException)

Example 20 with ISVNRemoteResource

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

the class ChooseUrlDialog method okPressed.

protected void okPressed() {
    saveLocation();
    ISelection selection = treeViewer.getSelection();
    if (!selection.isEmpty() && (selection instanceof IStructuredSelection)) {
        IStructuredSelection structured = (IStructuredSelection) selection;
        Object first = structured.getFirstElement();
        if (first instanceof ISVNRemoteResource) {
            url = ((ISVNRemoteResource) first).getUrl().toString();
            name = ((ISVNRemoteResource) first).getName();
        }
        if (first instanceof ISVNRepositoryLocation)
            url = ((ISVNRepositoryLocation) first).getUrl().toString();
        if (first instanceof Alias)
            url = AliasManager.transformUrl(resource, (Alias) first);
        ArrayList urlArray = new ArrayList();
        ArrayList nameArray = new ArrayList();
        Iterator iter = structured.iterator();
        while (iter.hasNext()) {
            Object selectedItem = iter.next();
            if (selectedItem instanceof ISVNRemoteResource) {
                urlArray.add(((ISVNRemoteResource) selectedItem).getUrl().toString());
                nameArray.add(((ISVNRemoteResource) selectedItem).getName());
            }
        }
        urls = new String[urlArray.size()];
        urlArray.toArray(urls);
        names = new String[nameArray.size()];
        nameArray.toArray(names);
    }
    super.okPressed();
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) Alias(org.tigris.subversion.subclipse.core.history.Alias) ISelection(org.eclipse.jface.viewers.ISelection) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Aggregations

ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)69 SVNException (org.tigris.subversion.subclipse.core.SVNException)23 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)21 InvocationTargetException (java.lang.reflect.InvocationTargetException)16 TeamException (org.eclipse.team.core.TeamException)16 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)16 IResource (org.eclipse.core.resources.IResource)15 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)14 ArrayList (java.util.ArrayList)12 ParseException (java.text.ParseException)11 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)10 CoreException (org.eclipse.core.runtime.CoreException)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)8 MalformedURLException (java.net.MalformedURLException)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)7 HistoryDialog (org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog)6 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)6