Search in sources :

Example 1 with IdeaCommitHandler

use of org.jetbrains.idea.svn.checkin.IdeaCommitHandler in project intellij-community by JetBrains.

the class SvnCheckoutProvider method doImport.

public static void doImport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean includeIgnored, final String message) {
    final Ref<String> errorMessage = new Ref<>();
    final SvnVcs vcs = SvnVcs.getInstance(project);
    final String targetPath = FileUtil.toSystemIndependentName(target.getAbsolutePath());
    ExclusiveBackgroundVcsAction.run(project, () -> ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
        final FileIndexFacade facade = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class);
        ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        try {
            progressIndicator.setText(message("progress.text.import", target.getAbsolutePath()));
            final VirtualFile targetVf = SvnUtil.getVirtualFile(targetPath);
            if (targetVf == null) {
                errorMessage.set("Can not find file: " + targetPath);
            } else {
                final boolean isInContent = getApplication().runReadAction((Computable<Boolean>) () -> facade.isInContent(targetVf));
                CommitEventHandler handler = new IdeaCommitHandler(progressIndicator);
                boolean useFileFilter = !project.isDefault() && isInContent;
                ISVNCommitHandler commitHandler = useFileFilter ? new MyFilter(LocalFileSystem.getInstance(), new SvnExcludingIgnoredOperation.Filter(project)) : null;
                long revision = vcs.getFactoryFromSettings().createImportClient().doImport(target, url, depth, message, includeIgnored, handler, commitHandler);
                if (revision > 0) {
                    StatusBar.Info.set(message("status.text.comitted.revision", revision), project);
                }
            }
        } catch (VcsException e) {
            errorMessage.set(e.getMessage());
        }
    }, message("message.title.import"), true, project));
    if (!errorMessage.isNull()) {
        showErrorDialog(message("message.text.cannot.import", errorMessage.get()), message("message.title.import"));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IdeaCommitHandler(org.jetbrains.idea.svn.checkin.IdeaCommitHandler) ISVNCommitHandler(org.tmatesoft.svn.core.wc.ISVNCommitHandler) CommitEventHandler(org.jetbrains.idea.svn.checkin.CommitEventHandler) SvnVcs(org.jetbrains.idea.svn.SvnVcs) Ref(com.intellij.openapi.util.Ref) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SvnExcludingIgnoredOperation(org.jetbrains.idea.svn.actions.SvnExcludingIgnoredOperation) VcsException(com.intellij.openapi.vcs.VcsException) Computable(com.intellij.openapi.util.Computable) FileIndexFacade(com.intellij.openapi.roots.FileIndexFacade)

Example 2 with IdeaCommitHandler

use of org.jetbrains.idea.svn.checkin.IdeaCommitHandler 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"));
        }
    }
}
Also used : IdeaCommitHandler(org.jetbrains.idea.svn.checkin.IdeaCommitHandler) SVNURL(org.tmatesoft.svn.core.SVNURL) CommitEventHandler(org.jetbrains.idea.svn.checkin.CommitEventHandler) SVNException(org.tmatesoft.svn.core.SVNException) SingleRootSwitcher(org.jetbrains.idea.svn.update.SingleRootSwitcher) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) VcsException(com.intellij.openapi.vcs.VcsException) SVNException(org.tmatesoft.svn.core.SVNException) Ref(com.intellij.openapi.util.Ref) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) 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)

Aggregations

ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Ref (com.intellij.openapi.util.Ref)2 VcsException (com.intellij.openapi.vcs.VcsException)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 CommitEventHandler (org.jetbrains.idea.svn.checkin.CommitEventHandler)2 IdeaCommitHandler (org.jetbrains.idea.svn.checkin.IdeaCommitHandler)2 FileIndexFacade (com.intellij.openapi.roots.FileIndexFacade)1 Computable (com.intellij.openapi.util.Computable)1 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)1 File (java.io.File)1 SvnVcs (org.jetbrains.idea.svn.SvnVcs)1 SvnExcludingIgnoredOperation (org.jetbrains.idea.svn.actions.SvnExcludingIgnoredOperation)1 SvnBindException (org.jetbrains.idea.svn.commandLine.SvnBindException)1 SingleRootSwitcher (org.jetbrains.idea.svn.update.SingleRootSwitcher)1 SVNException (org.tmatesoft.svn.core.SVNException)1 SVNURL (org.tmatesoft.svn.core.SVNURL)1 ISVNCommitHandler (org.tmatesoft.svn.core.wc.ISVNCommitHandler)1 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)1 SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)1