svn: Fix tests - update vcs mappings after configuring externals

GitOrigin-RevId: fb5cddf5e94f2ab0abdb578c60c5a13eef1f76cb
This commit is contained in:
Konstantin Kolosovsky
2020-05-11 12:00:59 +00:00
committed by intellij-monorepo-bot
parent a81cf72dac
commit 59c0c9c8f4
2 changed files with 15 additions and 20 deletions
@@ -1,9 +1,8 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.svn;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsDirectoryMapping;
import com.intellij.openapi.vcs.changes.Change;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -11,11 +10,8 @@ import org.jetbrains.idea.svn.api.Url;
import org.junit.Test;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import static com.intellij.openapi.util.io.FileUtil.toSystemIndependentName;
import static com.intellij.testFramework.EdtTestUtil.runInEdtAndWait;
import static com.intellij.util.containers.ContainerUtil.ar;
import static com.intellij.util.containers.ContainerUtil.map;
import static org.hamcrest.CoreMatchers.equalTo;
@@ -115,21 +111,14 @@ public class SvnExternalTest extends SvnTestCase {
}
private void updatedCreatedExternalFromIDEAImpl() {
final File sourceDir = new File(myWorkingCopyDir.getPath(), "source");
setNewDirectoryMappings(sourceDir);
imitUpdate();
final File sourceDir = new File(myWorkingCopyDir.getPath(), "source");
final File externalFile = new File(sourceDir, "external/t11.txt");
final VirtualFile externalVf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(externalFile);
assertNotNull(externalVf);
}
private void setNewDirectoryMappings(final File sourceDir) {
runInEdtAndWait(
() -> vcsManager.setDirectoryMappings(
Arrays.asList(new VcsDirectoryMapping(toSystemIndependentName(sourceDir.getPath()), vcs.getName()))));
}
@Test
public void testUncommittedExternalStatus() throws Exception {
prepareExternal(false, true, false);
@@ -168,7 +157,6 @@ public class SvnExternalTest extends SvnTestCase {
}
private void uncommittedExternalCopyIsDetectedImpl() {
setNewDirectoryMappings(new File(myWorkingCopyDir.getPath(), "source"));
imitUpdate();
refreshSvnMappingsSynchronously();
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.svn;
import com.intellij.diagnostic.ThreadDumper;
@@ -15,10 +15,7 @@ import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TestDialog;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.VcsShowConfirmationOption;
import com.intellij.openapi.vcs.*;
import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl;
import com.intellij.openapi.vcs.rollback.RollbackProgressListener;
@@ -64,6 +61,7 @@ import static com.intellij.testFramework.UsefulTestCase.assertExists;
import static com.intellij.util.ObjectUtils.notNull;
import static com.intellij.util.containers.ContainerUtil.map2Array;
import static com.intellij.util.lang.CompoundRuntimeException.throwIfNotEmpty;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.jetbrains.idea.svn.SvnUtil.parseUrl;
import static org.junit.Assert.*;
@@ -393,8 +391,10 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
runInAndVerifyIgnoreOutput("ci", "-m", "test", sourceDir.getPath());
}
refreshVfs();
setNewDirectoryMappings(sourceDir);
if (updateExternal) {
refreshVfs();
assertExists(new File(sourceDir, "external"));
}
});
@@ -407,6 +407,13 @@ public abstract class SvnTestCase extends AbstractJunitVcsTestCase {
refreshSvnMappingsSynchronously();
}
private void setNewDirectoryMappings(@NotNull File directory) {
runInEdtAndWait(() -> {
VcsDirectoryMapping mapping = new VcsDirectoryMapping(toSystemIndependentName(directory.getPath()), vcs.getName());
vcsManager.setDirectoryMappings(singletonList(mapping));
});
}
protected void createAnotherRepo() throws Exception {
File repo = virtualToIoFile(myTempDirFixture.findOrCreateDir("anotherRepo"));
copyDir(myRepoRoot, repo);