use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnUtil method getWcCopyRootIf17.
@Nullable
public static File getWcCopyRootIf17(final File file, @Nullable final File upperBound) {
File current = getParentWithDb(file);
if (current == null)
return null;
while (current != null) {
try {
final SvnWcGeneration svnWcGeneration = SvnOperationFactory.detectWcGeneration(current, false);
if (SvnWcGeneration.V17.equals(svnWcGeneration))
return current;
if (SvnWcGeneration.V16.equals(svnWcGeneration))
return null;
if (upperBound != null && FileUtil.filesEqual(upperBound, current))
return null;
current = current.getParentFile();
} catch (SVNException e) {
return null;
}
}
return null;
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnKitAddClient method add.
/**
* TODO: Implement correct support for includeIgnored parameter. Also check that correct depth will be used for all cases (when another
* TODO: overload of doAdd() is used) as, for instance, SVNDepth.recurseFromDepth(EMPTY) = false, SVNDepth.fromRecursive(false) = FILES.
*/
@Override
public void add(@NotNull File file, @Nullable Depth depth, boolean makeParents, boolean includeIgnored, boolean force, @Nullable ProgressTracker handler) throws VcsException {
try {
SVNWCClient client = myVcs.getSvnKitManager().createWCClient();
client.setEventHandler(toEventHandler(handler));
client.doAdd(file, force, // directory should already be created
false, // not used but will be passed as makeParents value
makeParents, Depth.isRecursive(depth));
} catch (SVNException e) {
throw new VcsException(e);
}
}
use of org.tmatesoft.svn.core.SVNException 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.SVNException in project intellij-community by JetBrains.
the class SvnKitAnnotateClient method annotate.
@Override
public void annotate(@NotNull SvnTarget target, @NotNull SVNRevision startRevision, @NotNull SVNRevision endRevision, boolean includeMergedRevisions, @Nullable DiffOptions diffOptions, @Nullable AnnotationConsumer handler) throws VcsException {
try {
SVNLogClient client = myVcs.getSvnKitManager().createLogClient();
client.setDiffOptions(toDiffOptions(diffOptions));
if (target.isFile()) {
client.doAnnotate(target.getFile(), target.getPegRevision(), startRevision, endRevision, true, includeMergedRevisions, toAnnotateHandler(handler), null);
} else {
client.doAnnotate(target.getURL(), target.getPegRevision(), startRevision, endRevision, true, includeMergedRevisions, toAnnotateHandler(handler), null);
}
} catch (SVNException e) {
throw new VcsException(e);
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnExceptionLogFilter method getKey.
@Override
public Object getKey(@NotNull Level level, @NonNls String message, @Nullable Throwable t, @NonNls String... details) {
SVNException e = getSvnException(t);
boolean shouldFilter = e != null && ourLogRarelyCodes.contains(e.getErrorMessage().getErrorCode());
return shouldFilter ? e.getErrorMessage().getErrorCode() : null;
}
Aggregations