Search in sources :

Example 1 with SvnVcs

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

the class SvnCheckoutProvider method doExport.

public static void doExport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean ignoreExternals, final boolean force, final String eolStyle) {
    try {
        final VcsException[] exception = new VcsException[1];
        final SvnVcs vcs = SvnVcs.getInstance(project);
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
            ProgressTracker handler = new CheckoutEventHandler(vcs, true, progressIndicator);
            try {
                progressIndicator.setText(message("progress.text.export", target.getAbsolutePath()));
                SvnTarget from = SvnTarget.fromURL(url);
                ExportClient client = vcs.getFactoryFromSettings().createExportClient();
                client.export(from, target, SVNRevision.HEAD, depth, eolStyle, force, ignoreExternals, handler);
            } catch (VcsException e) {
                exception[0] = e;
            }
        }, message("message.title.export"), true, project);
        if (exception[0] != null) {
            throw exception[0];
        }
    } catch (VcsException e1) {
        showErrorDialog(message("message.text.cannot.export", e1.getMessage()), message("message.title.export"));
    }
}
Also used : ProgressTracker(org.jetbrains.idea.svn.api.ProgressTracker) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 2 with SvnVcs

use of org.jetbrains.idea.svn.SvnVcs 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 3 with SvnVcs

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

the class SvnMergeProvider method conflictResolvedForFile.

public void conflictResolvedForFile(@NotNull VirtualFile file) {
    // TODO: Add possibility to resolve content conflicts separately from property conflicts.
    SvnVcs vcs = SvnVcs.getInstance(myProject);
    File path = virtualToIoFile(file);
    try {
        // TODO: Probably false should be passed to "resolveTree", but previous logic used true implicitly
        vcs.getFactory(path).createConflictClient().resolve(path, Depth.EMPTY, false, true, true);
    } catch (VcsException e) {
        LOG.warn(e);
    }
    // the .mine/.r## files have been deleted
    final VirtualFile parent = file.getParent();
    if (parent != null) {
        parent.refresh(true, false);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsException(com.intellij.openapi.vcs.VcsException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 4 with SvnVcs

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

the class SvnMergeProvider method loadRevisions.

@NotNull
public MergeData loadRevisions(@NotNull final VirtualFile file) throws VcsException {
    final MergeData data = new MergeData();
    VcsRunnable runnable = () -> {
        File oldFile = null;
        File newFile = null;
        File workingFile = null;
        boolean mergeCase = false;
        SvnVcs vcs = SvnVcs.getInstance(myProject);
        Info info = vcs.getInfo(file);
        if (info != null) {
            oldFile = info.getConflictOldFile();
            newFile = info.getConflictNewFile();
            workingFile = info.getConflictWrkFile();
            mergeCase = workingFile == null || workingFile.getName().contains("working");
            // for debug
            if (workingFile == null) {
                LOG.info("Null working file when merging text conflict for " + file.getPath() + " old file: " + oldFile + " new file: " + newFile);
            }
            if (mergeCase) {
                // this is merge case
                oldFile = info.getConflictNewFile();
                newFile = info.getConflictOldFile();
                workingFile = info.getConflictWrkFile();
            }
            data.LAST_REVISION_NUMBER = new SvnRevisionNumber(info.getRevision());
        } else {
            throw new VcsException("Could not get info for " + file.getPath());
        }
        if (oldFile == null || newFile == null || workingFile == null) {
            ByteArrayOutputStream bos = getBaseRevisionContents(vcs, file);
            data.ORIGINAL = bos.toByteArray();
            data.LAST = bos.toByteArray();
            data.CURRENT = readFile(virtualToIoFile(file));
        } else {
            data.ORIGINAL = readFile(oldFile);
            data.LAST = readFile(newFile);
            data.CURRENT = readFile(workingFile);
        }
        if (mergeCase) {
            final ByteArrayOutputStream contents = getBaseRevisionContents(vcs, file);
            if (!Arrays.equals(contents.toByteArray(), data.ORIGINAL)) {
                // swap base and server: another order of merge arguments
                byte[] original = data.ORIGINAL;
                data.ORIGINAL = data.LAST;
                data.LAST = original;
            }
        }
    };
    VcsUtil.runVcsProcessWithProgress(runnable, VcsBundle.message("multiple.file.merge.loading.progress.title"), false, myProject);
    return data;
}
Also used : SvnRevisionNumber(org.jetbrains.idea.svn.SvnRevisionNumber) VcsRunnable(com.intellij.vcsUtil.VcsRunnable) MergeData(com.intellij.openapi.vcs.merge.MergeData) VcsException(com.intellij.openapi.vcs.VcsException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Info(org.jetbrains.idea.svn.info.Info) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) SvnVcs(org.jetbrains.idea.svn.SvnVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with SvnVcs

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

the class CreateBranchOrTagDialog method init.

protected void init() {
    super.init();
    SvnVcs vcs = SvnVcs.getInstance(myProject);
    String revStr = "";
    Info info = vcs.getInfo(mySrcFile);
    if (info != null) {
        mySrcURL = info.getURL() == null ? null : info.getURL().toString();
        revStr = String.valueOf(info.getRevision());
        myURL = mySrcURL;
    }
    if (myURL == null) {
        return;
    }
    myWorkingCopyField.setText(mySrcFile.toString());
    myRepositoryField.setText(mySrcURL);
    myToURLText.setText(myURL);
    myRevisionPanel.setRevisionText(revStr);
    updateControls();
    myWorkingCopyRadioButton.setSelected(true);
}
Also used : RootUrlInfo(org.jetbrains.idea.svn.RootUrlInfo) Info(org.jetbrains.idea.svn.info.Info) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Aggregations

SvnVcs (org.jetbrains.idea.svn.SvnVcs)31 VirtualFile (com.intellij.openapi.vfs.VirtualFile)20 File (java.io.File)9 VcsException (com.intellij.openapi.vcs.VcsException)8 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)8 ChangeBrowserSettings (com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings)7 SvnChangeList (org.jetbrains.idea.svn.history.SvnChangeList)7 SvnRepositoryLocation (org.jetbrains.idea.svn.history.SvnRepositoryLocation)7 Test (org.junit.Test)7 Project (com.intellij.openapi.project.Project)5 NotNull (org.jetbrains.annotations.NotNull)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Ref (com.intellij.openapi.util.Ref)3 RootUrlInfo (org.jetbrains.idea.svn.RootUrlInfo)2 ProgressTracker (org.jetbrains.idea.svn.api.ProgressTracker)2 Info (org.jetbrains.idea.svn.info.Info)2 SVNException (org.tmatesoft.svn.core.SVNException)2 SVNURL (org.tmatesoft.svn.core.SVNURL)2 LocalHistoryAction (com.intellij.history.LocalHistoryAction)1 UsageDescriptor (com.intellij.internal.statistic.beans.UsageDescriptor)1