changeset 116:1c7e94c0ad2f

Add ability to use mercurial installed on the system. We bundle hg.exe for tests, but it doesn't work on linux. Add ability to set hg executable to use in our tests in the same way as it done in git-plugin
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Mon, 23 Aug 2010 16:18:54 +0400
parents d5fe3d08be74
children 345fe6e101b7
files mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Constants.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Constants.java	Fri Jul 30 20:03:51 2010 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Constants.java	Mon Aug 23 16:18:54 2010 +0400
@@ -22,6 +22,7 @@
   String REPOSITORY_PROP = "repositoryPath";
   String BRANCH_NAME_PROP = "branchName";
   String HG_COMMAND_PATH_PROP = "hgCommandPath";
+  String HG_PATH_ENV = "TEAMCITY_HG_PATH";
   String SERVER_CLONE_PATH_PROP = "serverClonePath";
   String USERNAME = "username";
   String PASSWORD = VcsRoot.SECURE_PROPERTY_PREFIX + "password";
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java	Fri Jul 30 20:03:51 2010 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/BaseMercurialTestCase.java	Mon Aug 23 16:18:54 2010 +0400
@@ -52,12 +52,21 @@
 
   protected VcsRootImpl createVcsRoot(@NotNull String repPath) throws IOException {
     VcsRootImpl vcsRoot = new VcsRootImpl(1, Constants.VCS_NAME);
-    vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, new File("mercurial-tests/testData/bin/hg.exe").getAbsolutePath());
+    vcsRoot.addProperty(Constants.HG_COMMAND_PATH_PROP, new File(getHgPath()).getAbsolutePath());
     File repository = LocalRepositoryUtil.prepareRepository(repPath);
     vcsRoot.addProperty(Constants.REPOSITORY_PROP, repository.getAbsolutePath());
     return vcsRoot;
   }
 
+  private String getHgPath() throws IOException {
+    String providedHg = System.getenv(Constants.HG_PATH_ENV);
+    if (providedHg != null) {
+      return providedHg;
+    } else {
+      return "mercurial-tests/testData/bin/hg.exe";
+    }
+  }
+
   protected VcsRootImpl createVcsRoot(@NotNull String repPath, @NotNull String branchName) throws IOException {
     VcsRootImpl vcsRoot = createVcsRoot(repPath);
     vcsRoot.addProperty(Constants.BRANCH_NAME_PROP, branchName);