changeset 480:efba721f9a1d Faradi-7.1.x

TW-23382 agent logs with info, server logs with debug
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Wed, 26 Sep 2012 18:29:01 +0400
parents 0a33f3dbd261
children 767e9a5bc209 236d0866a45f
files mercurial-agent/src/META-INF/build-agent-plugin-mercurial.xml mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentCommandSettingsFactory.java mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentRepoFactory.java mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgDetector.java mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgFileUtil.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ArchiveCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BranchesCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandExecutionSettings.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandExecutionSettingsBuilder.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettings.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettingsFactory.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Init.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/MercurialCommandLine.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/TagCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/UpdateCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VcsRootCommand.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommand.java mercurial-server/src/META-INF/build-server-plugin-mercurial.xml mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialResetCacheHandler.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerCommandSettingsFactory.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgRepo.java 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/RevisionFormatTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommandTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommandTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/TestCommandSettingsFactory.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommandTest.java
diffstat 50 files changed, 385 insertions(+), 256 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-agent/src/META-INF/build-agent-plugin-mercurial.xml	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-agent/src/META-INF/build-agent-plugin-mercurial.xml	Wed Sep 26 18:29:01 2012 +0400
@@ -8,4 +8,6 @@
   <bean id="pluginConfig" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.AgentPluginConfigImpl"/>
   <bean id="mirrorManager" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.MirrorManagerImpl" />
   <bean id="mirrorCleaner" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.AgentMirrorCleaner" />
+  <bean id="commandSettingsFactory" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.AgentCommandSettingsFactory" />
+  <bean id="agentRepoFactory" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.AgentRepoFactory"/>
 </beans>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentCommandSettingsFactory.java	Wed Sep 26 18:29:01 2012 +0400
@@ -0,0 +1,11 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettings;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsFactory;
+
+public class AgentCommandSettingsFactory implements CommandSettingsFactory {
+
+  public CommandSettings create() {
+    return new CommandSettings().setLogLevel("info");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentRepoFactory.java	Wed Sep 26 18:29:01 2012 +0400
@@ -0,0 +1,23 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsFactory;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.File;
+
+public class AgentRepoFactory {
+
+  private final CommandSettingsFactory myCommandSettingsFactory;
+
+  public AgentRepoFactory(@NotNull CommandSettingsFactory commandSettingsFactory) {
+    myCommandSettingsFactory = commandSettingsFactory;
+  }
+
+  public HgRepo create(@NotNull File workingDir,
+                       @NotNull String hgPath,
+                       @NotNull AuthSettings authSettings) {
+    return new HgRepo(myCommandSettingsFactory, workingDir, hgPath, authSettings);
+  }
+
+}
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgDetector.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgDetector.java	Wed Sep 26 18:29:01 2012 +0400
@@ -5,6 +5,7 @@
 import jetbrains.buildServer.agent.AgentLifeCycleListener;
 import jetbrains.buildServer.agent.BuildAgent;
 import jetbrains.buildServer.agent.BuildAgentConfiguration;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsFactory;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.VersionCommand;
 import jetbrains.buildServer.util.EventDispatcher;
 import jetbrains.buildServer.vcs.VcsException;
@@ -23,10 +24,13 @@
   final static String AGENT_HG_PATH_PROPERTY = "teamcity.hg.agent.path";
   private final static Logger LOG = Logger.getInstance(HgDetector.class.getName());
   private final static HgVersion LEAST_SUPPORTED_VERSION = new HgVersion(1, 5, 2);
+  private final CommandSettingsFactory myCommandSettingsFactory;
   private final List<String> myHgPaths = Arrays.asList("hg");
 
 
-  public HgDetector(@NotNull final EventDispatcher<AgentLifeCycleListener> dispatcher) {
+  public HgDetector(@NotNull EventDispatcher<AgentLifeCycleListener> dispatcher,
+                    @NotNull CommandSettingsFactory commandSettingsFactory) {
+    myCommandSettingsFactory = commandSettingsFactory;
     dispatcher.addListener(this);
   }
 
@@ -66,7 +70,7 @@
   }
 
   private boolean canRunHg(@NotNull final String hgPath, @NotNull final File workDir, boolean logWarnings) {
-    VersionCommand versionCommand = new VersionCommand(hgPath, workDir);
+    VersionCommand versionCommand = new VersionCommand(myCommandSettingsFactory.create(), hgPath, workDir);
     try {
       HgVersion version = versionCommand.call();
       if (isCompatible(version)) {
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java	Wed Sep 26 18:29:01 2012 +0400
@@ -32,17 +32,20 @@
   private final AgentPluginConfig myConfig;
   private final HgPathProvider myHgPathProvider;
   private final MirrorManager myMirrorManager;
+  private final AgentRepoFactory myRepoFactory;
 
-  public MercurialAgentSideVcsSupport(@NotNull final AgentPluginConfig pluginConfig,
-                                      @NotNull final HgPathProvider hgPathProvider,
-                                      @NotNull final MirrorManager mirrorManager) {
+  public MercurialAgentSideVcsSupport(@NotNull AgentPluginConfig pluginConfig,
+                                      @NotNull HgPathProvider hgPathProvider,
+                                      @NotNull MirrorManager mirrorManager,
+                                      @NotNull AgentRepoFactory repoFactory) {
     myConfig = pluginConfig;
     myHgPathProvider = hgPathProvider;
     myMirrorManager = mirrorManager;
+    myRepoFactory = repoFactory;
   }
 
   public IncludeRuleUpdater getUpdater(@NotNull final VcsRoot vcsRoot, @NotNull final CheckoutRules checkoutRules, @NotNull final String toVersion, @NotNull final File checkoutDirectory, @NotNull final AgentRunningBuild build, boolean cleanCheckoutRequested) throws VcsException {
-    return new MercurialIncludeRuleUpdater(myConfig, myMirrorManager, myHgPathProvider, vcsRoot, toVersion, build);
+    return new MercurialIncludeRuleUpdater(myConfig, myMirrorManager, myHgPathProvider, myRepoFactory, vcsRoot, toVersion, build);
   }
 
   @NotNull
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java	Wed Sep 26 18:29:01 2012 +0400
@@ -24,6 +24,7 @@
 
   private final AgentPluginConfig myConfig;
   private final MirrorManager myMirrorManager;
+  private final AgentRepoFactory myRepoFactory;
   private final HgVcsRoot myRoot;
   private final AuthSettings myAuthSettings;
   private final String myHgPath;
@@ -33,14 +34,16 @@
   private int myPullTimeout;
   private final boolean myUseTraceback;
 
-  public MercurialIncludeRuleUpdater(@NotNull final AgentPluginConfig pluginConfig,
-                                     @NotNull final MirrorManager mirrorManager,
-                                     @NotNull final HgPathProvider hgPathProvider,
-                                     @NotNull final VcsRoot root,
-                                     @NotNull final String toVersion,
-                                     @NotNull final AgentRunningBuild build) {
+  public MercurialIncludeRuleUpdater(@NotNull AgentPluginConfig pluginConfig,
+                                     @NotNull MirrorManager mirrorManager,
+                                     @NotNull HgPathProvider hgPathProvider,
+                                     @NotNull AgentRepoFactory repoFactory,
+                                     @NotNull VcsRoot root,
+                                     @NotNull String toVersion,
+                                     @NotNull AgentRunningBuild build) {
     myConfig = pluginConfig;
     myMirrorManager = mirrorManager;
+    myRepoFactory = repoFactory;
     myRoot = new HgVcsRoot(root);
     myAuthSettings = myRoot.getAuthSettings();
     myHgPath = hgPathProvider.getHgPath(myRoot);
@@ -71,7 +74,7 @@
 
   private void updateLocalMirror(@NotNull String repositoryUrl, @NotNull String revision) throws VcsException, IOException {
     File mirrorDir = myMirrorManager.getMirrorDir(repositoryUrl);
-    HgRepo mirrorRepo = new HgRepo(mirrorDir, myHgPath, myAuthSettings);
+    HgRepo mirrorRepo = myRepoFactory.create(mirrorDir, myHgPath, myAuthSettings);
     if (!mirrorRepo.isValidRepository()) {
       delete(mirrorDir);
       myLogger.message("Clone repository " + myAuthSettings.getRepositoryUrlWithHiddenPassword(repositoryUrl) + " into local mirror " + mirrorRepo.path());
@@ -100,7 +103,7 @@
 
   private void updateRepository(@NotNull File workingDir) throws VcsException, IOException {
     String repositoryUrl = getDefaultPullUrl(myRoot, myUseLocalMirrors);
-    HgRepo repo = new HgRepo(workingDir, myHgPath, myAuthSettings);
+    HgRepo repo = myRepoFactory.create(workingDir, myHgPath, myAuthSettings);
     myLogger.message("Update repository " + workingDir.getAbsolutePath());
     if (repo.isEmpty()) {//can do clone only in empty dir
       myLogger.message("Start cloning from " + (myUseLocalMirrors ? "local mirror " : "") + myAuthSettings.getRepositoryUrlWithHiddenPassword(repositoryUrl));
@@ -135,7 +138,7 @@
 
 
   private void updateWorkingDir(@NotNull File workingDir, @NotNull String toVersion, @NotNull String repositoryUrl) throws VcsException, IOException {
-    HgRepo repo = new HgRepo(workingDir, myHgPath, myAuthSettings);
+    HgRepo repo = myRepoFactory.create(workingDir, myHgPath, myAuthSettings);
     updateSubrepositories(repo, toVersion, repositoryUrl);
     doUpdateWorkingDir(repo, toVersion);
   }
@@ -156,7 +159,7 @@
         myLogger.message("The url of subrepo was changed between revisions " + workingDirRevision + " and " + toVersion + " , delete the subrepo");
         delete(subrepo.dir());
       }
-      HgRepo subrepository = new HgRepo(subrepo.dir(), myHgPath, myAuthSettings);
+      HgRepo subrepository = myRepoFactory.create(subrepo.dir(), myHgPath, myAuthSettings);
       if (myUseLocalMirrors && subrepo.vcsType() == SubRepo.VcsType.hg) {
         if (subrepo.isRelative()) {
           myLogger.message("Subrepo url " + subrepo.url() + " is relative, subrepo will be updated during parent repository update");
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgFileUtil.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgFileUtil.java	Wed Sep 26 18:29:01 2012 +0400
@@ -1,7 +1,6 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
 import com.intellij.openapi.diagnostic.Logger;
-import jetbrains.buildServer.log.Loggers;
 import jetbrains.buildServer.util.FileUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java	Wed Sep 26 18:29:01 2012 +0400
@@ -10,7 +10,6 @@
 import java.io.IOException;
 import java.util.*;
 
-import static com.intellij.openapi.util.io.FileUtil.delete;
 import static java.util.Collections.emptyMap;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.HgFileUtil.deleteDir;
 import static jetbrains.buildServer.util.FileUtil.isEmptyDir;
@@ -20,67 +19,72 @@
 */
 public class HgRepo {
 
+  protected final CommandSettingsFactory myCommandSettingsFactory;
   protected final File myWorkingDir;
   protected final String myHgPath;
   protected final AuthSettings myAuthSettings;
   private final Map<String, Map<String, SubRepo>> mySubreposCache = new HashMap<String, Map<String, SubRepo>>();
 
-  public HgRepo(@NotNull File workingDir, @NotNull String hgPath, @NotNull AuthSettings authSettings) {
+  public HgRepo(@NotNull CommandSettingsFactory commandSettingsFactory,
+                @NotNull File workingDir,
+                @NotNull String hgPath,
+                @NotNull AuthSettings authSettings) {
+    myCommandSettingsFactory = commandSettingsFactory;
     myWorkingDir = workingDir;
     myHgPath = hgPath;
     myAuthSettings = authSettings;
   }
 
   public PullCommand pull() {
-    return new PullCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new PullCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public PushCommand push() {
-    return new PushCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new PushCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public CloneCommand doClone() {
-    return new CloneCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new CloneCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public IdentifyCommand id() {
-    return new IdentifyCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new IdentifyCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public Init init() {
-    return new Init(myHgPath, myWorkingDir, myAuthSettings);
+    return new Init(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public LogCommand log() {
-    return new LogCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new LogCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public UpdateCommand update() {
-    return new UpdateCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new UpdateCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public BranchesCommand branches() {
-    return new BranchesCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new BranchesCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public StatusCommand status() {
-    return new StatusCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new StatusCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public TagCommand tag() {
-    return new TagCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new TagCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public CatCommand cat() {
-    return new CatCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new CatCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public ArchiveCommand archive() {
-    return new ArchiveCommand(myHgPath, myWorkingDir, myAuthSettings);
+    return new ArchiveCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public VersionCommand version() {
-    return new VersionCommand(myHgPath, myWorkingDir);
+    return new VersionCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir);
   }
 
   public String path() {
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ArchiveCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ArchiveCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -20,14 +20,15 @@
 
 import java.io.File;
 
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandExecutionSettingsBuilder.with;
-
 public class ArchiveCommand extends VcsRootCommand {
   private File myDestDir;
   private String myToId;
 
-  public ArchiveCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public ArchiveCommand(@NotNull CommandSettings commandSettings,
+                        @NotNull String hgPath,
+                        @NotNull File workingDir,
+                        @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
   }
 
   public ArchiveCommand toDir(@NotNull File destDir) {
@@ -43,13 +44,13 @@
   public void call() throws VcsException {
     if (myDestDir == null)
       throw new IllegalStateException("Destination dir must be specified");
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     cli.addParameter("archive");
     setType(cli);
     setRevision(cli);
     setDestination(cli);
 
-    runCommand(cli, with().failureWhenStderrNotEmpty());
+    runCommand(cli, myCommandSettings.setFailWhenStderrNotEmpty(true));
     deleteHgArchival();
   }
 
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,7 +15,6 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
@@ -28,10 +27,14 @@
  */
 public class BaseCommand {
 
+  protected final CommandSettings myCommandSettings;
   private final String myHgPath;
   private final File myWorkDirectory;
 
-  public BaseCommand(@NotNull final String hgPath, @NotNull File workingDir) {
+  public BaseCommand(CommandSettings commandSettings,
+                     @NotNull final String hgPath,
+                     @NotNull File workingDir) {
+    myCommandSettings = commandSettings;
     myHgPath = hgPath;
     myWorkDirectory = workingDir;
   }
@@ -41,15 +44,15 @@
     return myWorkDirectory;
   }
 
-  protected GeneralCommandLine createCommandLine() {
-    GeneralCommandLine cli = createCL();
+  protected MercurialCommandLine createCommandLine() {
+    MercurialCommandLine cli = createCL();
     cli.setWorkDirectory(myWorkDirectory.getAbsolutePath());
     cli.setPassParentEnvs(true);
     return cli;
   }
 
-  protected GeneralCommandLine createCL() {
-    GeneralCommandLine cl = new MercurialCommandLine(getPrivateData());
+  protected MercurialCommandLine createCL() {
+    MercurialCommandLine cl = new MercurialCommandLine(getPrivateData());
     cl.setExePath(myHgPath);
     return cl;
   }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BranchesCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BranchesCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,7 +15,6 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
@@ -31,8 +30,11 @@
  */
 public class BranchesCommand extends VcsRootCommand {
 
-  public BranchesCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public BranchesCommand(@NotNull CommandSettings commandSettings,
+                         @NotNull String hgPath,
+                         @NotNull File workingDir,
+                         @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
   }
 
   /**
@@ -41,7 +43,7 @@
    * @throws jetbrains.buildServer.vcs.VcsException if error occurs
    */
   public Map<String, ChangeSet> call() throws VcsException {
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     cli.addParameter("branches");
     CommandResult res = runCommand(cli);
     String stdout = res.getStdout();
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,7 +15,6 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgFileUtil;
 import jetbrains.buildServer.log.Loggers;
 import jetbrains.buildServer.vcs.VcsException;
@@ -28,10 +27,8 @@
 import java.util.List;
 import java.util.Queue;
 
-import static com.intellij.openapi.util.io.FileUtil.delete;
 import static java.util.Collections.singletonList;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.HgFileUtil.deleteDir;
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandExecutionSettingsBuilder.with;
 
 public class CatCommand extends VcsRootCommand {
   private String myRevId;
@@ -39,8 +36,11 @@
   private List<String> myRelativePaths = new ArrayList<String>();
   private boolean myCheckForFailure = true;
 
-  public CatCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public CatCommand(@NotNull CommandSettings commandSettings,
+                    @NotNull String hgPath,
+                    @NotNull File workingDir,
+                    @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
   }
 
   public CatCommand files(@NotNull String relativePath) {
@@ -108,7 +108,7 @@
   private void catFiles(List<String> relPaths, boolean checkFailure, File tempDir) throws VcsException {
     Queue<String> paths = new LinkedList<String>(relPaths);
     while (!paths.isEmpty()) {
-      GeneralCommandLine cli = createCommandLine(tempDir);
+      MercurialCommandLine cli = createCommandLine(tempDir);
       int cmdSize = cli.getCommandLineString().length();
 
       do {
@@ -117,12 +117,12 @@
         cmdSize += path.length();
       } while (cmdSize < MAX_CMD_LEN && !paths.isEmpty());
 
-      runCommand(cli, with().checkForFailure(checkFailure));
+      runCommand(cli, myCommandSettings.setCheckForFailure(checkFailure));
     }
   }
 
-  private GeneralCommandLine createCommandLine(final File tempDir) {
-    GeneralCommandLine cli = createCommandLine();
+  private MercurialCommandLine createCommandLine(final File tempDir) {
+    MercurialCommandLine cli = createCommandLine();
     cli.addParameter("cat");
     cli.addParameter("-o");
     cli.addParameter(tempDir.getAbsolutePath() + File.separator + "%p");
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,15 +15,12 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
 import java.io.IOException;
 
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandExecutionSettingsBuilder.with;
-
 public class CloneCommand extends VcsRootCommand {
   private String myToId;
   private boolean myUpdateWorkingDir = true;
@@ -33,8 +30,11 @@
   private boolean myUseUncompressedTransfer = false;
   private boolean myTraceback;
 
-  public CloneCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public CloneCommand(@NotNull CommandSettings commandSettings,
+                      @NotNull String hgPath,
+                      @NotNull File workingDir,
+                      @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
     myWorkingDir = workingDir;
   }
 
@@ -78,7 +78,7 @@
 
   public void call() throws VcsException {
     myWorkingDir.mkdirs();
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     File parent = myWorkingDir.getParentFile();
     cli.setWorkDirectory(parent.getAbsolutePath());
     cli.addParameter("clone");
@@ -100,6 +100,6 @@
     cli.addParameter(repositoryUrl);
     cli.addParameter(myWorkingDir.getName());
 
-    runCommand(cli, with().timeout(24 * 3600)); // some repositories are quite large, we set timeout to 24 hours
+    runCommand(cli, myCommandSettings.setTimeout(24 * 3600)); // some repositories are quite large, we set timeout to 24 hours
   }
 }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandExecutionSettings.java	Wed Sep 26 14:58:55 2012 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
-
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Set;
-
-/**
- * @author dmitry.neverov
- */
-public class CommandExecutionSettings {
-
-  private final int myTimeout;
-  private final Set<String> myPrivateData;
-  private final boolean myCheckForFailure;
-  private final boolean myFailWhenStderrNotEmpty;
-
-  CommandExecutionSettings(int timeout, @NotNull Set<String> privateData, boolean checkForFailure, boolean failWhenStderrNotEmpty) {
-    myTimeout = timeout;
-    myPrivateData = privateData;
-    myCheckForFailure = checkForFailure;
-    myFailWhenStderrNotEmpty = failWhenStderrNotEmpty;
-  }
-
-  public int timeout() {
-    return myTimeout;
-  }
-
-  @NotNull
-  public Set<String> privateData() {
-    return myPrivateData;
-  }
-
-  public boolean shouldCheckForFailure() {
-    return myCheckForFailure;
-  }
-
-  public boolean shouldFailWithNonEmptyStderr() {
-    return myFailWhenStderrNotEmpty;
-  }
-}
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandExecutionSettingsBuilder.java	Wed Sep 26 14:58:55 2012 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
-
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * @author dmitry.neverov
- */
-public class CommandExecutionSettingsBuilder {
-
-  private static final int DEFAULT_COMMAND_TIMEOUT_SEC = 3600;
-
-  private int myTimeout = DEFAULT_COMMAND_TIMEOUT_SEC;
-  private Set<String> myPrivateData = Collections.emptySet();
-  private boolean myCheckForFailure = true;
-  private boolean myFailWhenStderrNotEmpty = false;
-
-  public static CommandExecutionSettingsBuilder with() {
-    return new CommandExecutionSettingsBuilder();
-  }
-
-  public CommandExecutionSettings build() {
-    return new CommandExecutionSettings(myTimeout, myPrivateData, myCheckForFailure, myFailWhenStderrNotEmpty);
-  }
-
-  public CommandExecutionSettingsBuilder timeout(int timeout) {
-    myTimeout = timeout;
-    return this;
-  }
-
-  public CommandExecutionSettingsBuilder privateData(@NotNull Set<String> privateData) {
-    myPrivateData = privateData;
-    return this;
-  }
-
-  public CommandExecutionSettingsBuilder checkForFailure(boolean checkForFailure) {
-    myCheckForFailure = checkForFailure;
-    return this;
-  }
-
-  public CommandExecutionSettingsBuilder failureWhenStderrNotEmpty() {
-    myFailWhenStderrNotEmpty = true;
-    return this;
-  }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettings.java	Wed Sep 26 18:29:01 2012 +0400
@@ -0,0 +1,80 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author dmitry.neverov
+ */
+public class CommandSettings {
+
+  private int myTimeout = 3600;
+  private Set<String> myPrivateData = new HashSet<String>();
+  private boolean myCheckForFailure = true;
+  private boolean myFailWhenStderrNotEmpty = false;
+  private String myLogLevel = "debug";
+
+  public CommandSettings() {
+
+  }
+
+  public CommandSettings(int timeout,
+                         @NotNull Set<String> privateData,
+                         boolean checkForFailure,
+                         boolean failWhenStderrNotEmpty,
+                         @NotNull String logLevel) {
+    myTimeout = timeout;
+    myPrivateData = privateData;
+    myCheckForFailure = checkForFailure;
+    myFailWhenStderrNotEmpty = failWhenStderrNotEmpty;
+    myLogLevel = logLevel;
+  }
+
+  public CommandSettings setTimeout(int timeout) {
+    myTimeout = timeout;
+    return this;
+  }
+
+  public int getTimeout() {
+    return myTimeout;
+  }
+
+  public CommandSettings setPrivateData(@NotNull Set<String> privateData) {
+    myPrivateData = privateData;
+    return this;
+  }
+
+  @NotNull
+  public Set<String> getPrivateData() {
+    return myPrivateData;
+  }
+
+  public CommandSettings setCheckForFailure(boolean checkForFailure) {
+    myCheckForFailure = checkForFailure;
+    return this;
+  }
+
+  public boolean isCheckForFailure() {
+    return myCheckForFailure;
+  }
+
+  public CommandSettings setFailWhenStderrNotEmpty(boolean failWhenStderrNotEmpty) {
+    myFailWhenStderrNotEmpty = failWhenStderrNotEmpty;
+    return this;
+  }
+
+  public boolean isFailWithNonEmptyStderr() {
+    return myFailWhenStderrNotEmpty;
+  }
+
+  public CommandSettings setLogLevel(String logLevel) {
+    myLogLevel = logLevel;
+    return this;
+  }
+
+  public String getLogLevel() {
+    return myLogLevel;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettingsFactory.java	Wed Sep 26 18:29:01 2012 +0400
@@ -0,0 +1,7 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
+
+public interface CommandSettingsFactory {
+
+  CommandSettings create();
+
+}
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,38 +15,31 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.ExecResult;
 import jetbrains.buildServer.SimpleCommandLineProcessRunner;
 import jetbrains.buildServer.log.Loggers;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
+import java.io.File;
 import java.util.Set;
 
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandExecutionSettingsBuilder.with;
-
 public class CommandUtil {
 
-  public static CommandResult runCommand(@NotNull GeneralCommandLine cli) throws VcsException {
-    return runCommand(cli, with());
-  }
-
-  public static CommandResult runCommand(@NotNull GeneralCommandLine cli, @NotNull CommandExecutionSettingsBuilder executionSettingsBuilder) throws VcsException {
-    return runCommand(cli, executionSettingsBuilder.build());
-  }
-
-  private static CommandResult runCommand(@NotNull GeneralCommandLine cli, @NotNull CommandExecutionSettings executionSettings) throws VcsException {
-    final String command = removePrivateData(cli.getCommandLineString(), executionSettings.privateData());
-    Loggers.VCS.debug("Run command: " + command);
-    CommandResult res = run(cli, executionSettings.timeout(), command, executionSettings.privateData());
-    if (executionSettings.shouldCheckForFailure() || executionSettings.shouldFailWithNonEmptyStderr())
-      res.checkFailure(executionSettings.shouldFailWithNonEmptyStderr());
-    Loggers.VCS.debug("Command " + command + " output:\n" + res.getStdout());
+  public static CommandResult runCommand(@NotNull MercurialCommandLine cli, @NotNull CommandSettings settings) throws VcsException {
+    final String command = removePrivateData(cli.getCommandLineString(), settings.getPrivateData());
+    logRunCommand(cli, command, settings);
+    CommandResult res = run(cli, settings.getTimeout(), command, settings.getPrivateData());
+    if (settings.isCheckForFailure() || settings.isFailWithNonEmptyStderr())
+      res.checkFailure(settings.isFailWithNonEmptyStderr());
+    logCommandOutput(command, res);
     return res;
   }
 
-  private static CommandResult run(@NotNull final GeneralCommandLine cli, final int executionTimeout, @NotNull final String command, @NotNull final Set<String> privateData) {
+  private static CommandResult run(@NotNull final MercurialCommandLine cli,
+                                   final int executionTimeout,
+                                   @NotNull final String command,
+                                   @NotNull final Set<String> privateData) {
     final long start = System.currentTimeMillis();
     ExecResult res = SimpleCommandLineProcessRunner.runCommand(cli, null, new SimpleCommandLineProcessRunner.RunCommandEventsAdapter() {
       @Override
@@ -70,4 +63,19 @@
     }
     return result;
   }
+
+  private static void logRunCommand(@NotNull MercurialCommandLine cmd, @NotNull String command, @NotNull CommandSettings settings) {
+    String workingDir = cmd.getWorkingDirectory();
+    String dir = workingDir != null ? workingDir : new File(".").getAbsolutePath();
+    String message = "[" + dir + "] " + command;
+    if ("debug".equals(settings.getLogLevel())) {
+      Loggers.VCS.debug(message);
+    } else {
+      Loggers.VCS.info(message);
+    }
+  }
+
+  private static void logCommandOutput(@NotNull String command, @NotNull CommandResult result) {
+    Loggers.VCS.debug("Command " + command + " output:\n" + result.getStdout());
+  }
 }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,14 +15,11 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
 
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandExecutionSettingsBuilder.with;
-
 /**
  * @author Pavel.Sher
  *         Date: 16.07.2008
@@ -36,8 +33,11 @@
   private String myRepositoryUrl;
   private String myNamedRevision;
 
-  public IdentifyCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public IdentifyCommand(@NotNull CommandSettings commandSettings,
+                         @NotNull String hgPath,
+                         @NotNull File workingDir,
+                         @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
   }
 
   public IdentifyCommand namedRevision(@NotNull String name) {
@@ -76,7 +76,7 @@
   }
 
   public String call() throws VcsException {
-    GeneralCommandLine cli = createCL();
+    MercurialCommandLine cli = createCL();
     cli.addParameter("identify");
     if (myInLocalRepository) {
       cli.setWorkDirectory(this.getWorkDirectory().getAbsolutePath());
@@ -93,7 +93,7 @@
       cli.addParameter("--rev");
       cli.addParameter(myNamedRevision);
     }
-    CommandResult res = runCommand(cli, with().failureWhenStderrNotEmpty());
+    CommandResult res = runCommand(cli, myCommandSettings.setFailWhenStderrNotEmpty(true));
     String output = res.getStdout().trim();
     return output.contains(" ") ? output.substring(0, output.indexOf(" ")) : output;
   }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Init.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/Init.java	Wed Sep 26 18:29:01 2012 +0400
@@ -1,6 +1,5 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
@@ -11,13 +10,16 @@
  */
 public class Init extends VcsRootCommand {
 
-  public Init(@NotNull final String hgPath, @NotNull final File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public Init(@NotNull CommandSettings commandSettings,
+              @NotNull String hgPath,
+              @NotNull File workingDir,
+              @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
   }
 
   public void call() throws VcsException {
     getWorkDirectory().mkdirs();
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     cli.addParameter("init");
     runCommand(cli);
   }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,7 +15,6 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import com.intellij.openapi.diagnostic.Logger;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
@@ -48,8 +47,11 @@
   private String myRevsets;
   private File myTemplate;
 
-  public LogCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public LogCommand(@NotNull CommandSettings commandSettings,
+                    @NotNull String hgPath,
+                    @NotNull File workingDir,
+                    @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
   }
 
   public LogCommand withTemplate(@NotNull File template) {
@@ -98,7 +100,7 @@
   }
 
   public List<ChangeSet> call() throws VcsException {
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     cli.setCharset(Charset.forName("UTF-8"));
     cli.addParameters("--encoding", "UTF-8");
     cli.addParameter("log");
@@ -181,7 +183,7 @@
   private String getIdOf(int revNumber) throws VcsException {
     if (revNumber < 0)
       return ZERO_PARENT_ID;
-    return new IdentifyCommand(getHgPath(), getWorkDirectory(), myAuthSettings)
+    return new IdentifyCommand(myCommandSettings, getHgPath(), getWorkDirectory(), myAuthSettings)
             .revisionNumber(revNumber)
             .inLocalRepository()
             .call();
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/MercurialCommandLine.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/MercurialCommandLine.java	Wed Sep 26 18:29:01 2012 +0400
@@ -2,6 +2,7 @@
 
 import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.util.StringUtil;
+import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
 import java.nio.charset.Charset;
@@ -10,6 +11,7 @@
 
 public class MercurialCommandLine extends GeneralCommandLine {
 
+  private String myWorkingDirectory;
   private final Set<String> myPrivateData;
   private Charset myCharset;
 
@@ -43,6 +45,16 @@
     return myCharset != null ? myCharset : super.getCharset();
   }
 
+  @Override
+  public void setWorkDirectory(@NonNls String path) {
+    myWorkingDirectory = path;
+    super.setWorkDirectory(path);
+  }
+
+  public String getWorkingDirectory() {
+    return myWorkingDirectory;
+  }
+
   private String escape(String s) {
     return StringUtil.escapeQuotesIfWindows(s);
   }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,7 +15,6 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
@@ -23,7 +22,6 @@
 import java.io.IOException;
 
 import static com.intellij.openapi.util.io.FileUtil.delete;
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandExecutionSettingsBuilder.with;
 
 /**
  * @author Pavel.Sher
@@ -35,8 +33,11 @@
   private int myTimeout;
   private boolean myTraceback;
 
-  public PullCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public PullCommand(@NotNull CommandSettings commandSettings,
+                     @NotNull String hgPath,
+                     @NotNull File workingDir,
+                     @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
   }
 
   public PullCommand fromRepository(@NotNull String pullUrl) {
@@ -61,13 +62,13 @@
 
   public void call() throws VcsException {
     ensureRepositoryIsNotLocked();
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     cli.addParameter("pull");
     if (myTraceback)
       cli.addParameter("--traceback");
     String pullUrl = myAuthSettings != null ? myAuthSettings.getRepositoryUrlWithCredentials(myPullUrl) : myPullUrl;
     cli.addParameter(pullUrl);
-    runCommand(cli, with().timeout(myTimeout));
+    runCommand(cli, myCommandSettings.setTimeout(myTimeout));
   }
 
   private void ensureRepositoryIsNotLocked() {
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,14 +15,11 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
 
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandExecutionSettingsBuilder.with;
-
 /**
  * @author pavel
  */
@@ -30,8 +27,11 @@
 
   private String myRepositoryUrl;
 
-  public PushCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public PushCommand(@NotNull CommandSettings commandSettings,
+                     @NotNull String hgPath,
+                     @NotNull File workingDir,
+                     @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
   }
 
   public PushCommand toRepository(@NotNull String repositoryUrl) {
@@ -40,10 +40,10 @@
   }
 
   public void call() throws VcsException {
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     cli.addParameter("push");
     String repositoryUrl = myAuthSettings != null ? myAuthSettings.getRepositoryUrlWithCredentials(myRepositoryUrl) : myRepositoryUrl;
     cli.addParameter(repositoryUrl);
-    runCommand(cli, with().failureWhenStderrNotEmpty());
+    runCommand(cli, myCommandSettings.setFailWhenStderrNotEmpty(true));
   }
 }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,7 +15,6 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
@@ -31,8 +30,11 @@
   private boolean myShowAllFiles = false;
   private boolean myHideStatus = false;
 
-  public StatusCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public StatusCommand(@NotNull CommandSettings commandSettings,
+                       @NotNull String hgPath,
+                       @NotNull File workingDir,
+                       @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
   }
 
   public StatusCommand fromRevision(@NotNull ChangeSet fromCset) {
@@ -74,7 +76,7 @@
   }
 
   public List<FileStatus> call() throws VcsException {
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     cli.addParameter("status");
     if (myShowAllFiles)
       cli.addParameter("-A");
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/TagCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/TagCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -27,8 +27,11 @@
   private String myRevId;
   private String myUsername;
 
-  public TagCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir, authSettings);
+  public TagCommand(@NotNull CommandSettings commandSettings,
+                    @NotNull String hgPath,
+                    @NotNull File workingDir,
+                    @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir, authSettings);
   }
 
   public TagCommand tagName(@NotNull String tagName) {
@@ -47,7 +50,7 @@
   }
 
   public void call() throws VcsException {
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     cli.addParameter("tag");
     setUser(cli);
     cli.addParameter("-r");
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/UpdateCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/UpdateCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -22,7 +22,6 @@
 import java.io.File;
 
 import static com.intellij.openapi.util.io.FileUtil.delete;
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandExecutionSettingsBuilder.with;
 
 public class UpdateCommand extends VcsRootCommand {
 
@@ -32,8 +31,11 @@
   private String myBranchName;
   private boolean myTraceback;
 
-  public UpdateCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir,authSettings);
+  public UpdateCommand(@NotNull CommandSettings commandSettings,
+                       @NotNull String hgPath,
+                       @NotNull File workingDir,
+                       @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir,authSettings);
   }
 
   public UpdateCommand branch(@NotNull String branchName) {
@@ -58,7 +60,7 @@
   public void call() throws VcsException {
     ensureWorkingDirIsNotLocked();
 
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     cli.addParameter("update");
     if (myTraceback)
       cli.addParameter("--traceback");
@@ -70,7 +72,7 @@
     } else {
       cli.addParameter(myBranchName);
     }
-    runCommand(cli, with().timeout(UPDATE_TIMEOUT_SECONDS));
+    runCommand(cli, myCommandSettings.setTimeout(UPDATE_TIMEOUT_SECONDS));
   }
 
   private void ensureWorkingDirIsNotLocked() {
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VcsRootCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VcsRootCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -1,6 +1,5 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
@@ -8,8 +7,6 @@
 import java.util.Collections;
 import java.util.Set;
 
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandExecutionSettingsBuilder.with;
-
 /**
  * @author dmitry.neverov
  */
@@ -17,18 +14,22 @@
 
   protected final AuthSettings myAuthSettings;
 
-  public VcsRootCommand(@NotNull String hgPath, @NotNull File workingDir, @NotNull AuthSettings authSettings) {
-    super(hgPath, workingDir);
+  public VcsRootCommand(@NotNull CommandSettings commandSettings,
+                        @NotNull String hgPath,
+                        @NotNull File workingDir,
+                        @NotNull AuthSettings authSettings) {
+    super(commandSettings, hgPath, workingDir);
     myAuthSettings = authSettings;
   }
 
 
-  protected CommandResult runCommand(@NotNull GeneralCommandLine cli) throws VcsException {
-    return CommandUtil.runCommand(cli, with());
+  protected CommandResult runCommand(@NotNull MercurialCommandLine cli) throws VcsException {
+    return CommandUtil.runCommand(cli, myCommandSettings);
   }
 
-  protected CommandResult runCommand(@NotNull GeneralCommandLine cli, @NotNull CommandExecutionSettingsBuilder with) throws VcsException {
-    return CommandUtil.runCommand(cli, with.privateData(getPrivateData()));
+  protected CommandResult runCommand(@NotNull MercurialCommandLine cli, @NotNull CommandSettings s) throws VcsException {
+    s.setPrivateData(getPrivateData());
+    return CommandUtil.runCommand(cli, s);
   }
 
   protected Set<String> getPrivateData() {
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommand.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommand.java	Wed Sep 26 18:29:01 2012 +0400
@@ -15,17 +15,19 @@
  */
 public class VersionCommand extends BaseCommand {
 
-  public VersionCommand(@NotNull final String hgPath, @NotNull File workingDir) {
-    super(hgPath, workingDir);
+  public VersionCommand(@NotNull CommandSettings commandSettings,
+                        @NotNull final String hgPath,
+                        @NotNull File workingDir) {
+    super(commandSettings, hgPath, workingDir);
   }
 
 
   public HgVersion call() throws VcsException, ParseHgVersionException {
-    GeneralCommandLine cli = createCommandLine();
+    MercurialCommandLine cli = createCommandLine();
     cli.addParameter("version");
     cli.addParameter("--quiet");
     setDefaultLocale(cli);
-    CommandResult result = CommandUtil.runCommand(cli);
+    CommandResult result = CommandUtil.runCommand(cli, myCommandSettings);
     return HgVersion.parse(result.getStdout());
   }
 
--- a/mercurial-server/src/META-INF/build-server-plugin-mercurial.xml	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-server/src/META-INF/build-server-plugin-mercurial.xml	Wed Sep 26 18:29:01 2012 +0400
@@ -9,4 +9,5 @@
   <bean id="mirrorManager" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.MirrorManagerImpl" />
   <bean id="hgVcsRootFactory" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.HgVcsRootFactory" />
   <bean id="testConnection" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.HgTestConnectionSupport" />
+  <bean id="commandSettingsFactory" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.ServerCommandSettingsFactory"/>
 </beans>
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialResetCacheHandler.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialResetCacheHandler.java	Wed Sep 26 18:29:01 2012 +0400
@@ -5,7 +5,8 @@
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
-import java.util.*;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import static com.intellij.openapi.util.io.FileUtil.delete;
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java	Wed Sep 26 18:29:01 2012 +0400
@@ -1,6 +1,7 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsFactory;
 import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
@@ -17,18 +18,23 @@
 public final class RepoFactory {
 
   private final ServerPluginConfig myConfig;
+  private final CommandSettingsFactory myCommandSettingsFactory;
   private File myLogTemplate;
   private File myLogNoFilesTemplate;
 
-  public RepoFactory(@NotNull ServerPluginConfig config) throws IOException {
+  public RepoFactory(@NotNull ServerPluginConfig config,
+                     @NotNull CommandSettingsFactory commandSettingsFactory) throws IOException {
     myConfig = config;
+    myCommandSettingsFactory = commandSettingsFactory;
     myLogTemplate = createLogTemplate();
     myLogNoFilesTemplate = createLogNoFilesTemplate();
   }
 
   @NotNull
-  public ServerHgRepo create(@NotNull File workingDir, @NotNull String hgPath, @NotNull AuthSettings authSettings) throws VcsException {
-    return new ServerHgRepo(myConfig, workingDir, hgPath, authSettings).withLogTemplates(getTemplate(), getLogNoFilesTemplate());
+  public ServerHgRepo create(@NotNull File workingDir,
+                             @NotNull String hgPath,
+                             @NotNull AuthSettings authSettings) throws VcsException {
+    return new ServerHgRepo(myCommandSettingsFactory, myConfig, workingDir, hgPath, authSettings).withLogTemplates(getTemplate(), getLogNoFilesTemplate());
   }
 
   public void dispose() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerCommandSettingsFactory.java	Wed Sep 26 18:29:01 2012 +0400
@@ -0,0 +1,11 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettings;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsFactory;
+
+public class ServerCommandSettingsFactory implements CommandSettingsFactory {
+
+  public CommandSettings create() {
+    return new CommandSettings().setLogLevel("debug");
+  }
+}
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgRepo.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgRepo.java	Wed Sep 26 18:29:01 2012 +0400
@@ -14,12 +14,18 @@
 public class ServerHgRepo extends HgRepo {
 
   private final static HgVersion REVSET_HG_VERSION = new HgVersion(1, 7, 0);
+  private final CommandSettingsFactory myCommandSettingsFactory;
   private final ServerPluginConfig myConfig;
   private File myLogTemplate;
   private File myLogNoFilesTemplate;
 
-  public ServerHgRepo(@NotNull ServerPluginConfig config, @NotNull File workingDir, @NotNull String hgPath, @NotNull AuthSettings authSettings) {
-    super(workingDir, hgPath, authSettings);
+  public ServerHgRepo(@NotNull CommandSettingsFactory commandSettingsFactory,
+                      @NotNull ServerPluginConfig config,
+                      @NotNull File workingDir,
+                      @NotNull String hgPath,
+                      @NotNull AuthSettings authSettings) {
+    super(commandSettingsFactory, workingDir, hgPath, authSettings);
+    myCommandSettingsFactory = commandSettingsFactory;
     myConfig = config;
   }
 
@@ -30,7 +36,7 @@
   }
 
   public LogCommand log() {
-    return new LogCommand(myHgPath, myWorkingDir, myAuthSettings).withTemplate(myLogTemplate);
+    return new LogCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings).withTemplate(myLogTemplate);
   }
 
   public MergeBaseCommand mergeBase() throws VcsException {
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -53,7 +53,8 @@
     AgentPluginConfigImpl pluginConfig = new AgentPluginConfigImpl(agentConfig);
     AgentHgPathProvider hgPathProvider = new AgentHgPathProvider(agentConfig);
     myMirrorManager = new MirrorManagerImpl(pluginConfig);
-    myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig, hgPathProvider, myMirrorManager);
+    AgentRepoFactory repoFactory = new AgentRepoFactory(new AgentCommandSettingsFactory());
+    myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig, hgPathProvider, myMirrorManager, repoFactory);
     myCleaner = new AgentMirrorCleaner(myMirrorManager);
     myLogger = myContext.mock(BuildProgressLogger.class);
     myContext.checking(new Expectations() {{
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -72,7 +72,7 @@
     }});
 
     final AgentPluginConfigImpl pluginConfig = new AgentPluginConfigImpl(agentConfig);
-    myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig, new AgentHgPathProvider(agentConfig), new MirrorManagerImpl(pluginConfig));
+    myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig, new AgentHgPathProvider(agentConfig), new MirrorManagerImpl(pluginConfig), new AgentRepoFactory(new AgentCommandSettingsFactory()));
 
     myLogger = myContext.mock(BuildProgressLogger.class);
     myContext.checking(new Expectations() {{
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -71,7 +71,10 @@
 
     final AgentPluginConfigImpl pluginConfig = new AgentPluginConfigImpl(agentConfig);
     myMirrorManager = new MirrorManagerImpl(pluginConfig);
-    myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig, new AgentHgPathProvider(agentConfig), myMirrorManager);
+    myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig,
+            new AgentHgPathProvider(agentConfig),
+            myMirrorManager,
+            new AgentRepoFactory(new AgentCommandSettingsFactory()));
 
     myLogger = myContext.mock(BuildProgressLogger.class);
     myContext.checking(new Expectations() {{
@@ -118,7 +121,7 @@
     doUpdate(root1, "3d6694af00e4", true);
     server1.destroy();
 
-    HgRepo mirror1 = new HgRepo(myMirrorManager.getMirrorDir(url1), getHgPath(), new AuthSettings());
+    HgRepo mirror1 = new HgRepo(new AgentCommandSettingsFactory(), myMirrorManager.getMirrorDir(url1), getHgPath(), new AuthSettings());
     assertTrue("R1 mirror not updated to the latest revision", mirror1.containsRevision("3d6694af00e4"));
 
     try {
@@ -129,7 +132,7 @@
       fail("Contact remote repository when up-to-date subrepo local mirror exists");
     }
 
-    HgRepo mirror2 = new HgRepo(myMirrorManager.getMirrorDir(url2), getHgPath(), new AuthSettings());
+    HgRepo mirror2 = new HgRepo(new AgentCommandSettingsFactory(), myMirrorManager.getMirrorDir(url2), getHgPath(), new AuthSettings());
     assertTrue("R2 mirror not updated to the latest revision", mirror2.containsRevision("7de2f844e1a2"));
   }
 
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -254,11 +254,11 @@
     assertEquals(actualTag, "new_tag");
 
     // check the tag is pushed to the parent repository
-    GeneralCommandLine cli = new GeneralCommandLine();
+    MercurialCommandLine cli = new MercurialCommandLine();
     cli.setExePath(vcsRoot.getProperty(Constants.HG_COMMAND_PATH_PROP));
     cli.setWorkDirectory(vcsRoot.getProperty(Constants.REPOSITORY_PROP));
     cli.addParameter("tags");
-    CommandResult res = CommandUtil.runCommand(cli);
+    CommandResult res = CommandUtil.runCommand(cli, new CommandSettings());
     assertTrue(res.getStdout().contains("new_tag"));
     assertTrue(res.getStdout().contains("1:1d446e82d356"));
   }
@@ -270,11 +270,11 @@
     assertEquals(actualTag, "branch_tag");
 
     // check the tag is pushed to the parent repository
-    GeneralCommandLine cli = new GeneralCommandLine();
+    MercurialCommandLine cli = new MercurialCommandLine();
     cli.setExePath(vcsRoot.getProperty(Constants.HG_COMMAND_PATH_PROP));
     cli.setWorkDirectory(vcsRoot.getProperty(Constants.REPOSITORY_PROP));
     cli.addParameter("tags");
-    CommandResult res = CommandUtil.runCommand(cli);
+    CommandResult res = CommandUtil.runCommand(cli, new CommandSettings());
     assertTrue(res.getStdout().contains("branch_tag"));
     assertTrue(res.getStdout().contains("7:376dcf05cd2a"));
   }
@@ -552,13 +552,13 @@
 
 
   public void hg_version_should_not_depend_on_locale() throws IOException, VcsException {
-    HgRepo repo = new HgRepo(new File(simpleRepo()), Util.getHgPath(), new AuthSettings(null, null));
+    HgRepo repo = new HgRepo(new ServerCommandSettingsFactory(), new File(simpleRepo()), Util.getHgPath(), new AuthSettings(null, null));
     HgVersion defaultLocaleVersion = repo.version().call();
 
-    VersionCommand russianLocalVersion = new VersionCommand(Util.getHgPath(), new File(simpleRepo())) {
+    VersionCommand russianLocalVersion = new VersionCommand(new ServerCommandSettingsFactory().create(), Util.getHgPath(), new File(simpleRepo())) {
       @Override
-      protected GeneralCommandLine createCommandLine() {
-        GeneralCommandLine commandLine = super.createCommandLine();
+      protected MercurialCommandLine createCommandLine() {
+        MercurialCommandLine commandLine = super.createCommandLine();
         Map<String, String> env = commandLine.getEnvParams();
         if (env == null)
           env = new HashMap<String, String>();
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -3,6 +3,7 @@
 import com.intellij.openapi.diagnostic.Logger;
 import jetbrains.buildServer.TempFiles;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.log.Log4jFactory;
 import jetbrains.buildServer.vcs.*;
 import jetbrains.buildServer.vcs.patches.PatchTestCase;
@@ -139,7 +140,7 @@
   }
 
   private HgRepo createRepo(@NotNull File dir) throws IOException {
-    return new HgRepo(dir, Util.getHgPath(), new AuthSettings());
+    return new HgRepo(new TestCommandSettingsFactory(), dir, Util.getHgPath(), new AuthSettings());
   }
 
 }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java	Wed Sep 26 18:29:01 2012 +0400
@@ -40,7 +40,7 @@
 
 
   public static MercurialVcsSupport createMercurialServerSupport(@NotNull Mockery context, ServerPluginConfig config) throws IOException {
-    return createMercurialServerSupport(context, config, new RepoFactory(config));
+    return createMercurialServerSupport(context, config, new RepoFactory(config, new ServerCommandSettingsFactory()));
   }
 
 
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -16,7 +16,7 @@
 
   public void should_quote_command_line_arguments() throws IOException {
     File workingDir = new File("some dir");
-    BaseCommand command = new BaseCommand("/path/to/hg", workingDir);
+    BaseCommand command = new BaseCommand(new CommandSettings(), "/path/to/hg", workingDir);
     GeneralCommandLine cl = command.createCommandLine();
     cl.addParameter("param with spaces");
     cl.addParameter("param with quote \" rm -rf /");
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java	Wed Sep 26 18:29:01 2012 +0400
@@ -35,6 +35,7 @@
   private String myUsername;
   private String myPassword;
   private boolean myCloneRequired;
+  protected CommandSettingsFactory myCommandSettingsFactory = new TestCommandSettingsFactory();
 
   public BaseCommandTestCase() {
   }
@@ -81,7 +82,7 @@
     root.setCustomWorkingDir(workingDir);
     try {
       if (myCloneRequired) {
-        new HgRepo(workingDir, hgPathProvider.getHgPath(root), root.getAuthSettings()).doClone().fromRepository(root.getRepository()).call();
+        new HgRepo(myCommandSettingsFactory, workingDir, hgPathProvider.getHgPath(root), root.getAuthSettings()).doClone().fromRepository(root.getRepository()).call();
       }
 
       return executor.execute(root, hgPathProvider, workingDir);
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -40,7 +40,7 @@
     setRepository("mercurial-tests/testData/rep1", true);
     runCommand(new CommandExecutor<File>() {
       public File execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
-        return new CatCommand(hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings()).files("/non/existing/path").checkForFailure(false).call();
+        return new CatCommand(new CommandSettings(), hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings()).files("/non/existing/path").checkForFailure(false).call();
       }
     });
   }
@@ -67,7 +67,7 @@
   private File runCat(@NotNull final List<String> paths) throws IOException, VcsException {
     return runCommand(new CommandExecutor<File>() {
       public File execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
-        CatCommand cat = new CatCommand(hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings());
+        CatCommand cat = new CatCommand(new CommandSettings(), hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings());
         return cat.execute(paths);
       }
     });
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -49,7 +49,7 @@
     HgVcsRoot hgRoot = new HgVcsRoot(root);
     hgRoot.setCustomWorkingDir(workingDir);
 
-    new CloneCommand(hgPathProvider.getHgPath(hgRoot), workingDir, hgRoot.getAuthSettings()).fromRepository(hgRoot.getRepository()).call();
+    new CloneCommand(new CommandSettings(), 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	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java	Wed Sep 26 18:29:01 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(hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings())
+        new IdentifyCommand(new CommandSettings(), hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings())
                 .revision(cset)
                 .inLocalRepository()
                 .call();
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -175,7 +175,7 @@
   private List<ChangeSet> runLog(final String fromId, final String toId) throws IOException, VcsException {
     return runCommand(new CommandExecutor<List<ChangeSet>>() {
       public List<ChangeSet> execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
-        return new LogCommand(hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings())
+        return new LogCommand(myCommandSettingsFactory.create(), hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings())
                 .inBranch(root.getBranchName())
                 .withTemplate(myTemplateFile)
                 .fromRevision(fromId)
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommandTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommandTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -37,7 +37,7 @@
     try {
       runCommand(new CommandExecutor<Boolean>() {
         public Boolean execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
-          new PushCommand(hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings()).toRepository(root.getRepository()).call();
+          new PushCommand(myCommandSettingsFactory.create(), hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings()).toRepository(root.getRepository()).call();
           return null;
         }
       });
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommandTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommandTest.java	Wed Sep 26 18:29:01 2012 +0400
@@ -56,7 +56,7 @@
   private List<FileStatus> runStatus(final String fromId, final String toId) throws IOException, VcsException {
     return runCommand(new CommandExecutor<List<FileStatus>>() {
       public List<FileStatus> execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
-        return new StatusCommand(hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings())
+        return new StatusCommand(myCommandSettingsFactory.create(), hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings())
                 .fromRevision(fromId)
                 .toRevision(toId)
                 .call();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/TestCommandSettingsFactory.java	Wed Sep 26 18:29:01 2012 +0400
@@ -0,0 +1,8 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
+
+public class TestCommandSettingsFactory implements CommandSettingsFactory {
+
+  public CommandSettings create() {
+    return new CommandSettings();
+  }
+}
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommandTest.java	Wed Sep 26 14:58:55 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommandTest.java	Wed Sep 26 18:29:01 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(hgPathProvider.getHgPath(hgRoot), new File(".."));
+    VersionCommand versionCommand = new VersionCommand(new CommandSettings(), hgPathProvider.getHgPath(hgRoot), new File(".."));
     HgVersion version = versionCommand.call();
     assertNotNull(version);
   }