Search in sources :

Example 51 with ISVNClientAdapter

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

the class PropertyCompareRemoteResourceNode method getProperties.

public void getProperties(boolean recursive) {
    ISVNClientAdapter svnClient = null;
    try {
        svnClient = remoteResource.getRepository().getSVNClient();
        properties = svnClient.getProperties(remoteResource.getUrl(), remoteResource.getRevision(), pegRevision, recursive);
    } catch (Exception e) {
        SVNUIPlugin.log(Status.ERROR, e.getMessage(), e);
    } finally {
        remoteResource.getRepository().returnSVNClient(svnClient);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 52 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter 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 53 with ISVNClientAdapter

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

the class SVNUIPlugin method passwordStoresConfiguredOnLinux.

public boolean passwordStoresConfiguredOnLinux() {
    if (System.getProperty("os.name").toLowerCase().indexOf("linux") == -1) {
        return false;
    }
    String svnInterface = getPreferenceStore().getString(ISVNUIConstants.PREF_SVNINTERFACE);
    if (svnInterface != null && !svnInterface.equals("javahl")) {
        return false;
    }
    boolean passwordStoresFound = false;
    boolean valueIsGnomeKeyring = false;
    File configFile = getConfigFile();
    if (!configFile.exists()) {
        ISVNClientAdapter client = null;
        try {
            // This is ja hack to cause the config file to be created so that we
            // can offer to fix it.  We are using a non-existant path so that it will
            // just end quickly.
            client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
            client.cleanup(new File("/This/is/just/a/dummy/file"));
        } catch (Exception e) {
        } finally {
            SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
        }
    }
    if (!configFile.exists())
        return false;
    BufferedReader input = null;
    try {
        input = new BufferedReader(new FileReader(configFile));
        String line = null;
        while ((line = input.readLine()) != null) {
            if (line.startsWith("password-stores =")) {
                passwordStoresFound = true;
                if (!line.trim().endsWith("password-stores =")) {
                    valueIsGnomeKeyring = line.indexOf("gnome-keyring") != -1;
                }
                break;
            }
            if (line.startsWith("password-stores=")) {
                passwordStoresFound = true;
                if (!line.trim().endsWith("password-stores=")) {
                    valueIsGnomeKeyring = line.indexOf("gnome-keyring") != -1;
                }
                break;
            }
        }
    } catch (Exception e) {
    } finally {
        if (input != null) {
            try {
                input.close();
            } catch (IOException e) {
            }
        }
    }
    return valueIsGnomeKeyring || !passwordStoresFound;
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) File(java.io.File) CoreException(org.eclipse.core.runtime.CoreException) BackingStoreException(org.osgi.service.prefs.BackingStoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IOException(java.io.IOException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 54 with ISVNClientAdapter

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

the class UndoMergeCommand method run.

public void run(IProgressMonitor monitor) throws SVNException {
    ISVNClientAdapter svnClient = null;
    ISVNRepositoryLocation repository = null;
    try {
        final OperationManager operationManager = OperationManager.getInstance();
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        repository = svnResource.getRepository();
        svnClient = repository.getSVNClient();
        svnClient.addNotifyListener(operationResourceCollector);
        operationManager.beginOperation(svnClient);
        LocalResourceStatus status = SVNWorkspaceRoot.getSVNResourceFor(resource).getStatus();
        if (!status.isManaged()) {
            try {
                resource.delete(true, monitor);
            } catch (CoreException ex) {
                throw SVNException.wrapException(ex);
            }
        } else {
            File path = resource.getLocation().toFile();
            svnClient.revert(path, true);
            if (resource.getType() != IResource.FILE)
                operationManager.onNotify(path, SVNNodeKind.UNKNOWN);
            monitor.worked(100);
        }
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
        OperationManager.getInstance().endOperation(true, operationResourceCollector.getOperationResources());
        monitor.done();
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) CoreException(org.eclipse.core.runtime.CoreException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) OperationManager(org.tigris.subversion.subclipse.core.client.OperationManager) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 55 with ISVNClientAdapter

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

the class RepositoryBranchTagAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    ISVNRemoteResource[] resources = getSelectedRemoteResources();
    BranchTagWizard wizard = new BranchTagWizard(resources);
    WizardDialog dialog = // $NON-NLS-1$
    new SizePersistedWizardDialog(getShell(), wizard, "BranchTag");
    if (dialog.open() == WizardDialog.OK) {
        SVNUrl[] sourceUrls = wizard.getUrls();
        SVNUrl destinationUrl = wizard.getToUrl();
        String message = wizard.getComment();
        SVNRevision revision = wizard.getRevision();
        boolean makeParents = wizard.isMakeParents();
        ISVNClientAdapter client = null;
        try {
            ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(sourceUrls[0].toString());
            if (repository != null)
                client = repository.getSVNClient();
            if (client == null)
                client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
            RepositoryBranchTagOperation branchTagOperation = new RepositoryBranchTagOperation(getTargetPart(), client, sourceUrls, destinationUrl, revision, message, makeParents);
            branchTagOperation.setMultipleTransactions(wizard.isSameStructure());
            branchTagOperation.run();
        } catch (Exception e) {
            MessageDialog.openError(getShell(), Policy.bind("BranchTagDialog.title"), e.getMessage());
        } finally {
        // BranchTagCommand will dispose.
        // SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
        }
    }
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RepositoryBranchTagOperation(org.tigris.subversion.subclipse.ui.operations.RepositoryBranchTagOperation) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) BranchTagWizard(org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SizePersistedWizardDialog(org.tigris.subversion.subclipse.ui.wizards.SizePersistedWizardDialog) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)108 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)67 SVNException (org.tigris.subversion.subclipse.core.SVNException)37 File (java.io.File)28 IResource (org.eclipse.core.resources.IResource)27 CoreException (org.eclipse.core.runtime.CoreException)22 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)21 TeamException (org.eclipse.team.core.TeamException)21 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)20 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)20 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)19 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)19 ArrayList (java.util.ArrayList)18 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)13 OperationProgressNotifyListener (org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)9 IProject (org.eclipse.core.resources.IProject)8 List (java.util.List)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7