Mercurial > hg > mercurial
changeset 410:e182bb6b5921 Eluru-6.5.x
Don't use pull protocol in clone, do clone whenever it is possible
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Sat, 03 Mar 2012 12:28:29 +0400 |
parents | b0802861feaa |
children | |
files | mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfig.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfigImpl.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java |
diffstat | 7 files changed, 115 insertions(+), 165 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java Sat Feb 18 22:10:29 2012 +0400 +++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java Sat Mar 03 12:28:29 2012 +0400 @@ -34,7 +34,9 @@ import java.io.IOException; import java.util.Collections; +import static java.util.Collections.singleton; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandUtil.removePrivateData; +import static jetbrains.buildServer.util.FileUtil.isEmptyDir; public class MercurialAgentSideVcsSupport extends AgentVcsSupport implements UpdateByIncludeRules2 { @@ -82,39 +84,25 @@ return this; } - private void initRepository(File workingDir, Settings settings, BuildProgressLogger logger, boolean useLocalMirrors) throws VcsException { - try { - String defaultPullUrl = getDefaultPullUrl(settings, useLocalMirrors); - logger.message("Init repository at " + workingDir.getAbsolutePath() + ", remote repository is " + - removePrivateData(defaultPullUrl, Collections.singleton(settings.getPassword()))); - new Init(settings, workingDir, defaultPullUrl).execute(); - } catch (IOException e) { - throw new VcsException("Error while initializing repository at " + workingDir.getAbsolutePath(), e); - } - } - private void updateRepository(File workingDir, Settings settings, BuildProgressLogger logger, AgentPluginConfig config) throws VcsException, IOException { - if (!Settings.isValidRepository(workingDir)) { - initRepository(workingDir, settings, logger, config.isUseLocalMirrors()); + String defaultPullUrl = getDefaultPullUrl(settings, config.isUseLocalMirrors()); + if (isEmptyDir(workingDir)) {//can do clone only in empty dir + logger.message("Start cloning from " + removePrivateData(defaultPullUrl, singleton(settings.getPassword()))); + CloneCommand clone = new CloneCommand(settings, workingDir); + clone.setRepository(defaultPullUrl); + clone.setUpdateWorkingDir(false); + clone.setUseUncompressedTransfer(!config.isUseLocalMirrors() && settings.isUncompressedTransfer()); + clone.execute(); + writeDefaultPath(workingDir, settings.getRepository()); + logger.message("Repository successfully cloned"); } else { - ensureUseRightRepository(workingDir, settings, logger, config.isUseLocalMirrors()); - } - String defaultPullUrl = getDefaultPullUrl(settings, config.isUseLocalMirrors()); - logger.message("Start pulling changes from " + removePrivateData(defaultPullUrl, Collections.singleton(settings.getPassword()))); - new PullCommand(settings, workingDir, defaultPullUrl).execute(config.getPullTimeout()); - logger.message("Changes successfully pulled"); - } - - private void ensureUseRightRepository(File workingDir, Settings settings, BuildProgressLogger logger, boolean useLocalMirrors) throws VcsException { - boolean clonedFromWrongRepository = useLocalMirrors && !isClonedFromLocalMirror(settings, workingDir) - || !useLocalMirrors && isClonedFromLocalMirror(settings, workingDir); - - if (clonedFromWrongRepository) { - String rightRepository = useLocalMirrors ? "local mirror" : "remote repository"; - String wrongRepository = useLocalMirrors ? "remote repository" : "local mirror"; - logger.message("Repository in working directory is cloned from " + wrongRepository + ", clone it from " + rightRepository); - FileUtil.delete(workingDir); - initRepository(workingDir, settings, logger, useLocalMirrors); + if (!Settings.isValidRepository(workingDir)) { + logger.message("Init repository at " + workingDir.getAbsolutePath()); + new Init(settings, workingDir, settings.getRepository()).execute(); + } + logger.message("Start pulling changes from " + removePrivateData(defaultPullUrl, Collections.singleton(settings.getPassword()))); + new PullCommand(settings, workingDir, defaultPullUrl).execute(config.getPullTimeout()); + logger.message("Changes successfully pulled"); } } @@ -122,13 +110,24 @@ Settings settings = new Settings(root); File mirrorDir = myMirrorManager.getMirrorDir(settings.getRepositoryUrl()); logger.message("Update local mirror at " + mirrorDir); - if (!Settings.isValidRepository(mirrorDir)) { - initRepository(mirrorDir, settings, logger, false); + if (isEmptyDir(mirrorDir)) { + logger.message("Start cloning from " + removePrivateData(settings.getRepository(), singleton(settings.getPassword()))); + CloneCommand clone = new CloneCommand(settings, mirrorDir); + clone.setUpdateWorkingDir(false); + clone.setUseUncompressedTransfer(settings.isUncompressedTransfer()); + clone.execute(); + writeDefaultPath(mirrorDir, settings.getRepository()); + logger.message("Repository successfully cloned"); + } else { + if (!Settings.isValidRepository(mirrorDir)) { + logger.message("Init repository at " + mirrorDir.getAbsolutePath()); + new Init(settings, mirrorDir, settings.getRepository()).execute(); + } + final String defaultPullUrl = getDefaultPullUrl(settings, true); + logger.message("Start pulling changes from " + removePrivateData(defaultPullUrl, Collections.singleton(settings.getPassword()))); + new PullCommand(settings, mirrorDir, settings.getRepositoryUrl()).execute(config.getPullTimeout()); + logger.message("Local mirror changes successfully pulled"); } - final String defaultPullUrl = getDefaultPullUrl(settings, true); - logger.message("Start pulling changes from " + removePrivateData(defaultPullUrl, Collections.singleton(settings.getPassword()))); - new PullCommand(settings, mirrorDir).execute(config.getPullTimeout()); - logger.message("Local mirror changes successfully pulled"); } private void updateWorkingDir(final Settings settings, File workingDir, @NotNull final String version, final BuildProgressLogger logger) throws VcsException { @@ -157,14 +156,9 @@ } } - public boolean isClonedFromLocalMirror(Settings settings, File workingDir) { - try { - File mirrorDir = myMirrorManager.getMirrorDir(settings.getRepositoryUrl()); - File hgrc = new File(workingDir, ".hg" + File.separator + "hgrc"); - String config = FileUtil.readText(hgrc); - return config.contains("default = " + mirrorDir.getCanonicalPath()); - } catch (Exception e) { - return false; - } + private void writeDefaultPath(@NotNull File workingDir, @NotNull String defaultPath) { + File hgrc = new File(new File(workingDir, ".hg"), "hgrc"); + String content = "[paths]\ndefault = " + defaultPath; + FileUtil.writeFile(hgrc, content); } }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java Sat Feb 18 22:10:29 2012 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java Sat Mar 03 12:28:29 2012 +0400 @@ -28,7 +28,7 @@ private boolean myUpdateWorkingDir = true; private String myRepository; private File myWorkingDir; - private boolean myUsePullProtocol = true; + private boolean myUseUncompressedTransfer = false; public CloneCommand(@NotNull Settings settings, @NotNull File workingDir) { super(settings, workingDir); @@ -52,8 +52,8 @@ myUpdateWorkingDir = updateWorkingDir; } - public void setUsePullProtocol(boolean usePullProtocol) { - myUsePullProtocol = usePullProtocol; + public void setUseUncompressedTransfer(boolean useUncompressedTransfer) { + myUseUncompressedTransfer = useUncompressedTransfer; } public void execute() throws VcsException { @@ -65,12 +65,10 @@ cli.addParameter("-r"); cli.addParameter(myToId); } - if (myUsePullProtocol) - cli.addParameter("--pull"); if (!myUpdateWorkingDir) { cli.addParameter("-U"); } - if (getSettings().isUncompressedTransfer()) { + if (myUseUncompressedTransfer) { cli.addParameter("--uncompressed"); } cli.addParameter(myRepository);
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Sat Feb 18 22:10:29 2012 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Sat Mar 03 12:28:29 2012 +0400 @@ -62,7 +62,7 @@ private VcsManager myVcsManager; private File myDefaultWorkFolderParent; private MirrorManager myMirrorManager; - private final ServerPluginConfig myConfig; + private final PluginConfig myConfig; private File myLogTemplate; private final FileFilter myIgnoreDotHgFilter = new IgnoreDotHgFilter(); private final FileFilter myAcceptAllFilter = new AcceptAllFilter(); @@ -71,7 +71,7 @@ @NotNull final ServerPaths paths, @NotNull final SBuildServer server, @NotNull final EventDispatcher<BuildServerListener> dispatcher, - @NotNull final ServerPluginConfig config) throws IOException { + @NotNull final PluginConfig config) throws IOException { myLogTemplate = createLogTemplate(paths.getPluginDataDirectory()); myVcsManager = vcsManager; myDefaultWorkFolderParent = new File(paths.getCachesDir(), "mercurial"); @@ -392,7 +392,7 @@ cl.setRepository(mirrorDir.getAbsolutePath()); cl.setToId(toVer.getId()); cl.setUpdateWorkingDir(false); - cl.setUsePullProtocol(myConfig.isUsePullProtocol()); + cl.setUseUncompressedTransfer(false); cl.execute(); UpdateCommand up = new UpdateCommand(settings, tempDir); @@ -465,6 +465,7 @@ } else { CloneCommand cl = new CloneCommand(settings, workingDir); cl.setUpdateWorkingDir(false); + cl.setUseUncompressedTransfer(settings.isUncompressedTransfer()); cl.execute(); } } finally { @@ -482,6 +483,7 @@ } else { CloneCommand cl = new CloneCommand(settings, workingDir); cl.setUpdateWorkingDir(false); + cl.setUseUncompressedTransfer(settings.isUncompressedTransfer()); cl.execute(); } } finally {
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfig.java Sat Feb 18 22:10:29 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -package jetbrains.buildServer.buildTriggers.vcs.mercurial; - -/** - * @author dmitry.neverov - */ -public interface ServerPluginConfig extends PluginConfig { - - public boolean isUsePullProtocol(); - -}
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfigImpl.java Sat Feb 18 22:10:29 2012 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfigImpl.java Sat Mar 03 12:28:29 2012 +0400 @@ -5,15 +5,11 @@ /** * @author dmitry.neverov */ -public class ServerPluginConfigImpl implements ServerPluginConfig { +public class ServerPluginConfigImpl implements PluginConfig { private static final String PULL_TIMEOUT_SECONDS = "teamcity.hg.pull.timeout.seconds"; public static final int DEFAULT_PULL_TIMEOUT_SECONDS = 3600; - public boolean isUsePullProtocol() { - return TeamCityProperties.getBooleanOrTrue("teamcity.hg.use.pull.protocol"); - } - public int getPullTimeout() { int timeout = TeamCityProperties.getInteger(PULL_TIMEOUT_SECONDS, DEFAULT_PULL_TIMEOUT_SECONDS); return timeout > 0 ? timeout : DEFAULT_PULL_TIMEOUT_SECONDS;
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java Sat Feb 18 22:10:29 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java Sat Mar 03 12:28:29 2012 +0400 @@ -26,6 +26,7 @@ import org.jmock.Expectations; import org.jmock.Mockery; import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.io.File; @@ -72,69 +73,51 @@ } - public void checkout_on_agent() throws IOException, VcsException { - testUpdate(createVcsRoot(simpleRepo()), "4:b06a290a363b", "cleanPatch1/after", new IncludeRule(".", ".", null)); - } - - public void checkout_on_agent_include_rule_with_mapping() throws IOException, VcsException { - testUpdate(createVcsRoot(simpleRepo()), "4:b06a290a363b", "cleanPatch1/after", new IncludeRule("+:.", "subdir", null)); + @DataProvider(name = "localMirrors") + public static Object[][] localMirrors() { + return new Object[][] { + new Object[] { true }, + new Object[] { false }}; } - private void testUpdate(final VcsRoot vcsRoot, String version, String expected, final IncludeRule includeRule) throws VcsException, IOException { - File workDir = doUpdate(vcsRoot, version, includeRule); - - checkWorkingDir(expected, workDir); - } - - private void checkWorkingDir(final String expected, final File workDir) throws IOException { - FileUtil.delete(new File(workDir, ".hg")); - checkDirectoriesAreEqual(new File(getTestDataPath(), expected), workDir); - } - - private File doUpdate(final VcsRoot vcsRoot, final String version, final IncludeRule includeRule) throws VcsException { - return doUpdate(vcsRoot, version, includeRule, false); + @Test(dataProvider = "localMirrors") + public void checkout_on_agent(boolean useLocalMirrors) throws IOException, VcsException { + testUpdate(createVcsRoot(simpleRepo()), "4:b06a290a363b", "cleanPatch1/after", new IncludeRule(".", ".", null), useLocalMirrors); } - private File doUpdate(final VcsRoot vcsRoot, final String version, final IncludeRule includeRule, boolean useLocalMirrors) throws VcsException { - File actualWorkDir = new File(myWorkDir, includeRule.getTo()); - final Map<String, String> sharedConfigParameters = new HashMap<String, String>(); - sharedConfigParameters.put("teamcity.hg.use.local.mirrors", String.valueOf(useLocalMirrors)); - final AgentRunningBuild build = myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++); - myContext.checking(new Expectations() {{ - allowing(build).getBuildLogger(); will(returnValue(myLogger)); - allowing(build).getSharedConfigParameters(); will(returnValue(sharedConfigParameters)); - }}); - myVcsSupport.getUpdater(vcsRoot, new CheckoutRules(""), version, myWorkDir, build, false).process(includeRule, actualWorkDir); - - File hgDir = new File(actualWorkDir, ".hg"); - assertTrue(hgDir.isDirectory()); - return actualWorkDir; + @Test(dataProvider = "localMirrors") + public void checkout_on_agent_include_rule_with_mapping(boolean useLocalMirrors) throws IOException, VcsException { + testUpdate(createVcsRoot(simpleRepo()), "4:b06a290a363b", "cleanPatch1/after", new IncludeRule("+:.", "subdir", null), useLocalMirrors); } - public void checkout_on_agent_from_branch() throws IOException, VcsException { - testUpdate(createVcsRoot(simpleRepo(), "test_branch"), "7:376dcf05cd2a", "patch3/after", new IncludeRule(".", ".", null)); + @Test(dataProvider = "localMirrors") + public void checkout_on_agent_from_branch(boolean useLocalMirrors) throws IOException, VcsException { + testUpdate(createVcsRoot(simpleRepo(), "test_branch"), "7:376dcf05cd2a", "patch3/after", new IncludeRule(".", ".", null), useLocalMirrors); } - public void update_on_agent() throws IOException, VcsException { + @Test(dataProvider = "localMirrors") + public void update_on_agent(boolean useLocalMirrors) throws IOException, VcsException { VcsRoot vcsRoot = createVcsRoot(simpleRepo()); - doUpdate(vcsRoot, "3:9522278aa38d", new IncludeRule(".", ".", null)); - File workDir = doUpdate(vcsRoot, "4:b06a290a363b", new IncludeRule(".", ".", null)); + doUpdate(vcsRoot, "3:9522278aa38d", new IncludeRule(".", ".", null), useLocalMirrors); + File workDir = doUpdate(vcsRoot, "4:b06a290a363b", new IncludeRule(".", ".", null), useLocalMirrors); checkWorkingDir("patch1/after", workDir); } - public void update_on_agent_with_include_rule() throws IOException, VcsException { + @Test(dataProvider = "localMirrors") + public void update_on_agent_with_include_rule(boolean useLocalMirrors) throws IOException, VcsException { VcsRoot vcsRoot = createVcsRoot(simpleRepo()); - doUpdate(vcsRoot, "3:9522278aa38d", new IncludeRule(".", "subdir", null)); - File workDir = doUpdate(vcsRoot, "4:b06a290a363b", new IncludeRule(".", "subdir", null)); + doUpdate(vcsRoot, "3:9522278aa38d", new IncludeRule(".", "subdir", null), useLocalMirrors); + File workDir = doUpdate(vcsRoot, "4:b06a290a363b", new IncludeRule(".", "subdir", null), useLocalMirrors); checkWorkingDir("patch1/after", workDir); } - public void update_on_agent_from_branch() throws IOException, VcsException { + @Test(dataProvider = "localMirrors") + public void update_on_agent_from_branch(boolean useLocalMirrors) throws IOException, VcsException { VcsRoot vcsRoot = createVcsRoot(simpleRepo(), "test_branch"); - doUpdate(vcsRoot, "7:376dcf05cd2a", new IncludeRule(".", ".", null)); - File workDir = doUpdate(vcsRoot, "8:04c3ae4c6312", new IncludeRule(".", ".", null)); + doUpdate(vcsRoot, "7:376dcf05cd2a", new IncludeRule(".", ".", null), useLocalMirrors); + File workDir = doUpdate(vcsRoot, "8:04c3ae4c6312", new IncludeRule(".", ".", null), useLocalMirrors); checkWorkingDir("patch4/after", workDir); } @@ -143,7 +126,7 @@ List<File> mirrors = FileUtil.getSubDirectories(myMirrorsRootDir); assertTrue(mirrors.isEmpty()); VcsRoot root = createVcsRoot(simpleRepo()); - doUpdate(root, "3:9522278aa38d", new IncludeRule(".", ".", null)); + doUpdate(root, "3:9522278aa38d", new IncludeRule(".", ".", null), false); mirrors = FileUtil.getSubDirectories(myMirrorsRootDir); //though some dirs are created - they are empty => there were no clones into local mirrors for (File mirror : mirrors) { @@ -166,54 +149,18 @@ assertTrue(hgrcContent.contains("default = " + root.getProperty(Constants.REPOSITORY_PROP))); } - public void new_repository_is_cloned_from_local_mirror() throws IOException, VcsException { - VcsRoot root = createVcsRoot(simpleRepo()); - File workingDir = doUpdate(root, "3:9522278aa38d", new IncludeRule(".", ".", null), true); - File mirrorDir = FileUtil.getSubDirectories(myMirrorsRootDir).get(0); - File hgrc = new File(workingDir, ".hg" + File.separator + "hgrc"); - String hgrcContent = FileUtil.readText(hgrc); - assertTrue(hgrcContent.contains("default = " + mirrorDir.getCanonicalPath())); - } - - public void repository_cloned_from_remote_start_cloning_from_local_mirror() throws IOException, VcsException { - VcsRoot root = createVcsRoot(simpleRepo()); - //clone from remote repository - File workingDir = doUpdate(root, "3:9522278aa38d", new IncludeRule(".", ".", null)); - String hgrcContent = FileUtil.readText(new File(workingDir, ".hg" + File.separator + "hgrc")); - - File workingDir2 = doUpdate(root, "3:9522278aa38d", new IncludeRule(".", ".", null), true); - File newMirrorDir = FileUtil.getSubDirectories(myMirrorsRootDir).get(0); - String hgrcContent2 = FileUtil.readText(new File(workingDir2, ".hg" + File.separator + "hgrc")); - assertFalse(hgrcContent2.equals(hgrcContent));//repository settings are changed - assertTrue(hgrcContent2.contains("default = " + newMirrorDir.getCanonicalPath()));//now it clones from local mirror + //TW-15984 + @Test(dataProvider = "localMirrors") + public void should_be_able_to_clone_into_non_empty_dir(boolean useLocalMirrors) throws IOException, VcsException { + VcsRoot vcsRoot = createVcsRoot(simpleRepo()); + doUpdate(vcsRoot, "3:9522278aa38d", new IncludeRule(".", "subdir", null), useLocalMirrors); + doUpdate(vcsRoot, "4:b06a290a363b", new IncludeRule(".", ".", null), useLocalMirrors); } - public void repository_cloned_from_local_mirror_start_cloning_from_remote() throws IOException, VcsException { + @Test(dataProvider = "localMirrors") + public void cloned_repo_should_contains_default_parameter_in_hgrc(boolean useLocalMirrors) throws VcsException, IOException { VcsRoot root = createVcsRoot(simpleRepo()); - //clone from remote repository - File workingDir = doUpdate(root, "3:9522278aa38d", new IncludeRule(".", ".", null), true); - String hgrcContent = FileUtil.readText(new File(workingDir, ".hg" + File.separator + "hgrc")); - File newMirrorDir = FileUtil.getSubDirectories(myMirrorsRootDir).get(0); - assertTrue(hgrcContent.contains("default = " + newMirrorDir.getCanonicalPath()));//now it clones from local mirror - - File workingDir2 = doUpdate(root, "3:9522278aa38d", new IncludeRule(".", ".", null)); - String hgrcContent2 = FileUtil.readText(new File(workingDir2, ".hg" + File.separator + "hgrc")); - assertFalse(hgrcContent2.equals(hgrcContent));//repository settings are changed - assertTrue(hgrcContent2.contains("default = " + root.getProperty(Constants.REPOSITORY_PROP)));//now it clones from remote - } - - /** - * TW-15984 - */ - public void should_be_able_to_clone_into_non_empty_dir() throws IOException, VcsException { - VcsRoot vcsRoot = createVcsRoot(simpleRepo()); - doUpdate(vcsRoot, "3:9522278aa38d", new IncludeRule(".", "subdir", null)); - doUpdate(vcsRoot, "4:b06a290a363b", new IncludeRule(".", ".", null)); - } - - public void cloned_repo_should_contains_default_parameter_in_hgrc() throws VcsException, IOException { - VcsRoot root = createVcsRoot(simpleRepo()); - File workingDir = doUpdate(root, "4:b06a290a363b", new IncludeRule(".", ".", null)); + File workingDir = doUpdate(root, "4:b06a290a363b", new IncludeRule(".", ".", null), useLocalMirrors); File hgrc = new File(workingDir, ".hg" + File.separator + "hgrc"); String hgrcContent = FileUtil.readText(hgrc); assertTrue(hgrcContent.contains("default = " + root.getProperty(Constants.REPOSITORY_PROP))); @@ -222,4 +169,30 @@ protected String getTestDataPath() { return "mercurial-tests/testData"; } + + private void testUpdate(final VcsRoot vcsRoot, String version, String expected, final IncludeRule includeRule, boolean useLocalMirrors) throws VcsException, IOException { + File workDir = doUpdate(vcsRoot, version, includeRule, useLocalMirrors); + checkWorkingDir(expected, workDir); + } + + private void checkWorkingDir(final String expected, final File workDir) throws IOException { + FileUtil.delete(new File(workDir, ".hg")); + checkDirectoriesAreEqual(new File(getTestDataPath(), expected), workDir); + } + + private File doUpdate(final VcsRoot vcsRoot, final String version, final IncludeRule includeRule, boolean useLocalMirrors) throws VcsException { + File actualWorkDir = new File(myWorkDir, includeRule.getTo()); + final Map<String, String> sharedConfigParameters = new HashMap<String, String>(); + sharedConfigParameters.put("teamcity.hg.use.local.mirrors", String.valueOf(useLocalMirrors)); + final AgentRunningBuild build = myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++); + myContext.checking(new Expectations() {{ + allowing(build).getBuildLogger(); will(returnValue(myLogger)); + allowing(build).getSharedConfigParameters(); will(returnValue(sharedConfigParameters)); + }}); + myVcsSupport.getUpdater(vcsRoot, new CheckoutRules(""), version, myWorkDir, build, false).process(includeRule, actualWorkDir); + + File hgDir = new File(actualWorkDir, ".hg"); + assertTrue(hgDir.isDirectory()); + return actualWorkDir; + } }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java Sat Feb 18 22:10:29 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java Sat Mar 03 12:28:29 2012 +0400 @@ -511,11 +511,8 @@ assertTrue(myVcs.getCollectChangesPolicy() instanceof CollectChangesByCheckoutRules); } - private ServerPluginConfig createPluginConfig() { - return new ServerPluginConfig() { - public boolean isUsePullProtocol() { - return true; - } + private PluginConfig createPluginConfig() { + return new PluginConfig() { public int getPullTimeout() { return ServerPluginConfigImpl.DEFAULT_PULL_TIMEOUT_SECONDS; }