use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class CreateBranchOrTagAction method perform.
@Override
protected void perform(@NotNull SvnVcs vcs, @NotNull VirtualFile file, @NotNull DataContext context) throws VcsException {
CreateBranchOrTagDialog dialog = new CreateBranchOrTagDialog(vcs.getProject(), true, virtualToIoFile(file));
if (dialog.showAndGet()) {
String dstURL = dialog.getToURL();
SVNRevision revision = dialog.getRevision();
String comment = dialog.getComment();
Ref<Exception> exception = new Ref<>();
boolean isSrcFile = dialog.isCopyFromWorkingCopy();
File srcFile = new File(dialog.getCopyFromPath());
SVNURL srcUrl;
SVNURL dstSvnUrl;
SVNURL parentUrl;
try {
srcUrl = SVNURL.parseURIEncoded(dialog.getCopyFromUrl());
dstSvnUrl = SVNURL.parseURIEncoded(dstURL);
parentUrl = dstSvnUrl.removePathTail();
} catch (SVNException e) {
throw new SvnBindException(e);
}
if (!dirExists(vcs, parentUrl)) {
int rc = Messages.showYesNoDialog(vcs.getProject(), "The repository path '" + parentUrl + "' does not exist. Would you like to create it?", "Branch or Tag", Messages.getQuestionIcon());
if (rc == Messages.NO) {
return;
}
}
Runnable copyCommand = () -> {
try {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
CommitEventHandler handler = null;
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.copy.to", dstURL));
handler = new IdeaCommitHandler(progress);
}
SvnTarget source = isSrcFile ? SvnTarget.fromFile(srcFile, revision) : SvnTarget.fromURL(srcUrl, revision);
long newRevision = vcs.getFactory(source).createCopyMoveClient().copy(source, SvnTarget.fromURL(dstSvnUrl), revision, true, false, comment, handler);
updateStatusBar(newRevision, vcs.getProject());
} catch (Exception e) {
exception.set(e);
}
};
ProgressManager.getInstance().runProcessWithProgressSynchronously(copyCommand, SvnBundle.message("progress.title.copy"), false, vcs.getProject());
if (!exception.isNull()) {
throw new VcsException(exception.get());
}
if (dialog.isCopyFromWorkingCopy() && dialog.isSwitchOnCreate()) {
SingleRootSwitcher switcher = new SingleRootSwitcher(vcs.getProject(), VcsUtil.getFilePath(srcFile, srcFile.isDirectory()), dstSvnUrl);
AutoSvnUpdater.run(switcher, SvnBundle.message("action.name.switch"));
}
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnBindException method init.
private void init(@Nullable Throwable throwable) {
if (throwable instanceof SVNException) {
SVNException e = (SVNException) throwable;
int code = e.getErrorMessage().getErrorCode().getCode();
int type = e.getErrorMessage().getType();
(type == SVNErrorMessage.TYPE_ERROR ? errors : warnings).putValue(code, e.getMessage());
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnKitContentClient method getContent.
@Override
public byte[] getContent(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable SVNRevision pegRevision) throws VcsException, FileTooBigRuntimeException {
final int maxSize = VcsUtil.getMaxVcsLoadedFileSize();
ByteArrayOutputStream buffer = new ByteArrayOutputStream() {
@Override
public synchronized void write(int b) {
if (size() > maxSize)
throw new FileTooBigRuntimeException();
super.write(b);
}
@Override
public synchronized void write(byte[] b, int off, int len) {
if (size() > maxSize)
throw new FileTooBigRuntimeException();
super.write(b, off, len);
}
@Override
public synchronized void writeTo(OutputStream out) throws IOException {
if (size() > maxSize)
throw new FileTooBigRuntimeException();
super.writeTo(out);
}
};
SVNWCClient wcClient = myVcs.getSvnKitManager().createWCClient();
try {
if (target.isURL()) {
wcClient.doGetFileContents(target.getURL(), pegRevision, revision, true, buffer);
} else {
wcClient.doGetFileContents(target.getFile(), pegRevision, revision, true, buffer);
}
ContentRevisionCache.checkContentsSize(target.getPathOrUrlString(), buffer.size());
} catch (FileTooBigRuntimeException e) {
ContentRevisionCache.checkContentsSize(target.getPathOrUrlString(), buffer.size());
} catch (SVNException e) {
throw new VcsException(e);
}
return buffer.toByteArray();
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnKitCopyMoveClient method copy.
@Override
public void copy(@NotNull SvnTarget source, @NotNull File destination, @Nullable SVNRevision revision, boolean makeParents, @Nullable ProgressTracker handler) throws VcsException {
SVNCopyClient client = myVcs.getSvnKitManager().createCopyClient();
client.setEventHandler(toEventHandler(handler));
try {
client.doCopy(new SVNCopySource[] { createCopySource(source, revision) }, destination, false, makeParents, true);
} catch (SVNException e) {
throw new SvnBindException(e);
}
}
use of org.tmatesoft.svn.core.SVNException in project intellij-community by JetBrains.
the class SvnKitCopyMoveClient method copy.
@Override
public long copy(@NotNull SvnTarget source, @NotNull SvnTarget destination, @Nullable SVNRevision revision, boolean makeParents, boolean isMove, @NotNull String message, @Nullable CommitEventHandler handler) throws VcsException {
if (!destination.isURL()) {
throw new IllegalArgumentException("Only urls are supported as destination " + destination);
}
final SVNCopySource copySource = createCopySource(source, revision);
SVNCopyClient client = myVcs.getSvnKitManager().createCopyClient();
client.setEventHandler(toEventHandler(handler));
SVNCommitInfo info;
try {
info = client.doCopy(new SVNCopySource[] { copySource }, destination.getURL(), isMove, makeParents, true, message, null);
} catch (SVNException e) {
throw new VcsException(e);
}
return info != null ? info.getNewRevision() : INVALID_REVISION;
}
Aggregations