summaryrefslogtreecommitdiff
path: root/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRootAboveTest.java
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2013-01-08 11:11:20 -0800
committerJean-Baptiste Queru <jbq@google.com>2013-01-08 11:11:20 -0800
commitb56ea2a18f232d79481e778085fd64e8ae486fc3 (patch)
tree44e1f6eb4864a45033f865b74fe783e3d784dd6a /plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRootAboveTest.java
downloadidea-b56ea2a18f232d79481e778085fd64e8ae486fc3.tar.gz
Snapshot of commit d5ec1d5018ed24f1b4f32b1d09df6dbd7e2fc425
from branch master of git://git.jetbrains.org/idea/community.git
Diffstat (limited to 'plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRootAboveTest.java')
-rw-r--r--plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRootAboveTest.java181
1 files changed, 181 insertions, 0 deletions
diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRootAboveTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRootAboveTest.java
new file mode 100644
index 000000000000..9bb89bf28008
--- /dev/null
+++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnRootAboveTest.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.idea.svn;
+
+import com.intellij.openapi.vcs.VcsDirectoryMapping;
+import com.intellij.openapi.vcs.changes.ChangeListManager;
+import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SvnRootAboveTest extends Svn17TestCase {
+ private ProjectLevelVcsManagerImpl myProjectLevelVcsManager;
+ private ChangeListManager myClManager;
+
+ private File myLocalWcRoot;
+ private File myProjectRoot;
+ private File myModuleRoot;
+
+ @Override
+ public void setUp() throws Exception {
+ /*final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
+ myTempDirFixture = fixtureFactory.createTempDirTestFixture();
+ myTempDirFixture.setUp();
+
+ final File svnRoot = new File(myTempDirFixture.getTempDirPath(), "svnroot");
+ svnRoot.mkdir();
+
+ File pluginRoot = new File(PluginPathManager.getPluginHomePath("svn4idea"));
+ if (!pluginRoot.isDirectory()) {
+ // try standalone mode
+ Class aClass = Svn16TestCase.class;
+ String rootPath = PathManager.getResourceRoot(aClass, "/" + aClass.getName().replace('.', '/') + ".class");
+ pluginRoot = new File(rootPath).getParentFile().getParentFile().getParentFile();
+ }
+ myClientBinaryPath = new File(pluginRoot, "testData/svn/bin");
+
+ ZipUtil.extract(new File(pluginRoot, "testData/svn/newrepo.zip"), svnRoot, null);
+
+ // real WC root
+ myLocalWcRoot = new File(myTempDirFixture.getTempDirPath(), "wcroot");
+ myLocalWcRoot.mkdir();
+
+ myRepoUrl = "file:///" + FileUtil.toSystemIndependentName(svnRoot.getPath());
+ verify(runSvn("co", myRepoUrl, myLocalWcRoot.getAbsolutePath()));
+
+ // one level below - project root dir
+ sleep100();
+ myProjectRoot = new File(myLocalWcRoot, "projectRoot");
+ myProjectRoot.mkdir();
+ // one more level below - content root
+ sleep100();
+ myModuleRoot = new File(myProjectRoot, "moduleRoot");
+ myModuleRoot.mkdir();
+ sleep100();
+
+ // set current directory
+ verify(runArbitrary("cd", new String[] {myProjectRoot.getAbsolutePath()}));
+ initProject(myModuleRoot);
+ verify(runArbitrary("cd", new String[] {myTempDirFixture.getTempDirPath()}));
+
+ myProjectLevelVcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(myProject);
+ myProjectLevelVcsManager.setDirectoryMapping(myLocalWcRoot.getAbsolutePath(), SvnVcs.VCS_NAME);
+ myProjectLevelVcsManager.updateActiveVcss();
+
+ final SvnVcs vcs = SvnVcs.getInstance(myProject);
+ ((SvnFileUrlMappingImpl) vcs.getSvnFileUrlMapping()).realRefresh(myRefreshCopiesStub);
+
+ myClManager = ChangeListManager.getInstance(myProject);*/
+ }
+
+ private class SubTree {
+ private final VirtualFile myOuterDir;
+ private final VirtualFile myOuterFile;
+ private final VirtualFile myRootDir;
+ private final VirtualFile myInnerFile;
+ private VirtualFile myNonVersionedUpper;
+ private final VirtualFile myMappingTarget;
+
+ private SubTree(final VirtualFile base, final VirtualFile projectRoot) throws Throwable {
+ // todo +-
+ myMappingTarget = projectRoot.getParent();
+ myOuterDir = createDirInCommand(myMappingTarget, "outer" + System.currentTimeMillis());
+ myOuterFile = createFileInCommand(myOuterDir, "outer.txt", "123");
+
+ myRootDir = createDirInCommand(base, "root");
+ myInnerFile = createFileInCommand(myRootDir, "inner.txt", "321");
+
+ myNonVersionedUpper = createFileInCommand(base, "nonVersioned.txt", "135");
+
+ // correct mappings
+ final List<VcsDirectoryMapping> mappings = myProjectLevelVcsManager.getDirectoryMappings();
+ final String basePath = base.getPath();
+ final List<VcsDirectoryMapping> newMappings = new ArrayList<VcsDirectoryMapping>(mappings.size());
+
+ for (VcsDirectoryMapping mapping : mappings) {
+ if (! basePath.equals(mapping.getDirectory())) {
+ newMappings.add(mapping);
+ }
+ }
+ newMappings.add(new VcsDirectoryMapping(myMappingTarget.getPath(), SvnVcs.VCS_NAME));
+ myProjectLevelVcsManager.setDirectoryMappings(newMappings);
+ myProjectLevelVcsManager.updateActiveVcss();
+ sleep100();
+ }
+
+ public void createNonVers() {
+ myNonVersionedUpper = createFileInCommand(myMappingTarget, "nonVersioned.txt", "135");
+ }
+ }
+
+ @Test
+ public void testSvnVcsRootAbove() throws Throwable {
+ /*enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
+ enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE);
+
+ final SubTree subTree = new SubTree(myWorkingCopyDir, myProject.getBaseDir());
+
+ checkin();
+
+ subTree.createNonVers();
+
+ editFileInCommand(myProject, subTree.myOuterFile, "***");
+ editFileInCommand(myProject, subTree.myInnerFile, "*&*");
+
+ VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
+ myClManager.ensureUpToDate(false);
+ DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(new VirtualFile[] {subTree.myOuterFile, subTree.myInnerFile},
+ myClManager.getDefaultListName(), myClManager);*/
+ }
+
+ @Test
+ public void testFakeScopeDontBreakTheView() throws Throwable {
+ /*enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
+ enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE);
+
+ final SubTree subTree = new SubTree(myWorkingCopyDir, myProject.getBaseDir());
+
+ checkin();
+
+ subTree.createNonVers();
+
+ editFileInCommand(myProject, subTree.myOuterFile, "***");
+ editFileInCommand(myProject, subTree.myInnerFile, "*&*");
+
+ VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
+ myClManager.ensureUpToDate(false);
+ DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(new VirtualFile[] {subTree.myOuterFile, subTree.myInnerFile},
+ myClManager.getDefaultListName(), myClManager);
+
+ VcsDirtyScopeManagerImpl.getInstance(myProject).fileDirty(subTree.myNonVersionedUpper);
+ myClManager.ensureUpToDate(false);
+ DuringChangeListManagerUpdateTestScheme.checkFilesAreInList(new VirtualFile[] {subTree.myOuterFile, subTree.myInnerFile},
+ myClManager.getDefaultListName(), myClManager);*/
+ }
+
+ private void sleep100() {
+ try {
+ Thread.sleep(100);
+ }
+ catch (InterruptedException e) {
+ //
+ }
+ }
+}