changeset 939:7528d38018b1

merge
author Dmitry Neverov <dmitry.neverov@gmail.com>
date Wed, 09 Dec 2015 13:07:03 +0100
parents ecf83680273e (diff) 12ea02234103 (current diff)
children 9ad288b299ea
files
diffstat 2 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java	Wed Dec 09 13:05:16 2015 +0100
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java	Wed Dec 09 13:07:03 2015 +0100
@@ -56,8 +56,8 @@
 
   @NotNull
   @Override
-  public AgentCheckoutAbility canCheckout(@NotNull VcsRootEntry vcsRoot, @NotNull AgentRunningBuild build) {
-    CheckoutInfo info = new CheckoutInfo(myRepoFactory, new HgVcsRoot(vcsRoot.getVcsRoot()), vcsRoot.getCheckoutRules());
+  public AgentCheckoutAbility canCheckout(@NotNull VcsRoot vcsRoot, @NotNull CheckoutRules checkoutRules, @NotNull AgentRunningBuild build) {
+    CheckoutInfo info = new CheckoutInfo(myRepoFactory, new HgVcsRoot(vcsRoot), checkoutRules);
     try {
       info.getTempDirRepo().version().call();
     } catch (VcsException e) {
@@ -65,12 +65,12 @@
     }
 
     try {
-      for (IncludeRule rule : vcsRoot.getCheckoutRules().getRootIncludeRules()) {
+      for (IncludeRule rule : checkoutRules.getRootIncludeRules()) {
         MercurialIncludeRuleUpdater.checkRuleIsValid(rule);
       }
       return AgentCheckoutAbility.canCheckout();
     } catch (VcsException e) {
-      return AgentCheckoutAbility.canNotCheckout(e.getMessage());
+      return AgentCheckoutAbility.notSupportedCheckoutRules(e.getMessage());
     }
   }
 
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Wed Dec 09 13:05:16 2015 +0100
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Wed Dec 09 13:07:03 2015 +0100
@@ -15,10 +15,7 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
-import jetbrains.buildServer.agent.AgentRunningBuild;
-import jetbrains.buildServer.agent.BuildAgentConfiguration;
-import jetbrains.buildServer.agent.BuildProgressLogger;
-import jetbrains.buildServer.agent.FlowLogger;
+import jetbrains.buildServer.agent.*;
 import jetbrains.buildServer.agent.vcs.AgentCheckoutAbility;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsForRootImpl;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandlineViaFileWrapperWeaver;
@@ -29,6 +26,7 @@
 import jetbrains.buildServer.util.TestFor;
 import jetbrains.buildServer.vcs.*;
 import jetbrains.buildServer.vcs.impl.VcsRootImpl;
+import org.hamcrest.CoreMatchers;
 import org.jetbrains.annotations.NotNull;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
@@ -106,17 +104,18 @@
   public void auto_checkout_when_hg_client_not_found() throws Exception {
     VcsRootImpl root = new VcsRootBuilder().withUrl(copyRepository(myTempFiles, simpleRepo()).getAbsolutePath()).withHgPath("invalid_hg_path").build();
 
-    AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(new VcsRootEntry(root, CheckoutRules.DEFAULT), myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++));
+    AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(root, CheckoutRules.DEFAULT, myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++));
 
-    assertThat(agentCheckoutAbility.getCanNotCheckoutReason(), containsString(AgentCheckoutAbility.NO_VCS_CLIENT));
+    assertThat(agentCheckoutAbility.getCanNotCheckoutReason().getType(), CoreMatchers.equalTo(AgentCanNotCheckoutReason.NO_VCS_CLIENT));
   }
 
   public void auto_checkout_when_unsupported_include_rule_is_used() throws Exception {
     VcsRootImpl root = createVcsRoot(simpleRepo());
 
-    AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(new VcsRootEntry(root, new CheckoutRules("+:subdir=>subdir2")), myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++));
+    AgentCheckoutAbility agentCheckoutAbility = myVcsSupport.canCheckout(root, new CheckoutRules("+:subdir=>subdir2"), myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++));
 
-    assertThat(agentCheckoutAbility.getCanNotCheckoutReason(), containsString("Invalid include rule: subdir=>subdir2"));
+    assertThat(agentCheckoutAbility.getCanNotCheckoutReason().getType(), CoreMatchers.equalTo(AgentCanNotCheckoutReason.NOT_SUPPORTED_CHECKOUT_RULES));
+    assertThat(agentCheckoutAbility.getCanNotCheckoutReason().getDetails(), containsString("Invalid include rule: subdir=>subdir2"));
   }
 
   public void checkout_on_agent() throws IOException, VcsException {
@@ -169,7 +168,7 @@
       allowing(build).getBuildLogger(); will(returnValue(myLogger));
       allowing(build).getSharedConfigParameters(); will(returnValue(sharedConfigParameters));
     }});
-    assertNull(myVcsSupport.canCheckout(new VcsRootEntry(vcsRoot, new CheckoutRules("")), build).getCanNotCheckoutReason());
+    assertNull(myVcsSupport.canCheckout(vcsRoot, new CheckoutRules(""), build).getCanNotCheckoutReason());
     myVcsSupport.getUpdater(vcsRoot, new CheckoutRules(""), version, myWorkDir, build, false).process(includeRule, actualWorkDir);
 
     File hgDir = new File(actualWorkDir, ".hg");