use of org.jetbrains.idea.svn.update.SingleRootSwitcher 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"));
}
}
}
Aggregations