HgConfig tests added; static getRepositoryNamedConfig method added to Util class

This commit is contained in:
Nadya Zabrodina
2013-07-02 17:39:37 +04:00
parent 263543889e
commit fdc93f5d7f
2 changed files with 52 additions and 0 deletions
@@ -567,4 +567,10 @@ public abstract class HgUtil {
HgRepository hgRepository = getRepositoryManager(project).getRepositoryForRoot(root);
return hgRepository != null ? hgRepository.getRepositoryConfig().getDefaultPushPath() : null;
}
@Nullable
public static String getRepositoryNamedConfig(@NotNull Project project, @NotNull VirtualFile root, @Nullable String configName) {
HgRepository hgRepository = getRepositoryManager(project).getRepositoryForRoot(root);
return hgRepository != null ? hgRepository.getRepositoryConfig().getNamedConfig(configName) : null;
}
}
@@ -0,0 +1,46 @@
package hg4idea.test.config;
import com.intellij.openapi.util.io.FileUtil;
import hg4idea.test.HgPlatformTest;
import org.zmlx.hg4idea.repo.HgRepository;
import org.zmlx.hg4idea.util.HgUtil;
import java.io.File;
import java.io.IOException;
import static com.intellij.dvcs.test.Executor.cd;
/**
* @author Nadya Zabrodina
*/
public class HgConfigTest extends HgPlatformTest {
@Override
public void setUp() throws Exception {
super.setUp();
prepareSecondRepository();
}
public void testDefaultPathInClonedRepo() {
cd(myChildRepo);
assertEquals(myRepository.getCanonicalPath(), HgUtil.getRepositoryDefaultPath(myProject, myChildRepo));
}
public void testLargeExtensionInClonedRepo() {
cd(myChildRepo);
File hgrc = new File(new File(myChildRepo.getPath(), ".hg"), "hgrc");
assert hgrc.exists();
try {
FileUtil.appendToFile(hgrc, "\n[extensions]\n" +
"largefiles =");
}
catch (IOException e) {
e.printStackTrace();
fail("Can not update hgrc file.");
}
HgRepository hgRepository = HgUtil.getRepositoryManager(myProject).getRepositoryForRoot(myChildRepo);
assertNotNull(hgRepository);
hgRepository.getRepositoryConfig().update(myProject, null);
assertNotNull(HgUtil.getRepositoryNamedConfig(myProject, myChildRepo, "extensions.largefiles"));
}
}