Search in sources :

Example 21 with VcsException

use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.

the class LatestExistentSearcher method getDeletionRevision.

public long getDeletionRevision() {
    if (!detectStartRevision())
        return -1;
    final Ref<Long> latest = new Ref<>(myStartNumber);
    try {
        if (myEndNumber == -1) {
            myEndNumber = getLatestRevision();
        }
        final SVNURL existingParent = getExistingParent(myUrl);
        if (existingParent == null) {
            return myStartNumber;
        }
        final SVNRevision startRevision = SVNRevision.create(myStartNumber);
        SvnTarget target = SvnTarget.fromURL(existingParent, startRevision);
        myVcs.getFactory(target).createHistoryClient().doLog(target, startRevision, SVNRevision.HEAD, false, true, false, 0, null, createHandler(latest));
    } catch (VcsException e) {
        LOG.info(e);
    }
    return latest.get().longValue();
}
Also used : Ref(com.intellij.openapi.util.Ref) SVNURL(org.tmatesoft.svn.core.SVNURL) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) VcsException(com.intellij.openapi.vcs.VcsException) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision)

Example 22 with VcsException

use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.

the class LiveProvider method getEarliestBunchInIntervalImpl.

private Fragment getEarliestBunchInIntervalImpl(long earliestRevision, final long oldestRevision, final int desirableSize, final boolean includeYoungest, final boolean includeOldest, final long earliestToTake) throws VcsException {
    if ((myEarliestRevisionWasAccessed) || ((oldestRevision == myYoungestRevision) && ((!includeYoungest) || (!includeOldest)))) {
        return null;
    }
    final SVNRevision youngRevision = (earliestRevision == -1) ? SVNRevision.HEAD : SVNRevision.create(earliestRevision);
    final Ref<List<CommittedChangeList>> refToList = new Ref<>();
    final Ref<VcsException> exceptionRef = new Ref<>();
    final Runnable loader = () -> {
        try {
            refToList.set(myLoader.loadInterval(youngRevision, SVNRevision.create(oldestRevision), desirableSize, includeYoungest, includeOldest));
        } catch (VcsException e) {
            exceptionRef.set(e);
        }
    };
    final Application application = ApplicationManager.getApplication();
    if (application.isUnitTestMode() || !application.isDispatchThread()) {
        loader.run();
    } else {
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            final ProgressIndicator ind = ProgressManager.getInstance().getProgressIndicator();
            if (ind != null) {
                ind.setText(SvnBundle.message("progress.live.provider.loading.revisions.details.text"));
            }
            loader.run();
        }, SvnBundle.message("progress.live.provider.loading.revisions.text"), false, myVcs.getProject());
    }
    if (!exceptionRef.isNull()) {
        final VcsException e = exceptionRef.get();
        if (isElementNotFound(e)) {
            // occurs when target URL is deleted in repository
            // try to find latest existent revision. expensive ...
            final LatestExistentSearcher searcher = new LatestExistentSearcher(oldestRevision, myYoungestRevision, (oldestRevision != 0), myVcs, myLocation.toSvnUrl(), myRepositoryUrl);
            final long existent = searcher.getLatestExistent();
            if ((existent == -1) || (existent == earliestRevision)) {
                myEarliestRevisionWasAccessed = true;
                return null;
            }
            return getEarliestBunchInIntervalImpl(existent, oldestRevision, includeYoungest ? desirableSize : (desirableSize + 1), true, includeOldest, Math.min(existent, earliestRevision));
        }
        throw e;
    }
    final List<CommittedChangeList> list = refToList.get();
    if (list.isEmpty()) {
        myEarliestRevisionWasAccessed = (oldestRevision == 0);
        return null;
    }
    if (earliestToTake > 0) {
        for (Iterator<CommittedChangeList> iterator = list.iterator(); iterator.hasNext(); ) {
            final CommittedChangeList changeList = iterator.next();
            if (changeList.getNumber() > earliestToTake)
                iterator.remove();
        }
    }
    myEarliestRevisionWasAccessed = (oldestRevision == 0) && ((list.size() + ((!includeOldest) ? 1 : 0) + ((!includeYoungest) ? 1 : 0)) < desirableSize);
    return new Fragment(Origin.LIVE, list, true, true, null);
}
Also used : CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) Ref(com.intellij.openapi.util.Ref) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) List(java.util.List) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) Application(com.intellij.openapi.application.Application)

Example 23 with VcsException

use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.

the class LocalChangesPromptTask method shelveChanges.

private void shelveChanges(@NotNull Intersection intersection) throws VcsException {
    try {
        getApplication().invokeAndWait(() -> FileDocumentManager.getInstance().saveAllDocuments());
        ShelveChangesManager shelveManager = ShelveChangesManager.getInstance(myMergeContext.getProject());
        for (Map.Entry<String, List<Change>> entry : intersection.getChangesByLists().entrySet()) {
            String shelfName = intersection.getComment(entry.getKey()) + " (auto shelve before merge)";
            shelveManager.shelveChanges(entry.getValue(), shelfName, true, true);
        }
    } catch (IOException e) {
        throw new VcsException(e);
    }
}
Also used : ShelveChangesManager(com.intellij.openapi.vcs.changes.shelf.ShelveChangesManager) VcsException(com.intellij.openapi.vcs.VcsException) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) List(java.util.List) IOException(java.io.IOException) Map(java.util.Map)

Example 24 with VcsException

use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.

the class SvnRepositoryContentRevision method loadContent.

@NotNull
protected ByteArrayOutputStream loadContent() throws VcsException {
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    ContentLoader loader = new ContentLoader(myPath, buffer, myRevision);
    if (ApplicationManager.getApplication().isDispatchThread()) {
        ProgressManager.getInstance().runProcessWithProgressSynchronously(loader, SvnBundle.message("progress.title.loading.file.content"), false, null);
    } else {
        loader.run();
    }
    final Exception exception = loader.getException();
    if (exception != null) {
        throw new VcsException(exception);
    }
    ContentRevisionCache.checkContentsSize(myPath, buffer.size());
    return buffer;
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) IOException(java.io.IOException) VcsException(com.intellij.openapi.vcs.VcsException) NotNull(org.jetbrains.annotations.NotNull)

Example 25 with VcsException

use of com.intellij.openapi.vcs.VcsException in project intellij-community by JetBrains.

the class SvnKitRevertClient method revert.

@Override
public void revert(@NotNull Collection<File> paths, @Nullable Depth depth, @Nullable ProgressTracker handler) throws VcsException {
    SVNWCClient client = myVcs.getSvnKitManager().createWCClient();
    client.setEventHandler(toEventHandler(handler));
    try {
        client.doRevert(ArrayUtil.toObjectArray(paths, File.class), toDepth(depth), null);
    } catch (SVNException e) {
        throw new VcsException(e);
    }
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) SVNWCClient(org.tmatesoft.svn.core.wc.SVNWCClient) SVNException(org.tmatesoft.svn.core.SVNException) File(java.io.File)

Aggregations

VcsException (com.intellij.openapi.vcs.VcsException)200 VirtualFile (com.intellij.openapi.vfs.VirtualFile)89 File (java.io.File)48 NotNull (org.jetbrains.annotations.NotNull)42 FilePath (com.intellij.openapi.vcs.FilePath)35 Change (com.intellij.openapi.vcs.changes.Change)33 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)26 ArrayList (java.util.ArrayList)24 Nullable (org.jetbrains.annotations.Nullable)23 IOException (java.io.IOException)20 SVNException (org.tmatesoft.svn.core.SVNException)19 Project (com.intellij.openapi.project.Project)17 Ref (com.intellij.openapi.util.Ref)16 Test (org.junit.Test)14 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)13 GitRepository (git4idea.repo.GitRepository)12 Task (com.intellij.openapi.progress.Task)11 List (java.util.List)11 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)10 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)10