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));
}
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();
}
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);
}
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];
}
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;
}
Aggregations