changeset 742:091667cc54d5

assert HG version is supported for the command
author eugene.petrenko@jetbrains.com
date Mon, 27 Jan 2014 13:27:26 +0100
parents fba173530aa6
children ff89f023a3c8
files mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommitsAndMountPointsCommand.java
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java	Fri Jan 24 22:18:19 2014 +0100
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java	Mon Jan 27 13:27:26 2014 +0100
@@ -79,7 +79,7 @@
 
   @NotNull
   public CommitsAndMountPointsCommand logSubstates() throws VcsException {
-    return new CommitsAndMountPointsCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
+    return new CommitsAndMountPointsCommand(this, myCommandSettingsFactory.create(), myHgPath, myWorkingDir, myAuthSettings);
   }
 
   public UpdateCommand update() {
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommitsAndMountPointsCommand.java	Fri Jan 24 22:18:19 2014 +0100
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommitsAndMountPointsCommand.java	Mon Jan 27 13:27:26 2014 +0100
@@ -16,8 +16,9 @@
 
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
-import com.intellij.openapi.diagnostic.Logger;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgFileUtil;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgRepo;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.HgVersion;
 import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
@@ -36,13 +37,16 @@
  * @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
  */
 public class CommitsAndMountPointsCommand extends VcsRootCommand {
-  private static final Logger LOG = Logger.getInstance(CommitsAndMountPointsCommand.class.getName());
+  private static final HgVersion REQUIRED_VERSION = new HgVersion(2, 0, 0);
+  private final HgRepo myRepo;
 
-  public CommitsAndMountPointsCommand(@NotNull final CommandSettings commandSettings,
+  public CommitsAndMountPointsCommand(@NotNull final HgRepo hgRepo,
+                                      @NotNull final CommandSettings commandSettings,
                                       @NotNull final String hgPath,
                                       @NotNull final File workingDir,
                                       @NotNull final AuthSettings authSettings) {
     super(commandSettings.addHgEnv("HGENCODING", "UTF-8"), hgPath, workingDir, authSettings);
+    myRepo = hgRepo;
   }
 
   @NotNull
@@ -69,6 +73,11 @@
   }
 
   public void call(@NotNull final Callback consumer) throws VcsException {
+    final HgVersion hgVersion = myRepo.version().call();
+    if (!hgVersion.isEqualsOrGreaterThan(REQUIRED_VERSION)) {
+      throw new VcsException("Current mercurial version is " + hgVersion + ", please use " + REQUIRED_VERSION + " or newer");
+    }
+
     final File root = createTmpDir();
 
     try {