Search in sources :

Example 31 with SVNUrl

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

the class MergeDialog method dryRun.

private void dryRun() {
    try {
        svnClient = svnResource.getRepository().getSVNClient();
        file = resource.getLocation().toFile();
        fromUrl = new SVNUrl(fromUrlCombo.getText());
        toUrl = new SVNUrl(toUrlCombo.getText());
        if (fromHeadButton.getSelection())
            fromRevision = SVNRevision.HEAD;
        else
            fromRevision = SVNRevision.getRevision(fromRevisionText.getText().trim());
        if (toHeadButton.getSelection())
            toRevision = SVNRevision.HEAD;
        else
            toRevision = SVNRevision.getRevision(toRevisionText.getText().trim());
        BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

            public void run() {
                try {
                    svnClient.merge(fromUrl, fromRevision, toUrl, toRevision, file, forceButton.getSelection(), true, true, ignoreAncestryButton.getSelection());
                } catch (SVNClientException e) {
                    MessageDialog.openError(getShell(), Policy.bind("MergeDialog.dryRun"), // $NON-NLS-1$
                    e.toString());
                }
            }
        });
    } catch (Exception e) {
        MessageDialog.openError(getShell(), Policy.bind("MergeDialog.dryRun"), // $NON-NLS-1$
        e.toString());
    } finally {
        svnResource.getRepository().returnSVNClient(svnClient);
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SVNException(org.tigris.subversion.subclipse.core.SVNException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ParseException(java.text.ParseException) MalformedURLException(java.net.MalformedURLException)

Example 32 with SVNUrl

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

the class MergeDialog method okPressed.

protected void okPressed() {
    force = forceButton.getSelection();
    ignoreAncestry = ignoreAncestryButton.getSelection();
    fromUrlCombo.saveUrl();
    if (!toUrlCombo.getText().equals(fromUrlCombo.getText()))
        toUrlCombo.saveUrl();
    try {
        fromUrl = new SVNUrl(fromUrlCombo.getText());
        if (fromHeadButton.getSelection())
            fromRevision = SVNRevision.HEAD;
        else {
            try {
                fromRevision = SVNRevision.getRevision(fromRevisionText.getText().trim());
            } catch (ParseException e1) {
                MessageDialog.openError(getShell(), Policy.bind("MergeDialog.title"), // $NON-NLS-1$ //$NON-NLS-2$
                Policy.bind("MergeDialog.invalidFrom"));
                return;
            }
        }
        if (useFromUrlButton.getSelection())
            toUrl = new SVNUrl(fromUrlCombo.getText());
        toUrl = new SVNUrl(toUrlCombo.getText());
        if (toHeadButton.getSelection())
            toRevision = SVNRevision.HEAD;
        else {
            try {
                toRevision = SVNRevision.getRevision(toRevisionText.getText().trim());
            } catch (ParseException e1) {
                MessageDialog.openError(getShell(), Policy.bind("MergeDialog.title"), // $NON-NLS-1$ //$NON-NLS-2$
                Policy.bind("MergeDialog.invalidTo"));
                return;
            }
        }
    } catch (MalformedURLException e) {
        MessageDialog.openError(getShell(), Policy.bind("MergeDialog.title"), // $NON-NLS-1$
        e.getMessage());
        return;
    }
    super.okPressed();
}
Also used : MalformedURLException(java.net.MalformedURLException) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ParseException(java.text.ParseException)

Example 33 with SVNUrl

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

the class SVNLightweightDecorator method decorateTextLabel.

/**
 * decorate the text label of the given resource. This method assumes that only one thread will be
 * accessing it at a time.
 */
protected void decorateTextLabel(ISVNLocalResource svnResource, LocalResourceStatus status, IDecoration decoration, boolean isDirty) {
    Map bindings = new HashMap(6);
    // has been deleted after we where asked to decorate it.
    if (svnResource.getIResource().getLocation() == null) {
        return;
    }
    if (status.isUnversioned())
        return;
    // get the format
    IDecoratorComponent[][] format;
    int type = svnResource.getIResource().getType();
    if (type == IResource.FOLDER) {
        format = folderDecoratorFormat;
    } else if (type == IResource.PROJECT) {
        format = projectDecoratorFormat;
    } else {
        format = fileDecoratorFormat;
    }
    // fill the bindings
    if (isDirty & !status.isAdded()) {
        bindings.put(SVNDecoratorConfiguration.DIRTY_FLAG, dirtyFlag);
    }
    if (status.getUrlString() != null) {
        String label = null;
        ISVNRepositoryLocation repository = status.getRepository();
        if (repository != null) {
            label = status.getRepository().getLabel();
        }
        bindings.put(SVNDecoratorConfiguration.RESOURCE_LABEL, label == null ? status.getUrlString() : label);
        bindings.put(SVNDecoratorConfiguration.RESOURCE_URL, Util.unescape(status.getUrlString()));
        // short url is the path relative to root url of repository
        SVNUrl repositoryRoot = null;
        if (repository != null) {
            repositoryRoot = repository.getRepositoryRoot();
        }
        if (repositoryRoot != null) {
            int urlLen = status.getUrlString().length();
            int rootLen = repositoryRoot.toString().length() + 1;
            String shortUrl;
            if (urlLen > rootLen)
                shortUrl = status.getUrlString().substring(rootLen);
            else
                shortUrl = status.getUrlString();
            bindings.put(SVNDecoratorConfiguration.RESOURCE_URL_SHORT, Util.unescape(shortUrl));
        }
    }
    if (status.isAdded()) {
        bindings.put(SVNDecoratorConfiguration.ADDED_FLAG, addedFlag);
    } else if (SVNStatusKind.EXTERNAL.equals(status.getTextStatus())) {
        bindings.put(SVNDecoratorConfiguration.EXTERNAL_FLAG, externalFlag);
    } else {
        if ((status.getTextStatus() != SVNStatusKind.UNVERSIONED) && (status.getTextStatus() != SVNStatusKind.ADDED)) {
            if (status.getLastChangedRevision() != null) {
                bindings.put(SVNDecoratorConfiguration.RESOURCE_REVISION, status.getLastChangedRevision().toString());
            }
            if (status.getLastCommitAuthor() != null) {
                bindings.put(SVNDecoratorConfiguration.RESOURCE_AUTHOR, status.getLastCommitAuthor());
            }
        }
        if (status.getLastChangedDate() != null) {
            bindings.put(SVNDecoratorConfiguration.RESOURCE_DATE, dateFormat.format(status.getLastChangedDate()));
        }
    }
    SVNDecoratorConfiguration.decorate(decoration, format, bindings);
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) HashMap(java.util.HashMap) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 34 with SVNUrl

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

the class MergeWizardStandardPage method initializeLocations.

private void initializeLocations() {
    MergeWizard wizard = (MergeWizard) getWizard();
    resource = wizard.getResource();
    resources = wizard.getResources();
    svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
    mergeInfoPaths = null;
    try {
        fromUrl = svnResource.getStatus().getUrlString();
    } catch (Exception e) {
        Activator.handleError(e);
    }
    repositoryLocation = svnResource.getRepository().getLocation();
    if (((MergeWizard) getWizard()).suggestMergeSources()) {
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.setTaskName(Messages.MergeWizardStandardPage_retrievingMergeSourceInfo);
                monitor.beginTask(Messages.MergeWizardStandardPage_retrievingMergeSourceInfo, IProgressMonitor.UNKNOWN);
                // $NON-NLS-1$
                monitor.subTask("");
                ISVNClientAdapter svnClient = null;
                try {
                    svnClient = svnResource.getRepository().getSVNClient();
                    try {
                        if (unblock) {
                            try {
                                mergeInfo = svnClient.getMergeInfo(new SVNUrl(commonRoot), SVNRevision.HEAD);
                            } catch (Exception e) {
                            }
                            if (mergeInfo != null)
                                mergeInfoPaths = mergeInfo.getPaths();
                            if (mergeInfoPaths == null || mergeInfoPaths.length == 0) {
                                Display.getDefault().asyncExec(new Runnable() {

                                    public void run() {
                                        setErrorMessage(Messages.MergeWizardStandardPage_noRevisionsToUnblock);
                                    }
                                });
                            }
                        } else {
                            mergeInfoPaths = svnClient.suggestMergeSources(new SVNUrl(commonRoot), SVNRevision.HEAD);
                        }
                    } catch (Exception e1) {
                    }
                } catch (Exception e) {
                    Activator.handleError(e);
                } finally {
                    svnResource.getRepository().returnSVNClient(svnClient);
                }
                monitor.done();
            }
        };
        try {
            getContainer().run(true, false, runnable);
        } catch (Exception e2) {
            Activator.handleError(e2);
        }
    }
    boolean valueAdded = false;
    List<String> fromUrls = new ArrayList<String>();
    if (mergeInfoPaths != null) {
        for (int i = 0; i < mergeInfoPaths.length; i++) {
            String url = mergeInfoPaths[i].substring(repositoryLocation.length());
            if (!fromUrls.contains(url))
                fromUrls.add(url);
            valueAdded = true;
        }
    }
    String previousFromUrls = null;
    String previousFromUrl = null;
    try {
        previousFromUrls = Activator.getDefault().getDialogSettings().get("mergeFromUrls_" + commonRoot);
    } catch (Exception e) {
    }
    if (previousFromUrls != null) {
        String[] urls = previousFromUrls.split("\\,");
        for (String url : urls) {
            if (!fromUrls.contains(url))
                fromUrls.add(url);
            valueAdded = true;
        }
        if (urls.length > 0)
            previousFromUrl = urls[0];
    }
    if (!valueAdded && !unblock && commonRoot != null) {
        fromUrls.add(commonRoot.substring(repositoryLocation.length()));
    }
    for (String url : fromUrls) {
        fromCombo.add(url);
    }
    if (previousFromUrl != null)
        fromCombo.setText(previousFromUrl);
    else if (fromCombo.getItemCount() > 0)
        fromCombo.setText(fromCombo.getItem(0));
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException) MalformedURLException(java.net.MalformedURLException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 35 with SVNUrl

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

the class StandardMergeInputProvider method performMerge.

public boolean performMerge(MergeWizardMainPage mainPage, MergeWizardLastPage optionsPage, IWorkbenchPart targetPart) {
    String commonRoot = standardPage.getCommonRoot(false);
    String mergeFrom = standardPage.getMergeFrom();
    Activator.getDefault().saveMergeSource(mergeFrom, commonRoot);
    IResource[] resources = standardPage.getResources();
    SVNUrl[] urls = standardPage.getUrls();
    SVNRevisionRange[] revisions = null;
    if (standardPage.selectRevisions()) {
        Set<IResource> usedResources = new HashSet<IResource>();
        Map<SVNRevision.Number, List<IResource>> map = revisionsPage.getRevisionToResource();
        revisions = revisionsPage.getRevisions();
        CommentsManager commentsManager = SVNUIPlugin.getPlugin().getRepositoryManager().getCommentsManager();
        ILogEntry[] entries = revisionsPage.getSelectedLogEntries();
        for (int i = 0; i < entries.length; i++) {
            commentsManager.addComment(entries[i].getComment());
            if (map.size() > 0) {
                List<IResource> lst = map.get(entries[i].getRevision());
                usedResources.addAll(lst);
            }
        }
        // only filter the urls if the usedResources does have content.
        if (usedResources.size() > 0) {
            List<SVNUrl> urlsList = new ArrayList<SVNUrl>();
            List<IResource> resourcesList = new ArrayList<IResource>();
            for (int i = 0; i < resources.length; i++) {
                if (usedResources.contains(resources[i])) {
                    urlsList.add(urls[i]);
                    resourcesList.add(resources[i]);
                }
            }
            resources = resourcesList.toArray(new IResource[resourcesList.size()]);
            urls = urlsList.toArray(new SVNUrl[urlsList.size()]);
        }
    }
    MergeOperation mergeOperation = new MergeOperation(targetPart, resources, urls, null, urls, null, revisions, null);
    mergeOperation.setForce(optionsPage.isForce());
    mergeOperation.setIgnoreAncestry(optionsPage.isIgnore());
    mergeOperation.setDepth(optionsPage.getDepth());
    mergeOperation.setTextConflictHandling(optionsPage.getTextConflictHandling());
    mergeOperation.setBinaryConflictHandling(optionsPage.getBinaryConflictHandling());
    mergeOperation.setPropertyConflictHandling(optionsPage.getPropertyConflictHandling());
    mergeOperation.setTreeConflictHandling(optionsPage.getTreeConflictHandling());
    try {
        mergeOperation.run();
    } catch (Exception e) {
        Activator.handleError(Messages.StandardMergeInputProvider_error, e);
        MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.StandardMergeInputProvider_merge, e.getMessage());
        return false;
    }
    return true;
}
Also used : CommentsManager(org.tigris.subversion.subclipse.ui.comments.CommentsManager) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNRevisionRange(org.tigris.subversion.svnclientadapter.SVNRevisionRange) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet)

Aggregations

SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)83 SVNException (org.tigris.subversion.subclipse.core.SVNException)29 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)26 MalformedURLException (java.net.MalformedURLException)25 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)21 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)19 ParseException (java.text.ParseException)18 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)17 IResource (org.eclipse.core.resources.IResource)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)14 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)14 TeamException (org.eclipse.team.core.TeamException)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)13 ArrayList (java.util.ArrayList)12 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)12 File (java.io.File)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 RemoteFolder (org.tigris.subversion.subclipse.core.resources.RemoteFolder)8