Search in sources :

Example 26 with SvnVcs

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

the class BranchesLoader method loadBranches.

@NotNull
public List<SvnBranchItem> loadBranches() throws SVNException, VcsException {
    SvnVcs vcs = SvnVcs.getInstance(myProject);
    SVNURL branchesUrl = SVNURL.parseURIEncoded(myUrl);
    List<SvnBranchItem> result = new LinkedList<>();
    SvnTarget target = SvnTarget.fromURL(branchesUrl);
    DirectoryEntryConsumer handler = createConsumer(result);
    vcs.getFactory(target).create(BrowseClient.class, !myPassive).list(target, SVNRevision.HEAD, Depth.IMMEDIATES, handler);
    Collections.sort(result);
    return result;
}
Also used : DirectoryEntryConsumer(org.jetbrains.idea.svn.browse.DirectoryEntryConsumer) BrowseClient(org.jetbrains.idea.svn.browse.BrowseClient) SVNURL(org.tmatesoft.svn.core.SVNURL) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) LinkedList(java.util.LinkedList) SvnVcs(org.jetbrains.idea.svn.SvnVcs) NotNull(org.jetbrains.annotations.NotNull)

Example 27 with SvnVcs

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

the class SvnCheckoutProvider method checkout.

public static void checkout(final Project project, final File target, final String url, final SVNRevision revision, final Depth depth, final boolean ignoreExternals, final Listener listener, final WorkingCopyFormat selectedFormat) {
    final Ref<Boolean> checkoutSuccessful = new Ref<>();
    final Exception[] exception = new Exception[1];
    final Task.Backgroundable checkoutBackgroundTask = new Task.Backgroundable(project, message("message.title.check.out"), true, VcsConfiguration.getInstance(project).getCheckoutOption()) {

        public void run(@NotNull final ProgressIndicator indicator) {
            final WorkingCopyFormat format = selectedFormat == null ? UNKNOWN : selectedFormat;
            SvnWorkingCopyFormatHolder.setPresetFormat(format);
            SvnVcs vcs = SvnVcs.getInstance(project);
            ProgressTracker handler = new CheckoutEventHandler(vcs, false, ProgressManager.getInstance().getProgressIndicator());
            ProgressManager.progress(message("progress.text.checking.out", target.getAbsolutePath()));
            try {
                getFactory(vcs, format).createCheckoutClient().checkout(SvnTarget.fromURL(SVNURL.parseURIEncoded(url)), target, revision, depth, ignoreExternals, true, format, handler);
                ProgressManager.checkCanceled();
                checkoutSuccessful.set(Boolean.TRUE);
            } catch (SVNCancelException ignore) {
            } catch (SVNException | VcsException e) {
                exception[0] = e;
            } finally {
                SvnWorkingCopyFormatHolder.setPresetFormat(null);
            }
        }

        public void onCancel() {
            onSuccess();
        }

        public void onSuccess() {
            if (exception[0] != null) {
                showErrorDialog(message("message.text.cannot.checkout", exception[0].getMessage()), message("message.title.check.out"));
            }
            VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(target);
            if (vf != null) {
                vf.refresh(true, true, () -> getApplication().invokeLater(() -> notifyListener()));
            } else {
                notifyListener();
            }
        }

        private void notifyListener() {
            notifyRootManagerIfUnderProject(project, target);
            if (listener != null) {
                if (!checkoutSuccessful.isNull()) {
                    listener.directoryCheckedOut(target, SvnVcs.getKey());
                }
                listener.checkoutCompleted();
            }
        }
    };
    ProgressManager.getInstance().run(checkoutBackgroundTask);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Task(com.intellij.openapi.progress.Task) WorkingCopyFormat(org.jetbrains.idea.svn.WorkingCopyFormat) ProgressTracker(org.jetbrains.idea.svn.api.ProgressTracker) SVNException(org.tmatesoft.svn.core.SVNException) NotNull(org.jetbrains.annotations.NotNull) VcsException(com.intellij.openapi.vcs.VcsException) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) SVNException(org.tmatesoft.svn.core.SVNException) SvnVcs(org.jetbrains.idea.svn.SvnVcs) Ref(com.intellij.openapi.util.Ref) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) VcsException(com.intellij.openapi.vcs.VcsException)

Example 28 with SvnVcs

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

the class SvnCheckoutProvider method notifyRootManagerIfUnderProject.

private static void notifyRootManagerIfUnderProject(final Project project, final File directory) {
    if (project.isDefault())
        return;
    final ProjectLevelVcsManagerEx plVcsManager = ProjectLevelVcsManagerEx.getInstanceEx(project);
    final SvnVcs vcs = (SvnVcs) plVcsManager.findVcsByName(SvnVcs.VCS_NAME);
    final VirtualFile[] files = vcs.getSvnFileUrlMapping().getNotFilteredRoots();
    for (VirtualFile file : files) {
        if (FileUtil.isAncestor(virtualToIoFile(file), directory, false)) {
            // todo: should be done like auto detection
            plVcsManager.fireDirectoryMappingsChanged();
            return;
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectLevelVcsManagerEx(com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 29 with SvnVcs

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

the class SvnCommittedViewTest method testCopyDir.

@Test
public void testCopyDir() throws Exception {
    final File trunk = new File(myTempDirFixture.getTempDirPath(), "trunk");
    trunk.mkdir();
    Thread.sleep(100);
    final File folder = new File(trunk, "folder");
    folder.mkdir();
    Thread.sleep(100);
    new File(folder, "f1.txt").createNewFile();
    new File(folder, "f2.txt").createNewFile();
    Thread.sleep(100);
    runInAndVerifyIgnoreOutput("import", "-m", "test", trunk.getAbsolutePath(), myRepoUrl + "/trunk");
    runInAndVerifyIgnoreOutput("copy", "-m", "test", myRepoUrl + "/trunk", myRepoUrl + "/branch");
    final SvnVcs vcs = SvnVcs.getInstance(myProject);
    vcs.invokeRefreshSvnRoots();
    final CommittedChangesProvider<SvnChangeList, ChangeBrowserSettings> committedChangesProvider = vcs.getCommittedChangesProvider();
    final List<SvnChangeList> changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), new SvnRepositoryLocation(myRepoUrl + "/branch"), 0);
    checkList(changeListList, 2, new Data[] { new Data(new File(myWorkingCopyDir.getPath(), "branch").getAbsolutePath(), FileStatus.ADDED, "- copied from /trunk") });
}
Also used : SvnRepositoryLocation(org.jetbrains.idea.svn.history.SvnRepositoryLocation) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) ChangeBrowserSettings(com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) SvnVcs(org.jetbrains.idea.svn.SvnVcs) Test(org.junit.Test)

Example 30 with SvnVcs

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

the class SvnCommittedViewTest method testCopyAndModify.

@Test
public void testCopyAndModify() throws Exception {
    final File trunk = new File(myTempDirFixture.getTempDirPath(), "trunk");
    trunk.mkdir();
    Thread.sleep(100);
    final File folder = new File(trunk, "folder");
    folder.mkdir();
    Thread.sleep(100);
    new File(folder, "f1.txt").createNewFile();
    new File(folder, "f2.txt").createNewFile();
    Thread.sleep(100);
    runInAndVerifyIgnoreOutput("import", "-m", "test", trunk.getAbsolutePath(), myRepoUrl + "/trunk");
    update();
    runInAndVerifyIgnoreOutput("copy", myWorkingCopyDir.getPath() + "/trunk", myWorkingCopyDir.getPath() + "/branch");
    runInAndVerifyIgnoreOutput("propset", "testprop", "testval", myWorkingCopyDir.getPath() + "/branch/folder");
    checkin();
    final SvnVcs vcs = SvnVcs.getInstance(myProject);
    vcs.invokeRefreshSvnRoots();
    final CommittedChangesProvider<SvnChangeList, ChangeBrowserSettings> committedChangesProvider = vcs.getCommittedChangesProvider();
    final List<SvnChangeList> changeListList = committedChangesProvider.getCommittedChanges(committedChangesProvider.createDefaultSettings(), new SvnRepositoryLocation(myRepoUrl + "/branch"), 0);
    checkList(changeListList, 2, new Data[] { new Data(new File(myWorkingCopyDir.getPath(), "branch").getAbsolutePath(), FileStatus.ADDED, "- copied from /trunk"), new Data(new File(myWorkingCopyDir.getPath(), "branch/folder").getAbsolutePath(), FileStatus.MODIFIED, "- copied from /trunk/folder") });
}
Also used : SvnRepositoryLocation(org.jetbrains.idea.svn.history.SvnRepositoryLocation) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) ChangeBrowserSettings(com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) SvnVcs(org.jetbrains.idea.svn.SvnVcs) Test(org.junit.Test)

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