changeset 494:6ff7f6e77b98

Merge branch Faradi-7.1.x
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Tue, 23 Oct 2012 13:51:23 +0400
parents 04e8fdb0e403 (current diff) 236d0866a45f (diff)
children e4210c35aa24
files mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java
diffstat 11 files changed, 34 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java	Tue Oct 23 13:51:23 2012 +0400
@@ -31,7 +31,7 @@
   private final String myHgPath;
   private final File myWorkDirectory;
 
-  public BaseCommand(CommandSettings commandSettings,
+  public BaseCommand(@NotNull CommandSettings commandSettings,
                      @NotNull final String hgPath,
                      @NotNull File workingDir) {
     myCommandSettings = commandSettings;
@@ -54,6 +54,7 @@
   protected MercurialCommandLine createCL() {
     MercurialCommandLine cl = new MercurialCommandLine(getPrivateData());
     cl.setExePath(myHgPath);
+    cl.setEnvParams(myCommandSettings.getHgEnv());
     return cl;
   }
 
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettings.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettings.java	Tue Oct 23 13:51:23 2012 +0400
@@ -2,7 +2,9 @@
 
 import org.jetbrains.annotations.NotNull;
 
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -15,6 +17,7 @@
   private boolean myCheckForFailure = true;
   private boolean myFailWhenStderrNotEmpty = false;
   private String myLogLevel = "debug";
+  private Map<String, String> myHgEnv = new HashMap<String, String>();
 
   public CommandSettings() {
 
@@ -77,4 +80,13 @@
   public String getLogLevel() {
     return myLogLevel;
   }
+
+  public CommandSettings addHgEnv(@NotNull String param, @NotNull String value) {
+    myHgEnv.put(param, value);
+    return this;
+  }
+
+  public Map<String, String> getHgEnv() {
+    return myHgEnv;
+  }
 }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java	Tue Oct 23 13:51:23 2012 +0400
@@ -3,6 +3,7 @@
 import com.intellij.openapi.diagnostic.Logger;
 import jetbrains.buildServer.TempFiles;
 import jetbrains.buildServer.agent.*;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.log.Log4jFactory;
 import jetbrains.buildServer.vcs.*;
 import org.jetbrains.annotations.NotNull;
@@ -53,7 +54,7 @@
     AgentPluginConfigImpl pluginConfig = new AgentPluginConfigImpl(agentConfig);
     AgentHgPathProvider hgPathProvider = new AgentHgPathProvider(agentConfig);
     myMirrorManager = new MirrorManagerImpl(pluginConfig);
-    AgentRepoFactory repoFactory = new AgentRepoFactory(new AgentCommandSettingsFactory());
+    AgentRepoFactory repoFactory = new AgentRepoFactory(new TestCommandSettingsFactory());
     myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig, hgPathProvider, myMirrorManager, repoFactory);
     myCleaner = new AgentMirrorCleaner(myMirrorManager);
     myLogger = myContext.mock(BuildProgressLogger.class);
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Tue Oct 23 13:51:23 2012 +0400
@@ -18,6 +18,7 @@
 import jetbrains.buildServer.agent.AgentRunningBuild;
 import jetbrains.buildServer.agent.BuildAgentConfiguration;
 import jetbrains.buildServer.agent.BuildProgressLogger;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.util.TestFor;
 import jetbrains.buildServer.vcs.CheckoutRules;
@@ -72,7 +73,10 @@
     }});
 
     final AgentPluginConfigImpl pluginConfig = new AgentPluginConfigImpl(agentConfig);
-    myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig, new AgentHgPathProvider(agentConfig), new MirrorManagerImpl(pluginConfig), new AgentRepoFactory(new AgentCommandSettingsFactory()));
+    myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig,
+            new AgentHgPathProvider(agentConfig),
+            new MirrorManagerImpl(pluginConfig),
+            new AgentRepoFactory(new TestCommandSettingsFactory()));
 
     myLogger = myContext.mock(BuildProgressLogger.class);
     myContext.checking(new Expectations() {{
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java	Tue Oct 23 13:51:23 2012 +0400
@@ -7,6 +7,7 @@
 import jetbrains.buildServer.agent.BuildProgressLogger;
 import jetbrains.buildServer.agent.vcs.UpdateByIncludeRules2;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.ConnectionRefusedException;
 import jetbrains.buildServer.log.Log4jFactory;
 import jetbrains.buildServer.util.FileUtil;
@@ -74,7 +75,7 @@
     myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig,
             new AgentHgPathProvider(agentConfig),
             myMirrorManager,
-            new AgentRepoFactory(new AgentCommandSettingsFactory()));
+            new AgentRepoFactory(new TestCommandSettingsFactory()));
 
     myLogger = myContext.mock(BuildProgressLogger.class);
     myContext.checking(new Expectations() {{
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java	Tue Oct 23 13:51:23 2012 +0400
@@ -254,6 +254,7 @@
     MercurialCommandLine cli = new MercurialCommandLine();
     cli.setExePath(vcsRoot.getProperty(Constants.HG_COMMAND_PATH_PROP));
     cli.setWorkDirectory(vcsRoot.getProperty(Constants.REPOSITORY_PROP));
+    cli.setEnvParams(map("HGRCPATH", ""));
     cli.addParameter("tags");
     CommandResult res = CommandUtil.runCommand(cli, new CommandSettings());
     assertTrue(res.getStdout().contains("new_tag"));
@@ -271,6 +272,7 @@
     cli.setExePath(vcsRoot.getProperty(Constants.HG_COMMAND_PATH_PROP));
     cli.setWorkDirectory(vcsRoot.getProperty(Constants.REPOSITORY_PROP));
     cli.addParameter("tags");
+    cli.setEnvParams(map("HGRCPATH", ""));
     CommandResult res = CommandUtil.runCommand(cli, new CommandSettings());
     assertTrue(res.getStdout().contains("branch_tag"));
     assertTrue(res.getStdout().contains("7:376dcf05cd2a"));
@@ -559,10 +561,10 @@
 
 
   public void hg_version_should_not_depend_on_locale() throws IOException, VcsException {
-    HgRepo repo = new HgRepo(new ServerCommandSettingsFactory(), new File(simpleRepo()), Util.getHgPath(), new AuthSettings(null, null));
+    HgRepo repo = new HgRepo(new TestCommandSettingsFactory(), new File(simpleRepo()), Util.getHgPath(), new AuthSettings(null, null));
     HgVersion defaultLocaleVersion = repo.version().call();
 
-    VersionCommand russianLocalVersion = new VersionCommand(new ServerCommandSettingsFactory().create(), Util.getHgPath(), new File(simpleRepo())) {
+    VersionCommand russianLocalVersion = new VersionCommand(new TestCommandSettingsFactory().create(), Util.getHgPath(), new File(simpleRepo())) {
       @Override
       protected MercurialCommandLine createCommandLine() {
         MercurialCommandLine commandLine = super.createCommandLine();
@@ -572,6 +574,7 @@
         env.put("LANG", "ru_RU");
         env.put("LANGUAGE", "ru_RU");
         env.put("LC_MESSAGE", "ru_RU");
+        env.put("HGRCPATH", "");
         commandLine.setEnvParams(env);
         return commandLine;
       }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java	Tue Oct 23 13:51:23 2012 +0400
@@ -1,6 +1,7 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
 import jetbrains.buildServer.TempFiles;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.serverSide.BuildServerListener;
 import jetbrains.buildServer.serverSide.SBuildServer;
 import jetbrains.buildServer.util.EventDispatcher;
@@ -42,7 +43,7 @@
 
 
   public static MercurialVcsSupport createMercurialServerSupport(@NotNull Mockery context, ServerPluginConfig config) throws IOException {
-    return createMercurialServerSupport(context, config, new RepoFactory(config, new ServerCommandSettingsFactory()));
+    return createMercurialServerSupport(context, config, new RepoFactory(config, new TestCommandSettingsFactory()));
   }
 
 
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java	Tue Oct 23 13:51:23 2012 +0400
@@ -49,7 +49,7 @@
     HgVcsRoot hgRoot = new HgVcsRoot(root);
     hgRoot.setCustomWorkingDir(workingDir);
 
-    new CloneCommand(new CommandSettings(), hgPathProvider.getHgPath(hgRoot), workingDir, hgRoot.getAuthSettings()).fromRepository(hgRoot.getRepository()).call();
+    new CloneCommand(new TestCommandSettingsFactory().create(), hgPathProvider.getHgPath(hgRoot), workingDir, hgRoot.getAuthSettings()).fromRepository(hgRoot.getRepository()).call();
 
     String[] files = new String[] {".hg", "dir1", "dir with space", "file.txt"};
     for (String f : files) {
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java	Tue Oct 23 13:51:23 2012 +0400
@@ -38,7 +38,7 @@
   private Void runIdentify(final ChangeSet cset) throws IOException, VcsException {
     return runCommand(new CommandExecutor<Void>() {
       public Void execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
-        new IdentifyCommand(new CommandSettings(), hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings())
+        new IdentifyCommand(new TestCommandSettingsFactory().create(), hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings())
                 .revision(cset)
                 .inLocalRepository()
                 .call();
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/TestCommandSettingsFactory.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/TestCommandSettingsFactory.java	Tue Oct 23 13:51:23 2012 +0400
@@ -3,6 +3,6 @@
 public class TestCommandSettingsFactory implements CommandSettingsFactory {
 
   public CommandSettings create() {
-    return new CommandSettings();
+    return new CommandSettings().addHgEnv("HGRCPATH", "");
   }
 }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommandTest.java	Thu Oct 18 13:35:43 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommandTest.java	Tue Oct 23 13:51:23 2012 +0400
@@ -18,7 +18,7 @@
     ServerPluginConfig config = new ServerPluginConfigBuilder().build();
     final ServerHgPathProvider hgPathProvider = new ServerHgPathProvider(config);
     HgVcsRoot hgRoot = new HgVcsRoot(root);
-    VersionCommand versionCommand = new VersionCommand(new CommandSettings(), hgPathProvider.getHgPath(hgRoot), new File(".."));
+    VersionCommand versionCommand = new VersionCommand(new TestCommandSettingsFactory().create(), hgPathProvider.getHgPath(hgRoot), new File(".."));
     HgVersion version = versionCommand.call();
     assertNotNull(version);
   }