mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[hg] : clean tests; change QueueProcessor to MergingUpdateQueue in HgRepositoryUpdater
* tests should become more stable, but not fixed yet
This commit is contained in:
@@ -23,9 +23,10 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.concurrency.QueueProcessor;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.ui.update.MergingUpdateQueue;
|
||||
import com.intellij.util.ui.update.Update;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -38,15 +39,18 @@ import java.util.List;
|
||||
final class HgRepositoryUpdater implements Disposable, BulkFileListener {
|
||||
@NotNull private final HgRepositoryFiles myRepositoryFiles;
|
||||
@Nullable private final MessageBusConnection myMessageBusConnection;
|
||||
@NotNull private final QueueProcessor<Object> myUpdateQueue;
|
||||
@NotNull private final MergingUpdateQueue myUpdateQueue;
|
||||
@Nullable private final VirtualFile myBranchHeadsDir;
|
||||
private static final int TIME_SPAN = 300;
|
||||
@Nullable private VirtualFile myMqDir;
|
||||
@Nullable private final LocalFileSystem.WatchRequest myWatchRequest;
|
||||
@NotNull private final QueueProcessor<Object> myUpdateConfigQueue;
|
||||
@NotNull private final MergingUpdateQueue myUpdateConfigQueue;
|
||||
private final HgRepository myRepository;
|
||||
|
||||
|
||||
HgRepositoryUpdater(@NotNull final HgRepository repository) {
|
||||
VirtualFile hgDir = repository.getHgDir();
|
||||
myRepository = repository;
|
||||
VirtualFile hgDir = myRepository.getHgDir();
|
||||
myWatchRequest = LocalFileSystem.getInstance().addRootToWatch(hgDir.getPath(), true);
|
||||
myRepositoryFiles = HgRepositoryFiles.getInstance(hgDir);
|
||||
DvcsUtil.visitVcsDirVfs(hgDir, HgRepositoryFiles.getSubDirRelativePaths());
|
||||
@@ -55,13 +59,8 @@ final class HgRepositoryUpdater implements Disposable, BulkFileListener {
|
||||
myMqDir = VcsUtil.getVirtualFile(myRepositoryFiles.getMQDirPath());
|
||||
|
||||
Project project = repository.getProject();
|
||||
myUpdateQueue = new QueueProcessor<Object>(new DvcsUtil.Updater(repository), project.getDisposed());
|
||||
myUpdateConfigQueue = new QueueProcessor<Object>(new Consumer<Object>() {
|
||||
@Override
|
||||
public void consume(Object dummy) {
|
||||
repository.updateConfig();
|
||||
}
|
||||
}, project.getDisposed());
|
||||
myUpdateQueue = new MergingUpdateQueue("HgRepositoryUpdate", TIME_SPAN, true, null, this, null, Alarm.ThreadToUse.POOLED_THREAD);
|
||||
myUpdateConfigQueue = new MergingUpdateQueue("HgConfigUpdate", TIME_SPAN, true, null, this, null, Alarm.ThreadToUse.POOLED_THREAD);
|
||||
if (!project.isDisposed()) {
|
||||
myMessageBusConnection = project.getMessageBus().connect();
|
||||
myMessageBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, this);
|
||||
@@ -76,6 +75,8 @@ final class HgRepositoryUpdater implements Disposable, BulkFileListener {
|
||||
if (myWatchRequest != null) {
|
||||
LocalFileSystem.getInstance().removeWatchedRoot(myWatchRequest);
|
||||
}
|
||||
myUpdateQueue.cancelAllUpdates();
|
||||
myUpdateConfigQueue.cancelAllUpdates();
|
||||
if (myMessageBusConnection != null) {
|
||||
myMessageBusConnection.disconnect();
|
||||
}
|
||||
@@ -149,10 +150,26 @@ final class HgRepositoryUpdater implements Disposable, BulkFileListener {
|
||||
if (branchHeadsChanged || branchFileChanged || dirstateFileChanged || mergeFileChanged || rebaseFileChanged ||
|
||||
bookmarksFileChanged || currentBookmarkFileChanged || tagsFileChanged || localTagsFileChanged ||
|
||||
mqChanged) {
|
||||
myUpdateQueue.add(Void.TYPE);
|
||||
myUpdateQueue.queue(new MyUpdater("hgrepositoryUpdate"));
|
||||
}
|
||||
if (configHgrcChanged) {
|
||||
myUpdateConfigQueue.add(Void.TYPE);
|
||||
myUpdateConfigQueue.queue(new MyUpdater("hgconfigUpdate"));
|
||||
}
|
||||
}
|
||||
|
||||
private class MyUpdater extends Update {
|
||||
public MyUpdater(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEat(Update update) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
myRepository.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.intellij.openapi.vcs.VcsTestUtil;
|
||||
import hg4idea.test.HgPlatformTest;
|
||||
import org.zmlx.hg4idea.util.HgUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -89,10 +88,8 @@ public class HgConfigTest extends HgPlatformTest {
|
||||
|
||||
public void testLargeExtensionInClonedRepo() throws IOException {
|
||||
cd(myChildRepo);
|
||||
File hgrc = new File(new File(myChildRepo.getPath(), ".hg"), "hgrc");
|
||||
assert hgrc.exists();
|
||||
FileUtil.appendToFile(hgrc, "\n[extensions]\n" +
|
||||
"largefiles =");
|
||||
appendToHgrc(myChildRepo, "\n[extensions]\n" +
|
||||
"largefiles =");
|
||||
updateRepoConfig(myProject, myChildRepo);
|
||||
assertNotNull(HgUtil.getConfig(myProject, myChildRepo, "extensions", "largefiles"));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package hg4idea.test.history;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.annotate.FileAnnotation;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
@@ -40,8 +39,7 @@ public class HgAnnotationTest extends HgPlatformTest {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
cd(myRepository);
|
||||
File hgrc = new File(new File(myRepository.getPath(), ".hg"), "hgrc");
|
||||
FileUtil.appendToFile(hgrc, "[extensions]\n" +
|
||||
appendToHgrc(myRepository, "[extensions]\n" +
|
||||
"largefiles=!\n");
|
||||
touch(aName, "a1");
|
||||
myRepository.refresh(false, true);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package hg4idea.test.history;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -34,9 +33,6 @@ import java.util.List;
|
||||
import static com.intellij.openapi.vcs.Executor.*;
|
||||
import static hg4idea.test.HgExecutor.hg;
|
||||
|
||||
/**
|
||||
* @author Nadya Zabrodina
|
||||
*/
|
||||
public class HgHistoryTest extends HgPlatformTest {
|
||||
static final String[] names = {"f1.txt", "f2.txt", "f3.txt"};
|
||||
static final String subDirName = "sub";
|
||||
@@ -45,8 +41,7 @@ public class HgHistoryTest extends HgPlatformTest {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
cd(myRepository);
|
||||
File hgrc = new File(new File(myRepository.getPath(), ".hg"), "hgrc");
|
||||
FileUtil.appendToFile(hgrc, "[extensions]\n" +
|
||||
appendToHgrc(myRepository, "[extensions]\n" +
|
||||
"largefiles=!\n");
|
||||
mkdir(subDirName);
|
||||
cd(subDirName);
|
||||
|
||||
@@ -61,8 +61,8 @@ public class MqPatchTest extends HgPlatformTest {
|
||||
updateRepoConfig(myProject, myRepository);
|
||||
|
||||
hg("qinit");
|
||||
touch(FILENAME, "f1");
|
||||
hg("branch " + BRANCH);
|
||||
touch(FILENAME, "f1");
|
||||
myRepository.refresh(false, true);
|
||||
hg("add " + FILENAME);
|
||||
hg("commit -m \'" + MESSAGE + "\'");
|
||||
@@ -84,7 +84,9 @@ public class MqPatchTest extends HgPlatformTest {
|
||||
public void testMqPatchInfoAfterQNew() throws Exception {
|
||||
cd(myRepository);
|
||||
append(FILENAME, "modify");
|
||||
myRepository.refresh(false,true);
|
||||
new HgQNewCommand(myProject, myHgRepository, MESSAGE, false).execute();
|
||||
myRepository.refresh(false,true);
|
||||
MqPatchDetails patchDetails = updateAndGetDetails();
|
||||
assertEqualsCommitInfo(null, patchDetails);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user