changeset 429:04eab204ba39

Remove HgVcsRoot's dependency on HgPathProvider
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Fri, 11 May 2012 16:37:00 +0400
parents a68741340603
children 3600b68a4c0c
files mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleaner.java mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommand.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Cleanup.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CleanupTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProviderTest.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/VersionCommandTest.java
diffstat 19 files changed, 65 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleaner.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleaner.java	Fri May 11 16:37:00 2012 +0400
@@ -23,12 +23,9 @@
 
   private final static Logger ourLog = Logger.getInstance(AgentMirrorCleaner.class.getName());
   private final MirrorManager myMirrorManager;
-  private final HgPathProvider myHgPathProvider;
 
-  public AgentMirrorCleaner(@NotNull final MirrorManager mirrorManager,
-                            @NotNull final HgPathProvider hgPathProvider) {
+  public AgentMirrorCleaner(@NotNull final MirrorManager mirrorManager) {
     myMirrorManager = mirrorManager;
-    myHgPathProvider = hgPathProvider;
   }
 
   @NotNull
@@ -53,7 +50,7 @@
     Set<String> repositories = new HashSet<String>();
     for (VcsRootEntry entry : context.getRunningBuild().getVcsRootEntries()) {
       VcsRoot root = entry.getVcsRoot();
-      HgVcsRoot hgRoot = new HgVcsRoot(myHgPathProvider, root);
+      HgVcsRoot hgRoot = new HgVcsRoot(root);
       AuthSettings auth = hgRoot.getAuthSettings();
       ourLog.debug("Repository " + auth.getRepositoryUrlWithHiddenPassword(hgRoot.getRepository()) +
               " is used in the build, its mirror won't be cleaned");
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java	Fri May 11 16:37:00 2012 +0400
@@ -40,9 +40,9 @@
                                      @NotNull final AgentRunningBuild build) {
     myConfig = pluginConfig;
     myMirrorManager = mirrorManager;
-    myRoot = new HgVcsRoot(hgPathProvider, root);
+    myRoot = new HgVcsRoot(root);
     myAuthSettings = myRoot.getAuthSettings();
-    myHgPath = myRoot.getHgCommandPath();
+    myHgPath = hgPathProvider.getHgPath(myRoot);
     myToVersion = toVersion;
     myLogger = build.getBuildLogger();
     myUseLocalMirrors = myConfig.isUseLocalMirrors(build);
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java	Fri May 11 16:37:00 2012 +0400
@@ -16,7 +16,6 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants;
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgPathProvider;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.PathUtil;
 import jetbrains.buildServer.util.StringUtil;
 import jetbrains.buildServer.vcs.VcsRoot;
@@ -33,7 +32,6 @@
 
   private static final String DEFAULT_BRANCH_NAME = "default";
 
-  private final HgPathProvider myHgPathProvider;
   private final VcsRoot myRoot;
   private final String myRepository;
   private final String myHgCommandPath;
@@ -44,8 +42,7 @@
   private final AuthSettings myAuthSettings;
   private File myCustomWorkingDir;
 
-  public HgVcsRoot(@NotNull final HgPathProvider hgPathProvider, @NotNull final VcsRoot vcsRoot) {
-    myHgPathProvider = hgPathProvider;
+  public HgVcsRoot(@NotNull final VcsRoot vcsRoot) {
     myRoot = vcsRoot;
     myRepository = getProperty(Constants.REPOSITORY_PROP);
     myHgCommandPath = getProperty(Constants.HG_COMMAND_PATH_PROP);
@@ -78,14 +75,6 @@
   }
 
   /**
-   * @return path to hg command taking into account server-wide/agent-wide settings
-   */
-  @NotNull
-  public String getHgCommandPath() {
-    return myHgPathProvider.getHgPath(this);
-  }
-
-  /**
    * @return path to hg command as it is set in VCS root settings
    */
   public String getHgPath() {
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommand.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommand.java	Fri May 11 16:37:00 2012 +0400
@@ -13,11 +13,6 @@
  */
 public class VersionCommand extends BaseCommand {
 
-  public VersionCommand(@NotNull final HgVcsRoot root, @NotNull File workingDir) {
-    super(root.getHgCommandPath(), workingDir);
-  }
-
-
   public VersionCommand(@NotNull final String hgPath, @NotNull File workingDir) {
     super(hgPath, workingDir);
   }
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Cleanup.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Cleanup.java	Fri May 11 16:37:00 2012 +0400
@@ -24,16 +24,13 @@
   private final VcsManager myVcsManager;
   private final MirrorManager myMirrorManager;
   private final PluginConfig myConfig;
-  private final HgPathProvider myHgPathProvider;
 
   public Cleanup(@NotNull final VcsManager vcsManager,
                  @NotNull final MirrorManager mirrorManager,
-                 @NotNull final PluginConfig config,
-                 @NotNull final HgPathProvider hgPathProvider) {
+                 @NotNull final PluginConfig config) {
     myVcsManager = vcsManager;
     myMirrorManager = mirrorManager;
     myConfig = config;
-    myHgPathProvider = hgPathProvider;
   }
 
   public void run() {
@@ -68,18 +65,14 @@
     Map<String, File> mirrorMap = myMirrorManager.getMappings();
     List<File> result = new ArrayList<File>();
     for (VcsRoot root : mercurialVcsRoots()) {
-      File mirrorDir = mirrorMap.get(urlOf(root));
+      HgVcsRoot hgRoot = new HgVcsRoot(root);
+      File mirrorDir = mirrorMap.get(hgRoot.getRepository());
       if (mirrorDir != null)
         result.add(mirrorDir);
     }
     return result;
   }
 
-  private String urlOf(@NotNull VcsRoot root) {
-    HgVcsRoot hgRoot = new HgVcsRoot(myHgPathProvider, root);
-    return hgRoot.getRepository();
-  }
-
   private Collection<VcsRoot> mercurialVcsRoots() {
     List<VcsRoot> mercurialRoots = new ArrayList<VcsRoot>();
     for (VcsRoot root : myVcsManager.getAllRegisteredVcsRoots()) {
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Fri May 11 16:37:00 2012 +0400
@@ -79,7 +79,7 @@
     dispatcher.addListener(new BuildServerAdapter() {
       @Override
       public void cleanupFinished() {
-        server.getExecutor().submit(new Cleanup(myVcsManager, myMirrorManager, myConfig, myHgPathProvider));
+        server.getExecutor().submit(new Cleanup(myVcsManager, myMirrorManager, myConfig));
       }
 
       @Override
@@ -241,7 +241,7 @@
                 .withAuthSettings(root.getAuthSettings())
                 .call();
         StringBuilder res = new StringBuilder();
-        res.append(quoteIfNeeded(root.getHgCommandPath()));
+        res.append(quoteIfNeeded(myHgPathProvider.getHgPath(root)));
         res.append(" identify ");
         res.append(quoteIfNeeded(root.getAuthSettings().getRepositoryUrlWithHiddenPassword(root.getRepository())));
         res.append('\n').append(idResult);
@@ -704,7 +704,7 @@
   }
 
   private HgVcsRoot createHgRoot(@NotNull VcsRoot root) throws VcsException {
-    HgVcsRoot hgRoot = new HgVcsRoot(myHgPathProvider, root);
+    HgVcsRoot hgRoot = new HgVcsRoot(root);
     String customClonePath = hgRoot.getCustomClonePath();
     if (!StringUtil.isEmptyOrSpaces(customClonePath) && !myDefaultWorkFolderParent.equals(new File(customClonePath).getAbsoluteFile())) {
       File parentDir = new File(customClonePath);
@@ -767,11 +767,11 @@
   }
 
   private ServerHgRepo createRepo(@NotNull HgVcsRoot root) throws VcsException {
-    return myRepoFactory.create(getWorkingDir(root), root.getHgCommandPath(), root.getAuthSettings());
+    return myRepoFactory.create(getWorkingDir(root), myHgPathProvider.getHgPath(root), root.getAuthSettings());
   }
 
   private HgRepo createRepo(@NotNull HgVcsRoot root, @NotNull File customDir) throws VcsException {
-    return myRepoFactory.create(customDir, root.getHgCommandPath(), root.getAuthSettings());
+    return myRepoFactory.create(customDir, myHgPathProvider.getHgPath(root), root.getAuthSettings());
   }
 
   @NotNull
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java	Fri May 11 16:37:00 2012 +0400
@@ -54,7 +54,7 @@
     AgentHgPathProvider hgPathProvider = new AgentHgPathProvider(agentConfig);
     myMirrorManager = new MirrorManagerImpl(pluginConfig);
     myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig, hgPathProvider, myMirrorManager);
-    myCleaner = new AgentMirrorCleaner(myMirrorManager, hgPathProvider);
+    myCleaner = new AgentMirrorCleaner(myMirrorManager);
     myLogger = myContext.mock(BuildProgressLogger.class);
     myContext.checking(new Expectations() {{
       allowing(myLogger).message(with(any(String.class)));
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CleanupTest.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CleanupTest.java	Fri May 11 16:37:00 2012 +0400
@@ -48,7 +48,7 @@
     myMirrorManager = new MirrorManagerImpl(config);
 
     myVcsManager = myContext.mock(VcsManager.class);
-    myCleanup = new Cleanup(myVcsManager, myMirrorManager, config, new ServerHgPathProvider(config));
+    myCleanup = new Cleanup(myVcsManager, myMirrorManager, config);
   }
 
   @AfterMethod
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootTest.java	Fri May 11 16:37:00 2012 +0400
@@ -16,10 +16,8 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot;
-import jetbrains.buildServer.vcs.VcsRoot;
 import jetbrains.buildServer.vcs.impl.VcsRootImpl;
 import junit.framework.TestCase;
-import org.jetbrains.annotations.NotNull;
 import org.testng.annotations.Test;
 
 /**
@@ -30,78 +28,78 @@
 
   public void test_url_without_credentials() {
     VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials());
   }
 
   public void test_url_with_credentials() {
     VcsRootImpl vcsRoot = createVcsRoot("http://user:pwd@host.com/path");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials());
   }
 
   public void test_url_with_username() {
     VcsRootImpl vcsRoot = createVcsRoot("http://user@host.com/path");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     assertEquals("http://user:pwd@host.com/path", root.getRepositoryUrlWithCredentials());
   }
 
   public void test_url_with_at_after_slash() {
     VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path@");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     assertEquals("http://user:pwd@host.com/path@", root.getRepositoryUrlWithCredentials());
   }
 
   public void test_url_with_at_in_username() {
     VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path", "my.name@gmail.com", "1234");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     assertEquals("http://my.name%40gmail.com:1234@host.com/path", root.getRepositoryUrlWithCredentials());
   }
 
   /** TW-13768 */
   public void test_underscore_in_host() {
 		VcsRootImpl vcsRoot = createVcsRoot("http://Klekovkin.SDK_GARANT:8000/", "my.name@gmail.com", "1234");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
 		assertEquals("http://my.name%40gmail.com:1234@Klekovkin.SDK_GARANT:8000/", root.getRepositoryUrlWithCredentials());
 	}
 
   /** TW-13768 */
   public void test_underscore_in_host_with_credentials_in_url() {
     VcsRootImpl vcsRoot = createVcsRoot("http://me:mypass@Klekovkin.SDK_GARANT:8000/");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
 		assertEquals("http://me:mypass@Klekovkin.SDK_GARANT:8000/", root.getRepositoryUrlWithCredentials());
   }
 
   public void test_windows_path() throws Exception {
     VcsRootImpl vcsRoot = createVcsRoot("c:\\windows\\path");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     assertEquals("c:\\windows\\path", root.getRepositoryUrlWithCredentials());
   }
 
   public void test_file_scheme_has_no_credentials() {
     VcsRootImpl vcsRoot = createVcsRoot("file:///path/to/repo", "my.name@gmail.com", "1234");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     assertEquals("file:///path/to/repo", root.getRepositoryUrlWithCredentials());
   }
 
   public void uncompressed_transfer() {
     VcsRootImpl vcsRoot = createVcsRoot("http://host.com/path");
     vcsRoot.addProperty(Constants.UNCOMPRESSED_TRANSFER, "true");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     assertTrue(root.isUncompressedTransfer());
   }
 
   //TW-18262
   public void ampersand_in_password() {
     VcsRootImpl vcsRoot = createVcsRoot("http://some.org/path", "user", "m&n");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     assertEquals("http://user:m%26n@some.org/path", root.getRepositoryUrlWithCredentials());
   }
 
   //TW-18835
   public void test_ssh() {
     VcsRootImpl vcsRoot = createVcsRoot("ssh://ourserver.com/mercurialrepo/", "user", "pwd");
-    HgVcsRoot root = createHgRoot(vcsRoot);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     assertEquals("ssh://user:pwd@ourserver.com/mercurialrepo/", root.getRepositoryUrlWithCredentials());
   }
 
@@ -117,9 +115,4 @@
     vcsRoot.addProperty(Constants.PASSWORD, password);
     return vcsRoot;
   }
-
-  private HgVcsRoot createHgRoot(@NotNull final VcsRoot root) {
-    ServerPluginConfig config = new ServerPluginConfigBuilder().build();
-    return new HgVcsRoot(new ServerHgPathProvider(config), root);
-  }
 }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java	Fri May 11 16:37:00 2012 +0400
@@ -365,15 +365,15 @@
     VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
     String repPath = vcsRoot.getProperty(Constants.REPOSITORY_PROP);
     vcsRoot.addProperty(Constants.REPOSITORY_PROP, repPath + "#test_branch");
-    HgVcsRoot hgRoot = new HgVcsRoot(new ServerHgPathProvider(myPluginConfig), vcsRoot);
+    HgVcsRoot hgRoot = new HgVcsRoot(vcsRoot);
     assertEquals("test_branch", hgRoot.getBranchName());
 
     vcsRoot.addProperty(Constants.REPOSITORY_PROP, repPath + "#");
-    hgRoot = new HgVcsRoot(new ServerHgPathProvider(myPluginConfig), vcsRoot);
+    hgRoot = new HgVcsRoot(vcsRoot);
     assertEquals("default", hgRoot.getBranchName());
 
     vcsRoot.addProperty(Constants.REPOSITORY_PROP, repPath);
-    hgRoot = new HgVcsRoot(new ServerHgPathProvider(myPluginConfig), vcsRoot);
+    hgRoot = new HgVcsRoot(vcsRoot);
     assertEquals("default", hgRoot.getBranchName());
   }
 
@@ -485,7 +485,7 @@
     VcsRootImpl root = new VcsRootImpl(1, Constants.VCS_NAME);
     root.addAllProperties(myVcs.getDefaultVcsProperties());
     root.addProperty(Constants.REPOSITORY_PROP, "http://host.com/path");
-    HgVcsRoot hgRoot = new HgVcsRoot(new ServerHgPathProvider(myPluginConfig), root);
+    HgVcsRoot hgRoot = new HgVcsRoot(root);
     assertFalse(hgRoot.isUncompressedTransfer());
   }
 
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProviderTest.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProviderTest.java	Fri May 11 16:37:00 2012 +0400
@@ -1,7 +1,6 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot;
-import jetbrains.buildServer.vcs.impl.VcsRootImpl;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -27,16 +26,16 @@
   public void server_should_use_settings_from_vcs_root_if_server_wide_path_is_not_set() throws Exception {
     myServerWideHgPath = null;
     HgPathProvider provider = createHgPathProvider();
-    HgVcsRoot hgRoot = createSettings(provider);
-    assertEquals(myVcsRootHgPath, provider.getHgPath(hgRoot));
+    HgVcsRoot root = createHgRoot();
+    assertEquals(myVcsRootHgPath, provider.getHgPath(root));
   }
 
 
   public void server_should_use_server_wide_path_if_it_is_set() throws Exception {
     myServerWideHgPath = "/server-wide/hg/path";
     HgPathProvider provider = createHgPathProvider();
-    HgVcsRoot hgRoot = createSettings(provider);
-    assertEquals(myServerWideHgPath, provider.getHgPath(hgRoot));
+    HgVcsRoot root = createHgRoot();
+    assertEquals(myServerWideHgPath, provider.getHgPath(root));
   }
 
 
@@ -46,9 +45,8 @@
   }
 
 
-  private HgVcsRoot createSettings(HgPathProvider hgPathProvider) throws Exception {
-    VcsRootImpl root = new VcsRootBuilder().withHgPath(myVcsRootHgPath).build();
-    return new HgVcsRoot(hgPathProvider, root);
+  private HgVcsRoot createHgRoot() throws Exception {
+    return new HgVcsRoot(new VcsRootBuilder().withHgPath(myVcsRootHgPath).build());
   }
 
 }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTestCase.java	Fri May 11 16:37:00 2012 +0400
@@ -72,21 +72,22 @@
     VcsRoot vcsRoot = new VcsRootImpl(1, vcsRootProps);
     ServerPluginConfig config = new ServerPluginConfigBuilder().cachesDir(tf.createTempDir()).build();
     MirrorManager mirrorManager = new MirrorManagerImpl(config);
-    HgVcsRoot root = new HgVcsRoot(new ServerHgPathProvider(config), vcsRoot);
+    ServerHgPathProvider hgPathProvider = new ServerHgPathProvider(config);
+    HgVcsRoot root = new HgVcsRoot(vcsRoot);
     final File workingDir = mirrorManager.getMirrorDir(root.getRepository());
     root.setCustomWorkingDir(workingDir);
     try {
       if (myCloneRequired) {
-        new HgRepo(workingDir, root.getHgCommandPath(), root.getAuthSettings()).doClone().fromRepository(root.getRepository()).call();
+        new HgRepo(workingDir, hgPathProvider.getHgPath(root), root.getAuthSettings()).doClone().fromRepository(root.getRepository()).call();
       }
 
-      return executor.execute(root, workingDir);
+      return executor.execute(root, hgPathProvider, workingDir);
     } finally {
       tf.cleanup();
     }
   }
 
   public interface CommandExecutor<T> {
-    T execute(@NotNull HgVcsRoot root, File workingDir) throws VcsException;
+    T execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException;
   }
 }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CatCommandTest.java	Fri May 11 16:37:00 2012 +0400
@@ -1,5 +1,6 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgPathProvider;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.UnknownFileException;
 import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.vcs.VcsException;
@@ -38,8 +39,8 @@
     cleanCatResultDirs();
     setRepository("mercurial-tests/testData/rep1", true);
     runCommand(new CommandExecutor<File>() {
-      public File execute(@NotNull final HgVcsRoot root, @NotNull final File workingDir) throws VcsException {
-        return new CatCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings()).files("/non/existing/path").checkForFailure(false).call();
+      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();
       }
     });
   }
@@ -65,8 +66,8 @@
 
   private File runCat(@NotNull final List<String> paths) throws IOException, VcsException {
     return runCommand(new CommandExecutor<File>() {
-      public File execute(@NotNull final HgVcsRoot root, @NotNull final File workingDir) throws VcsException {
-        CatCommand cat = new CatCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings());
+      public File execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
+        CatCommand cat = new CatCommand(hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings());
         return cat.execute(paths);
       }
     });
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java	Fri May 11 16:37:00 2012 +0400
@@ -43,10 +43,11 @@
 
     File workingDir = myTempFiles.createTempDir();
     ServerPluginConfig config = new ServerPluginConfigBuilder().cachesDir(myTempFiles.createTempDir()).build();
-    HgVcsRoot hgRoot = new HgVcsRoot(new ServerHgPathProvider(config), root);
+    ServerHgPathProvider hgPathProvider = new ServerHgPathProvider(config);
+    HgVcsRoot hgRoot = new HgVcsRoot(root);
     hgRoot.setCustomWorkingDir(workingDir);
 
-    new CloneCommand(hgRoot.getHgCommandPath(), workingDir, hgRoot.getAuthSettings()).fromRepository(hgRoot.getRepository()).call();
+    new CloneCommand(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	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java	Fri May 11 16:37:00 2012 +0400
@@ -1,5 +1,6 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgPathProvider;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 import org.testng.annotations.Test;
@@ -36,8 +37,8 @@
 
   private Void runIdentify(final ChangeSet cset) throws IOException, VcsException {
     return runCommand(new CommandExecutor<Void>() {
-      public Void execute(@NotNull final HgVcsRoot root, File workingDir) throws VcsException {
-        new IdentifyCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings())
+      public Void execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
+        new IdentifyCommand(hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings())
                 .revision(cset)
                 .inLocalRepository()
                 .call();
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/LogCommandTest.java	Fri May 11 16:37:00 2012 +0400
@@ -16,6 +16,7 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
 import jetbrains.buildServer.TempFiles;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgPathProvider;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialVcsSupport;
 import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.vcs.VcsException;
@@ -173,8 +174,8 @@
 
   private List<ChangeSet> runLog(final String fromId, final String toId) throws IOException, VcsException {
     return runCommand(new CommandExecutor<List<ChangeSet>>() {
-      public List<ChangeSet> execute(@NotNull final HgVcsRoot root, @NotNull File workingDir) throws VcsException {
-        return new LogCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings())
+      public List<ChangeSet> execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
+        return new LogCommand(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	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PushCommandTest.java	Fri May 11 16:37:00 2012 +0400
@@ -15,6 +15,7 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgPathProvider;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 import org.testng.annotations.Test;
@@ -35,8 +36,8 @@
 
     try {
       runCommand(new CommandExecutor<Boolean>() {
-        public Boolean execute(@NotNull final HgVcsRoot root, @NotNull File workingDir) throws VcsException {
-          new PushCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings()).toRepository(root.getRepository()).call();
+        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();
           return null;
         }
       });
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommandTest.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/StatusCommandTest.java	Fri May 11 16:37:00 2012 +0400
@@ -15,6 +15,7 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgPathProvider;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 import org.testng.annotations.Test;
@@ -54,8 +55,8 @@
 
   private List<FileStatus> runStatus(final String fromId, final String toId) throws IOException, VcsException {
     return runCommand(new CommandExecutor<List<FileStatus>>() {
-      public List<FileStatus> execute(@NotNull final HgVcsRoot root, @NotNull final File workingDir) throws VcsException {
-        return new StatusCommand(root.getHgCommandPath(), workingDir, root.getAuthSettings())
+      public List<FileStatus> execute(@NotNull HgVcsRoot root, @NotNull HgPathProvider hgPathProvider, @NotNull File workingDir) throws VcsException {
+        return new StatusCommand(hgPathProvider.getHgPath(root), workingDir, root.getAuthSettings())
                 .fromRevision(fromId)
                 .toRevision(toId)
                 .call();
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommandTest.java	Fri May 11 16:05:21 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VersionCommandTest.java	Fri May 11 16:37:00 2012 +0400
@@ -16,8 +16,9 @@
   public void test() throws Exception {
     VcsRootImpl root = new VcsRootBuilder().withUrl("some/repository").build();
     ServerPluginConfig config = new ServerPluginConfigBuilder().build();
-    HgVcsRoot hgRoot = new HgVcsRoot(new ServerHgPathProvider(config), root);
-    VersionCommand versionCommand = new VersionCommand(hgRoot, new File(".."));
+    final ServerHgPathProvider hgPathProvider = new ServerHgPathProvider(config);
+    HgVcsRoot hgRoot = new HgVcsRoot(root);
+    VersionCommand versionCommand = new VersionCommand(hgPathProvider.getHgPath(hgRoot), new File(".."));
     HgVersion version = versionCommand.call();
     assertNotNull(version);
   }