Skip to content

Commit

Permalink
Merge remote branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Iris24 committed Feb 1, 2013
2 parents 8c638a8 + 9ea564a commit ea601e1
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public final void invoke(@NotNull Project project, Editor editor, PsiFile file)

@Override
public final boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (file == null) return false;
final PsiManager manager = file.getManager();
if (manager == null) return false;
if (!manager.isInProject(file)) return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
Expand Down Expand Up @@ -124,7 +124,8 @@ public void choose(@Nullable VirtualFile toSelect, @NotNull Consumer<List<Virtua
show();
if (myChosenFiles.length > 0) {
callback.consume(Arrays.asList(myChosenFiles));
} else if (callback instanceof FileChooser.FileChooserConsumer){
}
else if (callback instanceof FileChooser.FileChooserConsumer) {
((FileChooser.FileChooserConsumer)callback).cancelled();
}
}
Expand Down Expand Up @@ -357,13 +358,21 @@ protected final void registerMouseListener(final ActionGroup group) {
myFileSystemTree.registerMouseListener(group);
}

@Nullable
private VirtualFile[] getSelectedFilesInt() {
if (myTreeIsUpdating || !myUiUpdater.isEmpty()) {
if (!isTextFieldActive() || StringUtil.isEmpty(myPathTextField.getTextFieldText()))
return VirtualFile.EMPTY_ARRAY;
final LocalFsFinder.VfsFile toFind = (LocalFsFinder.VfsFile)myPathTextField.getFile();
return toFind == null || !toFind.exists() ? VirtualFile.EMPTY_ARRAY : new VirtualFile[]{toFind.getFile()};
if (isTextFieldActive() && !StringUtil.isEmpty(myPathTextField.getTextFieldText())) {
LookupFile toFind = myPathTextField.getFile();
if (toFind instanceof LocalFsFinder.VfsFile && toFind.exists()) {
VirtualFile file = ((LocalFsFinder.VfsFile)toFind).getFile();
if (file != null) {
return new VirtualFile[]{file};
}
}
}
return VirtualFile.EMPTY_ARRAY;
}

final List<VirtualFile> selectedFiles = Arrays.asList(myFileSystemTree.getSelectedFiles());
return VfsUtilCore.toVirtualFileArray(FileChooserUtil.getChosenFiles(myChooserDescriptor, selectedFiles));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import static com.intellij.util.containers.ContainerUtil.*;
Expand Down Expand Up @@ -83,6 +84,7 @@ protected NotificationGroup compute() {

private final ManagingFS myManagingFS;
private final File myExecutable;
private final AtomicBoolean myInitialized = new AtomicBoolean(false);
private volatile MyProcessHandler myProcessHandler;
private volatile int myStartAttemptCount = 0;
private volatile boolean myIsShuttingDown = false;
Expand All @@ -101,12 +103,21 @@ public static FileWatcher getInstance() {
myExecutable = getExecutable();

if (disabled) {
myInitialized.set(true);
LOG.info("Native file watcher is disabled");
}
else if (myExecutable == null) {
myInitialized.set(true);
LOG.info("Native file watcher is not supported on this platform");
}
else if (!myExecutable.exists()) {
}

private void init() {
if (!myInitialized.compareAndSet(false, true)) {
return;
}

if (!myExecutable.exists()) {
notifyOnFailure(ApplicationBundle.message("watcher.exe.not.found"), null);
}
else if (!myExecutable.canExecute()) {
Expand Down Expand Up @@ -244,7 +255,7 @@ private void shutdownProcess() {
}

public boolean isOperational() {
return myProcessHandler != null;
return !myInitialized.get() || myProcessHandler != null;
}

public boolean isSettingRoots() {
Expand Down Expand Up @@ -280,6 +291,7 @@ public List<String> getManualWatchRoots() {
}

public void setWatchRoots(final List<String> recursive, final List<String> flat) {
init();
setWatchRoots(recursive, flat, false);
}

Expand Down Expand Up @@ -309,8 +321,7 @@ private void setWatchRoots(List<String> recursive, List<String> flat, final bool
writeLine("#");
}
catch (IOException e) {
LOG.error(e);
shutdownProcess();
LOG.warn(e);
}

myRecursiveWatchRoots = recursive;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
Expand Down Expand Up @@ -159,7 +159,7 @@ protected void closeStreams() {
myProcess.getOutputStream().close();
}
catch (IOException e) {
LOG.error(e);
LOG.warn(e);
}
}

Expand Down
8 changes: 0 additions & 8 deletions plugins/hg4idea/src/org/zmlx/hg4idea/HgPlatformFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,4 @@ public interface HgPlatformFacade extends DvcsPlatformFacade {
@NotNull
HgVcs getVcs(@NotNull Project project);

@NotNull
HgRepositoryManager getRepositoryManager(@NotNull Project project);

//@NotNull
//HgProjectSettings getSettings(Project project);
//
//@NotNull
//HgCommandResultNotifier getNotificator(@NotNull Project project);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
*/
public class HgPlatformFacadeImpl extends DvcsPlatformFacadeImpl implements HgPlatformFacade {

@NotNull
@Override
public HgRepositoryManager getRepositoryManager(@NotNull Project project) {
throw new UnsupportedOperationException();
}

@NotNull
@Override
public HgVcs getVcs(@NotNull Project project) {
Expand Down
32 changes: 0 additions & 32 deletions plugins/hg4idea/src/org/zmlx/hg4idea/HgRepositoryManager.java

This file was deleted.

24 changes: 5 additions & 19 deletions plugins/hg4idea/testSrc/hg4idea/test/HgExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@

import com.intellij.dvcs.test.Executor;
import com.intellij.openapi.util.text.StringUtil;
import org.zmlx.hg4idea.provider.HgRepositoryLocation;

import java.util.Arrays;
import java.util.List;

/**
* @author Nadya Zabrodina
*/
class HgExecutor extends Executor {
public class HgExecutor extends Executor {

private static final String HG_EXECUTABLE_ENV = "IDEA_TEST_HG_EXECUTABLE";
//private static final String TEAMCITY_HG_EXECUTABLE_ENV = "TEAMCITY_HG_PATH"; //todo var for server testing
Expand All @@ -37,31 +36,18 @@ private static String findHgExecutable() {
return findExecutable("hg", "hg", "hg.exe", Arrays.asList(HG_EXECUTABLE_ENV));
}

public String hg(String command) {
public static String hg(String command) {
printVersionTheFirstTime();
List<String> split = StringUtil.split(command, " ");
split.add(0, HG_EXECUTABLE);
log("hg " + command);
for (int attempt = 0; attempt < 3; attempt++) {
String stdout = run(split);
return stdout;
for(int attempt = 0; attempt < 3; attempt++) {
return run(split);
}
throw new RuntimeException("fatal error during execution of Hg command: " + command);
}


public String hg(HgRepositoryLocation repository, String command) {
if (repository != null) {
cd(repository);
}
return hg(command);
}

public void cd(HgRepositoryLocation repository) {
cd(repository.getRoot().getPath());
}

private void printVersionTheFirstTime() {
private static void printVersionTheFirstTime() {
if (!myVersionPrinted) {
myVersionPrinted = true;
hg("version");
Expand Down
24 changes: 13 additions & 11 deletions plugins/hg4idea/testSrc/hg4idea/test/HgLightTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package hg4idea.test;

import com.intellij.dvcs.test.Executor;
import com.intellij.dvcs.test.MockProject;
import com.intellij.dvcs.test.MockVirtualFile;
import com.intellij.openapi.application.PluginPathManager;
Expand All @@ -33,7 +34,7 @@
/**
* @author Nadya Zabrodina
*/
public class HgLightTest extends HgExecutor {
public class HgLightTest {

//private static final String USER_NAME = "John Doe";
//private static final String USER_EMAIL = "[email protected]";
Expand Down Expand Up @@ -62,13 +63,14 @@ public void setUp() {
catch (IOException e) {
fail("Can not start test case!\n"); //todo change
}
cd(myTestRoot);
myProjectRoot = mkdir("project");
Executor.cd(myTestRoot);
myProjectRoot = Executor.mkdir("project");
myProject = new MockProject(myProjectRoot);
myPlatformFacade = new HgTestPlatformFacade();
cd(".hg");
Executor.cd(".hg");
File pluginRoot = new File(PluginPathManager.getPluginHomePath("hg4idea"));
File hgrcFile = new File(new File(pluginRoot, "testData\\repo\\dot_hg"), "hgrc");
String pathToHgrc = "testData\\repo\\dot_hg";
File hgrcFile = new File(new File(pluginRoot, FileUtil.toSystemIndependentName(pathToHgrc)), "hgrc");
File hgrc = new File(new File(myProjectRoot, ".hg"), "hgrc");
try {
FileUtil.copy(hgrcFile, hgrc);
Expand Down Expand Up @@ -96,11 +98,11 @@ protected MockVirtualFile createRepository(String rootDir) {
return new MockVirtualFile(rootDir);
}

private void initRepo(String repoRoot) {
cd(repoRoot);
hg("init");
touch("file.txt");
hg("add file.txt");
hg("commit -m initial");
private static void initRepo(String repoRoot) {
Executor.cd(repoRoot);
HgExecutor.hg("init");
Executor.touch("file.txt");
HgExecutor.hg("add file.txt");
HgExecutor.hg("commit -m initial");
}
}
7 changes: 1 addition & 6 deletions plugins/hg4idea/testSrc/hg4idea/test/HgMockVcsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,7 @@ public VirtualFile[] getAllVersionedRoots() {
@NotNull
@Override
public VcsRoot[] getAllVcsRoots() {
List<VcsRoot> vcsRoots = new ArrayList<VcsRoot>();
List<VirtualFile> repositories = myPlatformFacade.getRepositoryManager(myProject).getRepositories();
for (VirtualFile repository : repositories) {
vcsRoots.add(new VcsRoot(getVcsFor(repository), repository));
}
return vcsRoots.toArray(new VcsRoot[0]);
throw new UnsupportedOperationException();
}

@Override
Expand Down
19 changes: 6 additions & 13 deletions plugins/hg4idea/testSrc/hg4idea/test/HgTestPlatformFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.*;
import org.zmlx.hg4idea.HgGlobalSettings;
import org.zmlx.hg4idea.HgPlatformFacade;
import org.zmlx.hg4idea.HgProjectSettings;
import org.zmlx.hg4idea.HgVcs;

/**
* @author Nadya Zabrodina
*/
class HgTestPlatformFacade extends DvcsTestPlatformFacade implements HgPlatformFacade {
public class HgTestPlatformFacade extends DvcsTestPlatformFacade implements HgPlatformFacade {
private HgMockVcs myVcs;
private HgMockVcsManager myVcsManager;
private HgTestRepositoryManager myRepositoryManager;

HgTestPlatformFacade() {
myRepositoryManager = new HgTestRepositoryManager();
}

@NotNull
@Override
Expand All @@ -44,6 +42,7 @@ public HgVcs getVcs(@NotNull Project project) {
return myVcs;
}


@NotNull
@Override
public ProjectLevelVcsManager getVcsManager(@NotNull Project project) {
Expand All @@ -58,11 +57,5 @@ public ProjectLevelVcsManager getVcsManager(@NotNull Project project) {
public void showDialog(@NotNull DialogWrapper dialog) {
throw new UnsupportedOperationException();
}

@NotNull
@Override
public HgRepositoryManager getRepositoryManager(@NotNull Project project) {
return myRepositoryManager;
}
}

41 changes: 0 additions & 41 deletions plugins/hg4idea/testSrc/hg4idea/test/HgTestRepositoryManager.java

This file was deleted.

Loading

0 comments on commit ea601e1

Please sign in to comment.