IJPL-204539 Ensure CLM is up to date in HG tests

Otherwise, files are not automatically added to HG

GitOrigin-RevId: a04b4fd6f51bc76c011953e736b9d10b61c0af26
This commit is contained in:
Ilia.Shulgin
2025-08-28 15:35:30 +02:00
committed by intellij-monorepo-bot
parent e7020183e0
commit 6e9782947f
5 changed files with 41 additions and 5 deletions

View File

@@ -29,19 +29,23 @@ public class HgCopyTest extends HgSingleUserTest {
@Test
public void testCopyUnmodifiedFile() throws Exception {
VirtualFile file = createFileInCommand("a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
copyFileInCommand(file, "b.txt");
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.added("b.txt"));
}
@Test
public void testCopyModifiedFile() throws Exception {
VirtualFile file = createFileInCommand("a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
append(new File(file.getPath()), "newer content");
file.refresh(false, true);
verifyStatus(HgTestOutputParser.modified("a.txt"));
copyFileInCommand(file, "b.txt");
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.modified("a.txt"), HgTestOutputParser.added("b.txt"));
}
@@ -49,15 +53,19 @@ public class HgCopyTest extends HgSingleUserTest {
public void testCopyUnversionedFile() throws Exception {
VirtualFile file = makeFile(new File(myWorkingCopyDir.getPath(), "a.txt"));
copyFileInCommand(file, "b.txt");
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.added("b.txt"), HgTestOutputParser.unknown("a.txt"));
}
@Test
public void testCopyCopiedFile() throws Exception {
VirtualFile file = createFileInCommand("a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
copyFileInCommand(file, "b.txt");
myChangeListManager.ensureUpToDate();
copyFileInCommand(file, "c.txt");
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.added("b.txt"), HgTestOutputParser.added("c.txt"));
}
@@ -65,8 +73,10 @@ public class HgCopyTest extends HgSingleUserTest {
public void testCopyDirWithFiles() throws Exception {
VirtualFile parent = createDirInCommand(myWorkingCopyDir, "com");
createFileInCommand(parent, "a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
copyDir(parent, "org");
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.added("org", "a.txt"));
}

View File

@@ -29,8 +29,10 @@ public class HgDeleteTest extends HgSingleUserTest {
@Test
public void testDeleteUnmodifiedFile() throws Exception {
VirtualFile file = createFileInCommand("a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
deleteFileInCommand(file);
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.removed("a.txt"));
}
@@ -52,11 +54,13 @@ public class HgDeleteTest extends HgSingleUserTest {
@Test
public void testDeleteModifiedFile() throws Exception {
VirtualFile file = createFileInCommand("a.txt", "new file content");
runHgOnProjectRepo("commit", "-m", "added file");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
overwrite(VfsUtilCore.virtualToIoFile(file), "even newer content");
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.modified("a.txt"));
deleteFileInCommand(file);
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.removed("a.txt"));
}
@@ -64,8 +68,10 @@ public class HgDeleteTest extends HgSingleUserTest {
public void testDeleteDirWithFiles() throws Exception {
VirtualFile parent = createDirInCommand(myWorkingCopyDir, "com");
createFileInCommand(parent, "a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
deleteFileInCommand(parent);
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.removed("com", "a.txt"));
}
@@ -101,8 +107,10 @@ public class HgDeleteTest extends HgSingleUserTest {
@Test
public void testJustDeletedAndThenAddedFileShouldNotBePromptedForRemoval() {
VirtualFile vf = createFileInCommand("a.txt", null);
myChangeListManager.ensureUpToDate();
myChangeListManager.commitFiles(vf);
deleteFileInCommand(vf);
myChangeListManager.ensureUpToDate();
myChangeListManager.commitFiles(vf);
showConfirmation(VcsConfiguration.StandardConfirmation.REMOVE);

View File

@@ -12,10 +12,12 @@
// limitations under the License.
package org.zmlx.hg4idea.test;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.junit.Test;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
public class HgMoveTest extends HgSingleUserTest {
@@ -26,6 +28,7 @@ public class HgMoveTest extends HgSingleUserTest {
VirtualFile parent2 = createDirInCommand(myWorkingCopyDir, "org");
moveFileInCommand(file, parent2);
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.added("org", "a.txt"));
}
@@ -34,10 +37,12 @@ public class HgMoveTest extends HgSingleUserTest {
public void testMoveUnchangedFile() throws Exception {
VirtualFile parent1 = createDirInCommand(myWorkingCopyDir, "com");
VirtualFile file = createFileInCommand(parent1, "a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
VirtualFile parent2 = createDirInCommand(myWorkingCopyDir, "org");
moveFileInCommand(file, parent2);
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.added("org", "a.txt"), HgTestOutputParser.removed("com", "a.txt"));
}
@@ -47,10 +52,12 @@ public class HgMoveTest extends HgSingleUserTest {
VirtualFile parent1 = createDirInCommand(myWorkingCopyDir, "com");
VirtualFile dir = createDirInCommand(parent1, "zzz");
createFileInCommand(dir, "a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
VirtualFile parent2 = createDirInCommand(myWorkingCopyDir, "org");
moveFileInCommand(dir, parent2);
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.added("org", "zzz", "a.txt"), HgTestOutputParser.removed("com", "zzz", "a.txt"));
}
@@ -59,13 +66,16 @@ public class HgMoveTest extends HgSingleUserTest {
public void testMoveUnversionedFile() throws Exception {
VirtualFile parent1 = createDirInCommand(myWorkingCopyDir, "com");
File unversionedFile = new File(parent1.getPath(), "a.txt");
VirtualFile file = makeFile(unversionedFile);
Path unversionedFileNio = parent1.toNioPath().resolve("a.txt");
Files.writeString(unversionedFileNio, "unversioned file content");
VirtualFile unversionedFile = LocalFileSystem.getInstance().refreshAndFindFileByNioFile(unversionedFileNio);
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.unknown("com", "a.txt"));
VirtualFile parent2 = createDirInCommand(myWorkingCopyDir, "org");
moveFileInCommand(file, parent2);
moveFileInCommand(unversionedFile, parent2);
myChangeListManager.ensureUpToDate();
verifyStatus(HgTestOutputParser.unknown("org", "a.txt"));
}

View File

@@ -25,6 +25,7 @@ public class HgRenameTest extends HgSingleUserTest {
@Test
public void testRenameUnmodifiedFile() throws Exception {
VirtualFile file = createFileInCommand("a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
myChangeListManager.ensureUpToDate();
renameFileInCommand(file, "b.txt");
@@ -35,6 +36,7 @@ public class HgRenameTest extends HgSingleUserTest {
@Test
public void testRenameModifiedFile() throws Exception {
VirtualFile file = createFileInCommand("a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
myChangeListManager.ensureUpToDate();
overwrite(VfsUtilCore.virtualToIoFile(file), "modified new file content");
@@ -55,6 +57,7 @@ public class HgRenameTest extends HgSingleUserTest {
@Test
public void testRenameRenamedFile() throws Exception {
VirtualFile file = createFileInCommand("a.txt", "new file content");
myChangeListManager.ensureUpToDate();
runHgOnProjectRepo("commit", "-m", "added file");
myChangeListManager.ensureUpToDate();
renameFileInCommand(file, "b.txt");

View File

@@ -123,6 +123,7 @@ public class HgUpdateTest extends HgCollaborativeTest {
updateCommand.execute();
createFileInCommand(projectRepoVirtualFile.findChild("com"),"c.txt", "updated content");
myChangeListManager.ensureUpToDate();
runHg(projectRepo, "commit", "-m", "creating new local head");
List<HgRevisionNumber> branchHeads = new HgHeadsCommand(myProject, projectRepoVirtualFile).executeInCurrentThread();
@@ -140,6 +141,7 @@ public class HgUpdateTest extends HgCollaborativeTest {
@Test
public void localChangesShouldBeAllowedWithFastForwardUpdate() throws Exception{
createFileInCommand(projectRepoVirtualFile.findChild("com"), "b.txt", "other file");
myChangeListManager.ensureUpToDate();
runHg(projectRepo, "commit", "-m", "adding second file");
runHg(projectRepo, "push");
@@ -247,6 +249,7 @@ public class HgUpdateTest extends HgCollaborativeTest {
HgRevisionNumber parentBeforeUpdate = new HgWorkingCopyRevisionsCommand(myProject).parents(projectRepoVirtualFile).get(0);
VcsTestUtil.editFileInCommand(myProject, projectRepoVirtualFile.findFileByRelativePath("com/a.txt"), "modified file contents");
myChangeListManager.ensureUpToDate();
assertUpdateThroughPluginFails();
@@ -271,6 +274,7 @@ public class HgUpdateTest extends HgCollaborativeTest {
private void createAndCommitNewFileInLocalRepository() throws IOException {
createFileInCommand(projectRepoVirtualFile.findChild("com"), "b.txt", "other file");
myChangeListManager.ensureUpToDate();
runHg(projectRepo, "commit", "-m", "adding non-conflicting history to local repository");
}
@@ -289,6 +293,7 @@ public class HgUpdateTest extends HgCollaborativeTest {
private void changeFile_A_AndCommitInRemoteRepository() throws IOException {
fillFile(remoteRepo, new String[]{"com", "a.txt"}, "update file contents");
myChangeListManager.ensureUpToDate();
runHg(remoteRepo, "commit", "-m", "Adding history to remote repository");
assertEquals("The remote repository should have gotten new history", 1, determineNumberOfIncomingChanges(projectRepo));