Search in sources :

Example 1 with CannotFindCvsRootException

use of com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException in project intellij-community by JetBrains.

the class CvsCommandOperation method doExecute.

private void doExecute(final CvsExecutionEnvironment executionEnvironment, boolean underReadAction) throws VcsException {
    final VcsException[] exc = new VcsException[1];
    final Runnable action = () -> {
        try {
            final ReadWriteStatistics statistics = executionEnvironment.getReadWriteStatistics();
            final Collection<CvsRootProvider> allCvsRoots;
            try {
                allCvsRoots = getAllCvsRoots();
            } catch (CannotFindCvsRootException e) {
                throw createVcsExceptionOn(e, null);
            }
            final IProgressViewer progressViewer = new IProgressViewer() {

                @Override
                public void setProgress(double value) {
                    final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
                    if (progressIndicator != null)
                        progressIndicator.setFraction(value);
                }
            };
            int count = 0;
            final double step = 1.0 / allCvsRoots.size();
            for (CvsRootProvider cvsRootProvider : allCvsRoots) {
                try {
                    final double lowerBound = step * count;
                    final RangeProgressViewer partialProgress = new RangeProgressViewer(progressViewer, lowerBound, lowerBound + step);
                    myLastProcessedCvsRoot = cvsRootProvider.getCvsRootAsString();
                    execute(cvsRootProvider, executionEnvironment, statistics, partialProgress);
                    count++;
                } catch (IOCommandException e) {
                    LOG.info(e);
                    throw createVcsExceptionOn(e.getIOException(), cvsRootProvider.getCvsRootAsString());
                } catch (CommandException e) {
                    LOG.info(e);
                    final Exception underlyingException = e.getUnderlyingException();
                    if (underlyingException != null) {
                        LOG.info(underlyingException);
                    }
                    throw createVcsExceptionOn(underlyingException == null ? e : underlyingException, cvsRootProvider.getCvsRootAsString());
                }
            }
        } catch (VcsException e) {
            exc[0] = e;
        }
    };
    if (underReadAction) {
        ApplicationManager.getApplication().runReadAction(action);
    } else {
        action.run();
    }
    if (exc[0] != null)
        throw exc[0];
}
Also used : IProgressViewer(org.netbeans.lib.cvsclient.progress.IProgressViewer) CannotFindCvsRootException(com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException) CvsException(com.intellij.cvsSupport2.errorHandling.CvsException) AuthenticationException(org.netbeans.lib.cvsclient.connection.AuthenticationException) VcsException(com.intellij.openapi.vcs.VcsException) CannotFindCvsRootException(com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) RangeProgressViewer(org.netbeans.lib.cvsclient.progress.RangeProgressViewer) Collection(java.util.Collection) CvsRootProvider(com.intellij.cvsSupport2.connections.CvsRootProvider)

Example 2 with CannotFindCvsRootException

use of com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException in project intellij-community by JetBrains.

the class CvsRootOnFileSystem method createMeOn.

public static CvsRootOnFileSystem createMeOn(File file) throws CannotFindCvsRootException {
    File nearestRoot = getRootFor(file);
    if (nearestRoot == null)
        throw new CannotFindCvsRootException(file);
    CvsConnectionSettings cvsRoot = getCvsRootFor(nearestRoot);
    if (cvsRoot == CvsInfo.getAbsentSettings())
        throw new CannotFindCvsRootException(file);
    File commonRoot = getCommonRoot(nearestRoot, cvsRoot);
    return new CvsRootOnFileSystem(getCvsEntriesManager().getCvsConnectionSettingsFor(commonRoot), commonRoot);
}
Also used : File(java.io.File) CannotFindCvsRootException(com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException)

Aggregations

CannotFindCvsRootException (com.intellij.cvsSupport2.errorHandling.CannotFindCvsRootException)2 CvsRootProvider (com.intellij.cvsSupport2.connections.CvsRootProvider)1 CvsException (com.intellij.cvsSupport2.errorHandling.CvsException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 VcsException (com.intellij.openapi.vcs.VcsException)1 File (java.io.File)1 Collection (java.util.Collection)1 AuthenticationException (org.netbeans.lib.cvsclient.connection.AuthenticationException)1 IProgressViewer (org.netbeans.lib.cvsclient.progress.IProgressViewer)1 RangeProgressViewer (org.netbeans.lib.cvsclient.progress.RangeProgressViewer)1