Search in sources :

Example 11 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class SvnCommittedChangesProvider method getCommittedChangesImpl.

private void getCommittedChangesImpl(@NotNull ChangeBrowserSettings settings, @NotNull SvnTarget target, int maxCount, @NotNull Consumer<LogEntry> resultConsumer, boolean includeMergedRevisions, boolean filterOutByDate) throws VcsException {
    progress(message("progress.text.changes.collecting.changes"), message("progress.text2.changes.establishing.connection", target.getPathOrUrlString()));
    String author = settings.getUserFilter();
    SVNRevision revisionBefore = createBeforeRevision(settings);
    SVNRevision revisionAfter = createAfterRevision(settings);
    myVcs.getFactory(target).createHistoryClient().doLog(target, revisionBefore, revisionAfter, settings.STOP_ON_COPY, true, includeMergedRevisions, maxCount, null, createLogHandler(resultConsumer, filterOutByDate, author));
}
Also used : SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision)

Example 12 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision 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 13 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision 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 14 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class SvnAnnotationProvider method annotate.

private FileAnnotation annotate(final VirtualFile file, final VcsFileRevision revision, final VcsRevisionNumber lastChangedRevision, final boolean loadExternally) throws VcsException {
    if (file.isDirectory()) {
        throw new VcsException(SvnBundle.message("exception.text.cannot.annotate.directory"));
    }
    final FileAnnotation[] annotation = new FileAnnotation[1];
    final VcsException[] exception = new VcsException[1];
    Runnable command = () -> {
        final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
        final File ioFile = virtualToIoFile(file).getAbsoluteFile();
        Info info = null;
        try {
            final String contents;
            if (loadExternally) {
                byte[] data = SvnUtil.getFileContents(myVcs, SvnTarget.fromFile(ioFile), SVNRevision.BASE, SVNRevision.UNDEFINED);
                contents = LoadTextUtil.getTextByBinaryPresentation(data, file, false, false).toString();
            } else {
                final byte[] bytes = VcsHistoryUtil.loadRevisionContent(revision);
                contents = LoadTextUtil.getTextByBinaryPresentation(bytes, file, false, false).toString();
            }
            final SvnFileAnnotation result = new SvnFileAnnotation(myVcs, file, contents, lastChangedRevision);
            info = myVcs.getInfo(ioFile);
            if (info == null) {
                exception[0] = new VcsException(new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "File ''{0}'' is not under version control", ioFile)));
                return;
            }
            final String url = info.getURL() == null ? null : info.getURL().toString();
            SVNRevision endRevision = ((SvnFileRevision) revision).getRevision();
            if (SVNRevision.WORKING.equals(endRevision)) {
                endRevision = info.getRevision();
            }
            if (progress != null) {
                progress.setText(SvnBundle.message("progress.text.computing.annotation", file.getName()));
            }
            // ignore mime type=true : IDEA-19562
            final AnnotationConsumer annotateHandler = createAnnotationHandler(progress, result);
            boolean calculateMergeinfo = myVcs.getSvnConfiguration().isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, url);
            final MySteppedLogGetter logGetter = new MySteppedLogGetter(myVcs, ioFile, progress, myVcs.getFactory(ioFile).createHistoryClient(), endRevision, result, url, calculateMergeinfo, file.getCharset());
            logGetter.go();
            final LinkedList<SVNRevision> rp = logGetter.getRevisionPoints();
            // TODO: only 2 elements will be in rp and for loop will be executed only once - probably rewrite with Pair
            AnnotateClient annotateClient = myVcs.getFactory(ioFile).createAnnotateClient();
            for (int i = 0; i < rp.size() - 1; i++) {
                annotateClient.annotate(SvnTarget.fromFile(ioFile), rp.get(i + 1), rp.get(i), calculateMergeinfo, getLogClientOptions(myVcs), annotateHandler);
            }
            if (rp.get(1).getNumber() > 0) {
                result.setFirstRevision(rp.get(1));
            }
            annotation[0] = result;
        } catch (IOException e) {
            exception[0] = new VcsException(e);
        } catch (VcsException e) {
            if (e.getCause() instanceof SVNException) {
                handleSvnException(ioFile, info, (SVNException) e.getCause(), file, revision, annotation, exception);
            } else {
                exception[0] = e;
            }
        }
    };
    if (ApplicationManager.getApplication().isDispatchThread()) {
        ProgressManager.getInstance().runProcessWithProgressSynchronously(command, SvnBundle.message("action.text.annotate"), false, myVcs.getProject());
    } else {
        command.run();
    }
    if (exception[0] != null) {
        throw new VcsException(exception[0]);
    }
    return annotation[0];
}
Also used : SVNException(org.tmatesoft.svn.core.SVNException) IOException(java.io.IOException) Info(org.jetbrains.idea.svn.info.Info) LinkedList(java.util.LinkedList) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Example 15 with SVNRevision

use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.

the class SvnDiffProvider method getRevision.

@Nullable
private static VcsRevisionNumber getRevision(@Nullable Info info) {
    VcsRevisionNumber result = null;
    if (info != null) {
        SVNRevision revision = SVNRevision.UNDEFINED.equals(info.getCommittedRevision()) && info.getCopyFromRevision() != null ? info.getCopyFromRevision() : info.getRevision();
        result = new SvnRevisionNumber(revision);
    }
    return result;
}
Also used : VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)19 VcsException (com.intellij.openapi.vcs.VcsException)7 Info (org.jetbrains.idea.svn.info.Info)7 SVNURL (org.tmatesoft.svn.core.SVNURL)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)4 Ref (com.intellij.openapi.util.Ref)4 File (java.io.File)4 NotNull (org.jetbrains.annotations.NotNull)4 Nullable (org.jetbrains.annotations.Nullable)4 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)4 SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)4 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 FilePath (com.intellij.openapi.vcs.FilePath)3 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)3 List (java.util.List)2 SVNException (org.tmatesoft.svn.core.SVNException)2 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Application (com.intellij.openapi.application.Application)1