changeset 957:a0bb066bda0e Indore-10.0.x

Merge branch Hajipur-9.1.x
author Dmitry Neverov <dmitry.neverov@gmail.com>
date Fri, 22 Jul 2016 12:40:07 +0200
parents 978363f2e89e (diff) 1ba5cc4c9ca4 (current diff)
children 6a16b17fcada
files mercurial-tests/src/testng.xml
diffstat 24 files changed, 135 insertions(+), 1260 deletions(-) [+]
line wrap: on
line diff
--- a/.idea/ant.xml	Fri Jul 22 12:26:37 2016 +0200
+++ b/.idea/ant.xml	Fri Jul 22 12:40:07 2016 +0200
@@ -1,10 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="AntConfiguration">
-    <buildFile url="file://$PROJECT_DIR$/build.xml">
-      <maximumStackSize value="32" />
-    </buildFile>
     <buildFile url="file://$PROJECT_DIR$/build/ant.build.xml" />
   </component>
-</project>
-
+</project>
\ No newline at end of file
--- a/.idea/artifacts/plugin.xml	Fri Jul 22 12:26:37 2016 +0200
+++ b/.idea/artifacts/plugin.xml	Fri Jul 22 12:40:07 2016 +0200
@@ -34,6 +34,9 @@
           <element id="artifact" artifact-name="mercurial-vcs-worker" />
         </element>
       </element>
+      <element id="directory" name="kotlin-dsl">
+        <element id="file-copy" path="$PROJECT_DIR$/mercurial-dsl/HgVcsRoot.xml" />
+      </element>
     </root>
   </artifact>
 </component>
\ No newline at end of file
--- a/.idea/compiler.xml	Fri Jul 22 12:26:37 2016 +0200
+++ b/.idea/compiler.xml	Fri Jul 22 12:40:07 2016 +0200
@@ -27,7 +27,5 @@
         <processorPath useClasspath="true" />
       </profile>
     </annotationProcessing>
-    <bytecodeTargetLevel target="1.5" />
   </component>
-</project>
-
+</project>
\ No newline at end of file
--- a/.idea/encodings.xml	Fri Jul 22 12:26:37 2016 +0200
+++ b/.idea/encodings.xml	Fri Jul 22 12:40:07 2016 +0200
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
-</project>
-
+  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
+    <file url="PROJECT" charset="UTF-8" />
+  </component>
+</project>
\ No newline at end of file
--- a/.idea/libraries/TeamCityAPI_common.xml	Fri Jul 22 12:26:37 2016 +0200
+++ b/.idea/libraries/TeamCityAPI_common.xml	Fri Jul 22 12:40:07 2016 +0200
@@ -2,6 +2,7 @@
   <library name="TeamCityAPI-common">
     <CLASSES>
       <root url="jar://$TeamCityDistribution$/devPackage/common-api.jar!/" />
+      <root url="jar://$TeamCityDistribution$/devPackage/serviceMessages.jar!/" />
     </CLASSES>
     <JAVADOC />
     <SOURCES>
--- a/.idea/misc.xml	Fri Jul 22 12:26:37 2016 +0200
+++ b/.idea/misc.xml	Fri Jul 22 12:40:07 2016 +0200
@@ -4,6 +4,5 @@
     <entry_points version="2.0" />
   </component>
   <component name="IdProvider" IDEtalkID="C52C76224CD45BEC1DC62428B699D800" />
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK" />
-</project>
-
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
+</project>
\ No newline at end of file
--- a/build.xml	Fri Jul 22 12:26:37 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-<!--
-  ~ Copyright 2000-2014 JetBrains s.r.o.
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~ http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<project name="Mercurial VCS Support" default="dist" basedir=".">
-  <property file="mercurial.properties"/>
-  <import file="mercurial.xml"/>
-
-  <property name="distPath" value="${basedir}/dist"/>
-
-  <property name="plugin.name" value="mercurial"/>
-
-  <property name="build.number" value=""/>
-  <tstamp>
-    <format property="timestamp" pattern="yyyyMMddhhmmss"/>
-  </tstamp>
-  <property name="snapshot.build.number" value="SNAPSHOT-${timestamp}"/>
-  <property name="build.vcs.number" value=""/>
-
-  <condition property="plugin.version" value="${snapshot.build.number}" else="${build.number}">
-    <matches pattern="snapshot-.*" string="${build.number}" casesensitive="false"/>
-  </condition>
-
-  <import file="teamcity-common.xml"/>
-
-  <target name="package" depends="define.version">
-    <package.teamcity.plugin name="${plugin.name}"
-                             server.output="${mercurial-server.output.dir}"
-                             agent.output="${mercurial-agent.output.dir}"
-                             common.output="${mercurial-common.output.dir}"
-                             plugin.descriptor.file="${basedir}/teamcity-plugin.xml"
-                             plugin.version="${plugin.version}"/>
-  </target>
-
-  <target name="define.version" depends="define.version.if.under.teamcity">
-    <tstamp>
-      <format property="current.time" pattern="yyyyMMddHHmm"/>
-    </tstamp>
-    <property name="plugin.version" value="SNAPSHOT-${current.time}"/>
-  </target>
-
-  <target name="define.version.if.under.teamcity" if="build.number">
-    <property name="plugin.version" value="${build.number}"/>
-  </target>
-
-  <target name="dist" depends="check.teamcitydistribution,all,package"/>
-
-  <target name="deploy" depends="dist">
-    <deploy.teamcity.plugin name="${plugin.name}"/>
-  </target>
-
-  <taskdef name="testng" classname="org.testng.TestNGAntTask" classpath="${basedir}/mercurial-tests/lib/testng-5.7-jdk15.jar"/>
-
-  <path id="tests_classpath">
-    <pathelement location="${agent.home.dir}/lib/runtime-util.jar"/>
-    <pathelement location="${agent.home.dir}/lib/buildServerRuntimeUtil.jar"/>
-    <path refid="mercurial-tests.runtime.module.classpath"/>
-  </path>
-
-  <target name="run-tests" depends="clean, init, compile.module.mercurial-tests">
-    <property name="suspend" value="n"/>
-
-    <testng haltonfailure="no" failureProperty="failure_found" listener="org.testng.reporters.TestHTMLReporter"
-            outputdir="${basedir}/test-output" classpathref="tests_classpath" dumpcommand="true" workingDir="${basedir}">
-
-      <jvmarg value="-ea"/>
-      <!--<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=${suspend},address=5555"/>-->
-
-      <sysproperty key="java.awt.headless" value="true"/>
-
-      <xmlfileset dir="${basedir}/mercurial-tests/src">
-        <include name="testng.xml"/>
-      </xmlfileset>
-    </testng>
-  </target>
-</project>
--- a/mercurial-agent/mercurial-agent.iml	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-agent/mercurial-agent.iml	Fri Jul 22 12:40:07 2016 +0200
@@ -5,16 +5,15 @@
       <configuration />
     </facet>
   </component>
-  <component name="NewModuleRootManager" inherit-compiler-output="false">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
     <output url="file://$MODULE_DIR$/classes" />
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
     </content>
-    <orderEntry type="inheritedJdk" />
+    <orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" name="TeamCityAPI-agent" level="project" />
     <orderEntry type="module" module-name="mercurial-common" />
   </component>
-</module>
-
+</module>
\ No newline at end of file
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialAgentSideVcsSupport.java	Fri Jul 22 12:40:07 2016 +0200
@@ -16,17 +16,12 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
 import jetbrains.buildServer.agent.AgentRunningBuild;
-import jetbrains.buildServer.agent.vcs.AgentVcsSupport;
-import jetbrains.buildServer.agent.vcs.IncludeRuleUpdater;
-import jetbrains.buildServer.agent.vcs.UpdateByIncludeRules2;
-import jetbrains.buildServer.agent.vcs.UpdatePolicy;
+import jetbrains.buildServer.agent.vcs.*;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.ext.CheckoutInfo;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.ext.MercurialExtension;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.ext.MercurialExtensionManager;
-import jetbrains.buildServer.vcs.CheckoutRules;
-import jetbrains.buildServer.vcs.VcsException;
-import jetbrains.buildServer.vcs.VcsRoot;
+import jetbrains.buildServer.vcs.*;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
@@ -59,6 +54,25 @@
     return updater;
   }
 
+  @NotNull
+  @Override
+  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) {
+      return AgentCheckoutAbility.noVcsClientOnAgent(e.getMessage());
+    }
+
+    try {
+      for (IncludeRule rule : checkoutRules.getRootIncludeRules()) {
+        MercurialIncludeRuleUpdater.checkRuleIsValid(rule);
+      }
+      return AgentCheckoutAbility.canCheckout();
+    } catch (VcsException e) {
+      return AgentCheckoutAbility.notSupportedCheckoutRules(e.getMessage());
+    }
+  }
 
   private void registerExtensions(@NotNull VcsRoot root, @NotNull CheckoutRules checkoutRules, @NotNull MercurialIncludeRuleUpdater updater) {
     CheckoutInfo info = new CheckoutInfo(myRepoFactory, new HgVcsRoot(root), checkoutRules);
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialIncludeRuleUpdater.java	Fri Jul 22 12:40:07 2016 +0200
@@ -269,11 +269,9 @@
   }
 
 
-  private void checkRuleIsValid(IncludeRule includeRule) throws VcsException {
-    if (includeRule.getTo() != null && includeRule.getTo().length() > 0) {
-      if (!".".equals(includeRule.getFrom()) && includeRule.getFrom().length() != 0)
-        throw new VcsException("Invalid include rule: " + includeRule.toString() + ", Mercurial plugin supports mapping of the form: +:.=>dir only.");
-    }
+  public static void checkRuleIsValid(IncludeRule includeRule) throws VcsException {
+    if (!".".equals(includeRule.getFrom()) && includeRule.getFrom().length() != 0)
+      throw new VcsException("Invalid include rule: " + includeRule.toString() + ", Mercurial plugin supports mapping of the form: +:.=>dir only.");
   }
 
 
--- a/mercurial-common/mercurial-common.iml	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-common/mercurial-common.iml	Fri Jul 22 12:40:07 2016 +0200
@@ -1,17 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module relativePaths="true" type="JAVA_MODULE" version="4">
-  <component name="NewModuleRootManager" inherit-compiler-output="false">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
     <output url="file://$MODULE_DIR$/classes" />
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
     </content>
-    <orderEntry type="inheritedJdk" />
+    <orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" exported="" name="TeamCityAPI-common" level="project" />
     <orderEntry type="library" exported="" name="IDEA-openapi" level="project" />
     <orderEntry type="library" name="jdom" level="project" />
     <orderEntry type="library" name="commons-codec-1.4" level="project" />
   </component>
-</module>
-
+</module>
\ No newline at end of file
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResult.java	Fri Jul 22 12:40:07 2016 +0200
@@ -270,7 +270,7 @@
   }
 
   private void checkAbandonedTransaction(@NotNull final String stderr) throws AbandonedTransactionFound {
-    if (stderr.contains("abort: abandoned transaction found - run hg recover"))
+    if (stderr.contains("abort: abandoned transaction found") && stderr.contains("hg recover"))
       throw new AbandonedTransactionFound();
   }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-dsl/HgVcsRoot.xml	Fri Jul 22 12:40:07 2016 +0200
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2000-2016 JetBrains s.r.o.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<dsl-extension kind="vcs" type="mercurial" generateDslJar="true">
+  <class name="HgVcsRoot"/>
+  <params>
+    <param name="repositoryPath" dslName="url"/>
+    <param name="branchName" dslName="branch"/>
+    <param name="teamcity:branchSpec" dslName="branchSpec"/>
+    <param name="useTagsAsBranches" type="boolean"/>
+    <param name="detectSubrepoChanges" type="boolean"/>
+    <param name="tagUsername" dslName="userForTags"/>
+    <param name="uncompressedTransfer" type="boolean"/>
+    <param name="hgCommandPath" dslName="hgPath"/>
+    <param name="customHgConfig"/>
+    <param name="username" dslName="userName"/>
+    <param name="secure:password" dslName="password"/>
+    <param name="purgePolicy" type="PurgePolicy"/>
+    <param name="useSharedMirrors" dslName="useMirrors" type="boolean"/>
+  </params>
+  <types>
+    <enum name="PurgePolicy">
+      <option name="DONT_RUN"/>
+      <option name="PURGE_UNKNOWN"/>
+      <option name="PURGE_ALL"/>
+    </enum>
+  </types>
+</dsl-extension>
\ No newline at end of file
--- a/mercurial-server/resources/buildServerResources/mercurialSettings.jsp	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-server/resources/buildServerResources/mercurialSettings.jsp	Fri Jul 22 12:40:07 2016 +0200
@@ -37,6 +37,7 @@
   <tr>
     <th><label for="repositoryPath">Pull changes from: <l:star/></label></th>
     <td><props:textProperty name="repositoryPath" className="longField" onchange="updateBranchName(this.value)"/>
+      <jsp:include page="/admin/repositoryControls.html?projectId=${parentProject.externalId}&vcsType=hg"/>
       <span class="error" id="error_repositoryPath"></span></td>
   </tr>
   <tr>
@@ -141,4 +142,18 @@
       </td>
     </tr>
   </l:settingsGroup>
+  <script type="text/javascript">
+    $j(document).ready(function() {
+      if (BS.Repositories != null) {
+        BS.Repositories.installControls($('repositoryPath'), function (repoInfo, cre) {
+          $('repositoryPath').value = repoInfo.repositoryUrl;
+          if (cre != null) {
+            $('username').value = cre.oauthLogin;
+          }
+        });
+      } else {
+        $j('.listRepositoriesControls').hide();
+      }
+    });
+  </script>
 </table>
--- a/mercurial-server/src/META-INF/build-server-plugin-mercurial.xml	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-server/src/META-INF/build-server-plugin-mercurial.xml	Fri Jul 22 12:40:07 2016 +0200
@@ -31,7 +31,6 @@
   <bean id="commitSupport" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialCommitSupport"/>
 
   <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialCommitsInfoBuilderSupport"/>
-  <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialModificationInfoBuilder"/>
 
   <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsForRootImpl"/>
   <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ExtensionsWeaver"/>
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialModificationInfoBuilder.java	Fri Jul 22 12:26:37 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright 2000-2014 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package jetbrains.buildServer.buildTriggers.vcs.mercurial;
-
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ChangeSet;
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot;
-import jetbrains.buildServer.vcs.*;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Collection;
-import java.util.Collections;
-
-public class MercurialModificationInfoBuilder implements ChangesInfoBuilder, MercurialServerExtension {
-
-  private final ServerPluginConfig myConfig;
-  private final MercurialVcsSupport myVcs;
-  private final HgVcsRootFactory myHgVcsRootFactory;
-  private final RepoFactory myRepoFactory;
-  private final HgPathProvider myHgPathProvider;
-
-  public MercurialModificationInfoBuilder(@NotNull ServerPluginConfig config,
-                                          @NotNull MercurialVcsSupport vcs,
-                                          @NotNull HgVcsRootFactory hgVcsRootFactory,
-                                          @NotNull RepoFactory repoFactory,
-                                          @NotNull HgPathProvider hgPathProvider) {
-    myConfig = config;
-    myVcs = vcs;
-    myHgVcsRootFactory = hgVcsRootFactory;
-    myRepoFactory = repoFactory;
-    myHgPathProvider = hgPathProvider;
-    myVcs.addExtension(this);
-  }
-
-  public void fetchChangesInfo(@NotNull final VcsRoot root,
-                               @NotNull final CheckoutRules checkoutRules,
-                               @NotNull final Collection<String> revisions,
-                               @NotNull final ChangesConsumer consumer) throws VcsException {
-    final HgVcsRoot hgRoot = myHgVcsRootFactory.createHgRoot(root);
-
-    final CollectChangesContext ctx = new CollectChangesContext(myConfig, myVcs,
-            myRepoFactory,
-            MercurialProgress.NO_OP,
-            Collections.<String>emptyList());
-
-    //TODO: it's better if we call log command once (or by chunks) instead of simple for-each
-    for (String commitId : revisions) {
-      for (ChangeSet set : myVcs.createRepo(hgRoot).log().withRevsets(commitId).call()) {
-        consumer.consumeChange(ModificationDataFactory.createModificationData(ctx, set, root, checkoutRules));
-      }
-    }
-  }
-}
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Fri Jul 22 12:40:07 2016 +0200
@@ -15,10 +15,8 @@
  */
 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;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ExtensionsWeaver;
@@ -26,11 +24,9 @@
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.ext.MercurialExtensionManager;
 import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.util.TestFor;
-import jetbrains.buildServer.vcs.CheckoutRules;
-import jetbrains.buildServer.vcs.IncludeRule;
-import jetbrains.buildServer.vcs.VcsException;
-import jetbrains.buildServer.vcs.VcsRoot;
+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;
@@ -45,6 +41,8 @@
 import java.util.concurrent.*;
 
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository;
+import static org.hamcrest.MatcherAssert.*;
+import static org.hamcrest.text.StringContains.containsString;
 
 /**
  * @author Pavel.Sher
@@ -103,6 +101,22 @@
     testUpdate(root, "b06a290a363b", "cleanPatch1/after", new IncludeRule(".", ".", null));
   }
 
+  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(root, CheckoutRules.DEFAULT, myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++));
+
+    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(root, new CheckoutRules("+:subdir=>subdir2"), myContext.mock(AgentRunningBuild.class, "build" + myBuildCounter++));
+
+    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 {
     testUpdate(createVcsRoot(simpleRepo()), "4:b06a290a363b", "cleanPatch1/after", new IncludeRule(".", ".", null));
@@ -112,6 +126,16 @@
     testUpdate(createVcsRoot(simpleRepo()), "4:b06a290a363b", "cleanPatch1/after", new IncludeRule("+:.", "subdir", null));
   }
 
+  @TestFor(issues = "TW-19761")
+  public void include_subdir_is_not_supported() throws Exception {
+    try {
+      testUpdate(createVcsRoot(simpleRepo()), "4:b06a290a363b", "cleanPatch1/after", new IncludeRule("+:subdir", ".", null));
+      fail("should fail");
+    } catch (VcsException e) {
+      assertTrue(e.getMessage().contains("Invalid include rule"));
+    }
+  }
+
   private void testUpdate(final VcsRoot vcsRoot, String version, String expected, final IncludeRule includeRule) throws VcsException, IOException {
     File workDir = doUpdate(vcsRoot, version, includeRule);
 
@@ -154,6 +178,7 @@
       allowing(build).getBuildLogger(); will(returnValue(myLogger));
       allowing(build).getSharedConfigParameters(); will(returnValue(sharedConfigParameters));
     }});
+    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");
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CommitsInfoBuilderSupportTest.java	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/CommitsInfoBuilderSupportTest.java	Fri Jul 22 12:40:07 2016 +0200
@@ -131,7 +131,7 @@
     }
   }
 
-  public void should_return_subrepos_graphcommits(@NotNull HgVersion _) throws Exception {
+  private void should_return_subrepos_graphcommits(@NotNull HgVersion _) throws Exception {
     myRemoteRepo = myTempFiles.createTempDir();
     copyRepository(new File("mercurial-tests/testData/subrepos/r1"), myRemoteRepo);
 
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialModificationInfoBuilderTest.java	Fri Jul 22 12:26:37 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * Copyright 2000-2014 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package jetbrains.buildServer.buildTriggers.vcs.mercurial;
-
-import jetbrains.buildServer.vcs.ChangesConsumer;
-import jetbrains.buildServer.vcs.CheckoutRules;
-import jetbrains.buildServer.vcs.VcsRoot;
-import jetbrains.vcs.api.ChangeData;
-import org.jetbrains.annotations.NotNull;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport;
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.ServerPluginConfigBuilder.serverPluginConfig;
-import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot;
-import static org.testng.AssertJUnit.assertEquals;
-
-@RequiredHgVersion(min = "1.7.0")
-@Test(dataProviderClass = HgVersionConstraint.class, dataProvider = "installedHgVersion")
-public class MercurialModificationInfoBuilderTest extends BaseMercurialTestCase {
-
-  private File myRemoteRepository;
-  private MercurialModificationInfoBuilder myModInfoBuilder;
-  private MercurialVcsSupport myVcs;
-
-  @BeforeMethod
-  public void setUp() throws Exception {
-    super.setUp();
-    ServerPluginConfig config = serverPluginConfig()
-            .cachesDir(myTempFiles.createTempDir())
-            .hgPath(Util.getHgPath())
-            .build();
-
-    myRemoteRepository = myTempFiles.createTempDir();
-    Util.copyRepository(new File("mercurial-tests/testData/rep2"), myRemoteRepository);
-    MercurialSupportBuilder hgBuilder = mercurialSupport().withConfig(config);
-    MercurialVcsSupport vcs = hgBuilder.build();
-    myVcs = vcs;
-    myModInfoBuilder = new MercurialModificationInfoBuilder(config, vcs, hgBuilder.getHgRootFactory(), hgBuilder.getHgRepoFactory(), hgBuilder.getHgPathProvider());
-  }
-
-
-  public void should_return_commits_for_every_revision_in_state(HgVersion _) throws Exception {
-    VcsRoot root = vcsRoot().withUrl(myRemoteRepository.getAbsolutePath()).build();
-    final List<ChangeData> changes = new ArrayList<ChangeData>();
-    myVcs.syncRepository(root);
-    myModInfoBuilder.fetchChangesInfo(root, CheckoutRules.DEFAULT, Arrays.asList("505c5b9d01e6", "9ec402c74298"), new ChangesConsumer() {
-      public void consumeChange(@NotNull ChangeData change) {
-        changes.add(change);
-      }
-    });
-
-    for (ChangeData change : changes) {
-      if (change.getVersion().equals("505c5b9d01e6")) {
-        Assert.assertEquals(change.getParentRevisions(), Arrays.asList("78e67807f916"));
-      } else if (change.getVersion().equals("9ec402c74298")) {
-        Assert.assertEquals(change.getParentRevisions(), Arrays.asList("96b78d73081d"));
-      } else {
-        Assert.fail("Unexpected revision: " + change.getVersion());
-      }
-    }
-
-    assertEquals(2, changes.size());
-  }
-
-
-  public void should_return_commits_for_every_revision_in_state_parent_child(HgVersion _) throws Exception {
-    VcsRoot root = vcsRoot().withUrl(myRemoteRepository.getAbsolutePath()).build();
-    final List<ChangeData> changes = new ArrayList<ChangeData>();
-    myVcs.syncRepository(root);
-    myModInfoBuilder.fetchChangesInfo(root, CheckoutRules.DEFAULT, Arrays.asList("505c5b9d01e6", "9ec402c74298", "96b78d73081d"), new ChangesConsumer() {
-      public void consumeChange(@NotNull ChangeData change) {
-        changes.add(change);
-      }
-    });
-
-    for (ChangeData change : changes) {
-      if (change.getVersion().equals("505c5b9d01e6")) {
-        Assert.assertEquals(change.getParentRevisions(), Arrays.asList("78e67807f916"));
-      } else if (change.getVersion().equals("9ec402c74298")) {
-        Assert.assertEquals(change.getParentRevisions(), Arrays.asList("96b78d73081d"));
-      } else if (change.getVersion().equals("96b78d73081d")) {
-        Assert.assertEquals(change.getParentRevisions(), Arrays.asList("dec47d2d49bf"));
-      } else {
-        Assert.fail("Unexpected revision: " + change.getVersion());
-      }
-    }
-
-    assertEquals(3, changes.size());
-  }
-
-  public void should_return_commits_for_every_revision_in_state_parent_gap_child(HgVersion _) throws Exception {
-    VcsRoot root = vcsRoot().withUrl(myRemoteRepository.getAbsolutePath()).build();
-    final List<ChangeData> changes = new ArrayList<ChangeData>();
-    myVcs.syncRepository(root);
-    myModInfoBuilder.fetchChangesInfo(root, CheckoutRules.DEFAULT, Arrays.asList("505c5b9d01e6", "9ec402c74298", "dec47d2d49bf"), new ChangesConsumer() {
-      public void consumeChange(@NotNull ChangeData change) {
-        changes.add(change);
-      }
-    });
-
-
-    for (ChangeData change : changes) {
-      if (change.getVersion().equals("505c5b9d01e6")) {
-        Assert.assertEquals(change.getParentRevisions(), Arrays.asList("78e67807f916"));
-      } else if (change.getVersion().equals("9ec402c74298")) {
-        Assert.assertEquals(change.getParentRevisions(), Arrays.asList("96b78d73081d"));
-      } else if (change.getVersion().equals("dec47d2d49bf")) {
-        Assert.assertEquals(change.getParentRevisions(), Arrays.asList("1e620196c4b6"));
-      } else {
-        Assert.fail("Unexpected revision: " + change.getVersion());
-      }
-    }
-
-    assertEquals(3, changes.size());
-  }
-}
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandResultTest.java	Fri Jul 22 12:40:07 2016 +0200
@@ -155,7 +155,7 @@
     try {
       cr.checkCommandFailed();
     } catch (VcsException e) {
-      assertThat(e.getMessage(), containsString("300Mb from..."));
+      assertThat(e.getMessage(), containsString("300Mb from ..."));
       assertThat(e.getMessage(), containsString("See details in teamcity-vcs.log"));
     }
   }
--- a/mercurial-tests/src/testng-via-cmd.xml	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-tests/src/testng-via-cmd.xml	Fri Jul 22 12:40:07 2016 +0200
@@ -38,7 +38,6 @@
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MergeSupportTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.TagsTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.CommitsInfoBuilderSupportTest"/>
-      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialModificationInfoBuilderTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialUrlSupportTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.PurgeTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialCommitSupportTest"/>
--- a/mercurial-tests/src/testng.xml	Fri Jul 22 12:26:37 2016 +0200
+++ b/mercurial-tests/src/testng.xml	Fri Jul 22 12:40:07 2016 +0200
@@ -52,7 +52,6 @@
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MergeSupportTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.TagsTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.CommitsInfoBuilderSupportTest"/>
-      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialModificationInfoBuilderTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialUrlSupportTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommitsAndMountPointsCommandParserTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.PurgeTest"/>
--- a/mercurial.xml	Fri Jul 22 12:26:37 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,617 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright 2000-2014 JetBrains s.r.o.
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~ http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<project name="mercurial" default="all">
-  
-  
-  <property file="mercurial.properties"/>
-  <!-- Uncomment the following property if no tests compilation is needed -->
-  <!-- 
-  <property name="skip.tests" value="true"/>
-   -->
-  
-  <!-- Compiler options -->
-  
-  <property name="compiler.debug" value="on"/>
-  <property name="compiler.generate.no.warnings" value="off"/>
-  <property name="compiler.args" value=""/>
-  <property name="compiler.max.memory" value="128m"/>
-  <patternset id="ignored.files">
-    <exclude name="**/CVS/**"/>
-    <exclude name="**/SCCS/**"/>
-    <exclude name="**/RCS/**"/>
-    <exclude name="**/rcs/**"/>
-    <exclude name="**/.DS_Store/**"/>
-    <exclude name="**/.svn/**"/>
-    <exclude name="**/.pyc/**"/>
-    <exclude name="**/.pyo/**"/>
-    <exclude name="**/*.pyc/**"/>
-    <exclude name="**/*.pyo/**"/>
-    <exclude name="**/.git/**"/>
-    <exclude name="**/*.hprof/**"/>
-    <exclude name="**/_svn/**"/>
-    <exclude name="**/.hg/**"/>
-    <exclude name="**/*.lib/**"/>
-    <exclude name="**/*~/**"/>
-    <exclude name="**/__pycache__/**"/>
-    <exclude name="**/.bundle/**"/>
-    <exclude name="**/*.rbc/**"/>
-    <exclude name="**/*.orig/**"/>
-  </patternset>
-  <patternset id="library.patterns">
-    <include name="*.zip"/>
-    <include name="*.apk"/>
-    <include name="*.war"/>
-    <include name="*.egg"/>
-    <include name="*.ear"/>
-    <include name="*.ane"/>
-    <include name="*.swc"/>
-    <include name="*.jar"/>
-  </patternset>
-  <patternset id="compiler.resources">
-    <include name="**/?*.properties"/>
-    <include name="**/?*.xml"/>
-    <include name="**/?*.gif"/>
-    <include name="**/?*.png"/>
-    <include name="**/?*.jpeg"/>
-    <include name="**/?*.jpg"/>
-    <include name="**/?*.html"/>
-    <include name="**/?*.dtd"/>
-    <include name="**/?*.tld"/>
-    <include name="**/?*.jsp"/>
-    <include name="**/?*.tag"/>
-    <include name="**/?*.template"/>
-  </patternset>
-  
-  
-  <!-- Project Libraries -->
-  
-  <path id="library.idea-openapi.classpath">
-    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/annotations.jar"/>
-    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/openapi.jar"/>
-    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/resources_en.jar"/>
-    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/util.jar"/>
-  </path>
-  
-  <path id="library.jdom.classpath">
-    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/jdom.jar"/>
-  </path>
-  
-  <path id="library.jmock.classpath">
-    <pathelement location="${basedir}/mercurial-tests/lib/hamcrest-core-1.1.jar"/>
-    <pathelement location="${basedir}/mercurial-tests/lib/hamcrest-integration-1.1.jar"/>
-    <pathelement location="${basedir}/mercurial-tests/lib/hamcrest-library-1.1.jar"/>
-    <pathelement location="${basedir}/mercurial-tests/lib/jmock-2.5.1.jar"/>
-    <pathelement location="${basedir}/mercurial-tests/lib/jmock-SNAPSHOT.jar"/>
-  </path>
-  
-  <path id="library.junit.classpath">
-    <pathelement location="${basedir}/mercurial-tests/lib/junit-3.8.1.jar"/>
-  </path>
-  
-  <path id="library.log4j.classpath">
-    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/log4j-1.2.12.jar"/>
-  </path>
-  
-  <path id="library.teamcity-impl.classpath">
-    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/patches-impl.jar"/>
-    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/trove4j.jar"/>
-  </path>
-  
-  <path id="library.teamcity-testsapi.classpath">
-    <pathelement location="${path.variable.teamcitydistribution}/devPackage/tests/patches-test.jar"/>
-    <pathelement location="${path.variable.teamcitydistribution}/devPackage/tests/tests-support.jar"/>
-  </path>
-  
-  <path id="library.teamcity_vcs_api.classpath">
-    <pathelement location="${path.variable.teamcitydistribution}/devPackage/server-common-api.jar"/>
-    <pathelement location="${path.variable.teamcitydistribution}/devPackage/server-vcs-api.jar"/>
-  </path>
-  
-  <path id="library.teamcityapi-agent.classpath">
-    <pathelement location="${path.variable.teamcitydistribution}/buildAgent/lib/agent.jar"/>
-    <pathelement location="${path.variable.teamcitydistribution}/devPackage/agent-api.jar"/>
-  </path>
-  
-  <path id="library.teamcityapi-common.classpath">
-    <pathelement location="${path.variable.teamcitydistribution}/devPackage/common-api.jar"/>
-  </path>
-  
-  <path id="library.teamcityapi-server.classpath">
-    <pathelement location="${path.variable.teamcitydistribution}/devPackage/server-api.jar"/>
-    <pathelement location="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib/server.jar"/>
-  </path>
-  
-  <path id="library.testng.classpath">
-    <pathelement location="${basedir}/mercurial-tests/lib/testng-5.7-jdk15.jar"/>
-  </path>
-  
-  
-  <!-- Application Server Libraries -->
-  
-  <!-- Modules -->
-  
-  
-  <!-- Module main -->
-  
-  <dirname property="module.main.basedir" file="${ant.file}"/>
-  
-  
-  
-  <property name="compiler.args.main" value="${compiler.args}"/>
-  
-  <property name="main.output.dir" value="undefined"/>
-  <property name="main.testoutput.dir" value="undefined"/>
-  
-  <path id="main.module.bootclasspath">
-    <!-- Paths to be included in compilation bootclasspath -->
-  </path>
-  
-  <path id="main.module.production.classpath"/>
-  
-  <path id="main.runtime.production.module.classpath"/>
-  
-  <path id="main.module.classpath"/>
-  
-  <path id="main.runtime.module.classpath"/>
-  
-  
-  <patternset id="excluded.from.module.main">
-    <patternset refid="ignored.files"/>
-  </patternset>
-  
-  <patternset id="excluded.from.compilation.main">
-    <patternset refid="excluded.from.module.main"/>
-  </patternset>
-  
-  
-  <target name="compile.module.main" depends="compile.module.main.production,compile.module.main.tests" description="Compile module main"/>
-  
-  <target name="compile.module.main.production" description="Compile module main; production classes"/>
-  
-  <target name="compile.module.main.tests" depends="compile.module.main.production" description="compile module main; test classes" unless="skip.tests"/>
-  
-  <target name="clean.module.main" description="cleanup module">
-    <delete dir="${main.output.dir}"/>
-    <delete dir="${main.testoutput.dir}"/>
-  </target>
-  
-  
-  <!-- Module mercurial-common -->
-  
-  <dirname property="module.mercurial-common.basedir" file="${ant.file}"/>
-  
-  
-  
-  <property name="compiler.args.mercurial-common" value="${compiler.args}"/>
-  
-  <property name="mercurial-common.output.dir" value="${module.mercurial-common.basedir}/mercurial-common/classes"/>
-  <property name="mercurial-common.testoutput.dir" value="${module.mercurial-common.basedir}/mercurial-common/classes"/>
-  
-  <path id="mercurial-common.module.bootclasspath">
-    <!-- Paths to be included in compilation bootclasspath -->
-  </path>
-  
-  <path id="mercurial-common.module.production.classpath">
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.jdom.classpath"/>
-  </path>
-  
-  <path id="mercurial-common.runtime.production.module.classpath">
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.jdom.classpath"/>
-  </path>
-  
-  <path id="mercurial-common.module.classpath">
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.jdom.classpath"/>
-  </path>
-  
-  <path id="mercurial-common.runtime.module.classpath">
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.jdom.classpath"/>
-  </path>
-  
-  
-  <patternset id="excluded.from.module.mercurial-common">
-    <patternset refid="ignored.files"/>
-  </patternset>
-  
-  <patternset id="excluded.from.compilation.mercurial-common">
-    <patternset refid="excluded.from.module.mercurial-common"/>
-  </patternset>
-  
-  <path id="mercurial-common.module.sourcepath">
-    <dirset dir="${module.mercurial-common.basedir}/mercurial-common">
-      <include name="src"/>
-    </dirset>
-  </path>
-  
-  
-  <target name="compile.module.mercurial-common" depends="compile.module.mercurial-common.production,compile.module.mercurial-common.tests" description="Compile module mercurial-common"/>
-  
-  <target name="compile.module.mercurial-common.production" description="Compile module mercurial-common; production classes">
-    <mkdir dir="${mercurial-common.output.dir}"/>
-    <javac destdir="${mercurial-common.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true">
-      <compilerarg line="${compiler.args.mercurial-common}"/>
-      <bootclasspath refid="mercurial-common.module.bootclasspath"/>
-      <classpath refid="mercurial-common.module.production.classpath"/>
-      <src refid="mercurial-common.module.sourcepath"/>
-      <patternset refid="excluded.from.compilation.mercurial-common"/>
-    </javac>
-    
-    <copy todir="${mercurial-common.output.dir}">
-      <fileset dir="${module.mercurial-common.basedir}/mercurial-common/src">
-        <patternset refid="compiler.resources"/>
-        <type type="file"/>
-      </fileset>
-    </copy>
-  </target>
-  
-  <target name="compile.module.mercurial-common.tests" depends="compile.module.mercurial-common.production" description="compile module mercurial-common; test classes" unless="skip.tests"/>
-  
-  <target name="clean.module.mercurial-common" description="cleanup module">
-    <delete dir="${mercurial-common.output.dir}"/>
-    <delete dir="${mercurial-common.testoutput.dir}"/>
-  </target>
-  
-  
-  <!-- Module mercurial-agent -->
-  
-  <dirname property="module.mercurial-agent.basedir" file="${ant.file}"/>
-  
-  
-  
-  <property name="compiler.args.mercurial-agent" value="${compiler.args}"/>
-  
-  <property name="mercurial-agent.output.dir" value="${module.mercurial-agent.basedir}/mercurial-agent/classes"/>
-  <property name="mercurial-agent.testoutput.dir" value="${module.mercurial-agent.basedir}/mercurial-agent/classes"/>
-  
-  <path id="mercurial-agent.module.bootclasspath">
-    <!-- Paths to be included in compilation bootclasspath -->
-  </path>
-  
-  <path id="mercurial-agent.module.production.classpath">
-    <path refid="library.teamcityapi-agent.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-  </path>
-  
-  <path id="mercurial-agent.runtime.production.module.classpath">
-    <pathelement location="${mercurial-agent.output.dir}"/>
-    <path refid="library.teamcityapi-agent.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.jdom.classpath"/>
-  </path>
-  
-  <path id="mercurial-agent.module.classpath">
-    <pathelement location="${mercurial-agent.output.dir}"/>
-    <path refid="library.teamcityapi-agent.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-  </path>
-  
-  <path id="mercurial-agent.runtime.module.classpath">
-    <pathelement location="${mercurial-agent.output.dir}"/>
-    <path refid="library.teamcityapi-agent.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.jdom.classpath"/>
-  </path>
-  
-  
-  <patternset id="excluded.from.module.mercurial-agent">
-    <patternset refid="ignored.files"/>
-  </patternset>
-  
-  <patternset id="excluded.from.compilation.mercurial-agent">
-    <patternset refid="excluded.from.module.mercurial-agent"/>
-  </patternset>
-  
-  <path id="mercurial-agent.module.sourcepath">
-    <dirset dir="${module.mercurial-agent.basedir}/mercurial-agent">
-      <include name="src"/>
-    </dirset>
-  </path>
-  
-  
-  <target name="compile.module.mercurial-agent" depends="compile.module.mercurial-agent.production,compile.module.mercurial-agent.tests" description="Compile module mercurial-agent"/>
-  
-  <target name="compile.module.mercurial-agent.production" depends="compile.module.mercurial-common" description="Compile module mercurial-agent; production classes">
-    <mkdir dir="${mercurial-agent.output.dir}"/>
-    <javac destdir="${mercurial-agent.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true">
-      <compilerarg line="${compiler.args.mercurial-agent}"/>
-      <bootclasspath refid="mercurial-agent.module.bootclasspath"/>
-      <classpath refid="mercurial-agent.module.production.classpath"/>
-      <src refid="mercurial-agent.module.sourcepath"/>
-      <patternset refid="excluded.from.compilation.mercurial-agent"/>
-    </javac>
-    
-    <copy todir="${mercurial-agent.output.dir}">
-      <fileset dir="${module.mercurial-agent.basedir}/mercurial-agent/src">
-        <patternset refid="compiler.resources"/>
-        <type type="file"/>
-      </fileset>
-    </copy>
-  </target>
-  
-  <target name="compile.module.mercurial-agent.tests" depends="compile.module.mercurial-agent.production" description="compile module mercurial-agent; test classes" unless="skip.tests"/>
-  
-  <target name="clean.module.mercurial-agent" description="cleanup module">
-    <delete dir="${mercurial-agent.output.dir}"/>
-    <delete dir="${mercurial-agent.testoutput.dir}"/>
-  </target>
-  
-  
-  <!-- Module mercurial-server -->
-  
-  <dirname property="module.mercurial-server.basedir" file="${ant.file}"/>
-  
-  
-  
-  <property name="compiler.args.mercurial-server" value="${compiler.args}"/>
-  
-  <property name="mercurial-server.output.dir" value="${module.mercurial-server.basedir}/mercurial-server/classes"/>
-  <property name="mercurial-server.testoutput.dir" value="${module.mercurial-server.basedir}/mercurial-server/classes"/>
-  
-  <path id="mercurial-server.module.bootclasspath">
-    <!-- Paths to be included in compilation bootclasspath -->
-  </path>
-  
-  <path id="mercurial-server.module.production.classpath">
-    <path refid="library.teamcityapi-server.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.log4j.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.teamcity_vcs_api.classpath"/>
-  </path>
-  
-  <path id="mercurial-server.runtime.production.module.classpath">
-    <pathelement location="${mercurial-server.output.dir}"/>
-    <path refid="library.teamcityapi-server.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.log4j.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.jdom.classpath"/>
-    <path refid="library.teamcity_vcs_api.classpath"/>
-  </path>
-  
-  <path id="mercurial-server.module.classpath">
-    <pathelement location="${mercurial-server.output.dir}"/>
-    <path refid="library.teamcityapi-server.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.log4j.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.teamcity_vcs_api.classpath"/>
-  </path>
-  
-  <path id="mercurial-server.runtime.module.classpath">
-    <pathelement location="${mercurial-server.output.dir}"/>
-    <path refid="library.teamcityapi-server.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.log4j.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.jdom.classpath"/>
-    <path refid="library.teamcity_vcs_api.classpath"/>
-  </path>
-  
-  
-  <patternset id="excluded.from.module.mercurial-server">
-    <patternset refid="ignored.files"/>
-  </patternset>
-  
-  <patternset id="excluded.from.compilation.mercurial-server">
-    <patternset refid="excluded.from.module.mercurial-server"/>
-  </patternset>
-  
-  <path id="mercurial-server.module.sourcepath">
-    <dirset dir="${module.mercurial-server.basedir}/mercurial-server">
-      <include name="resources"/>
-      <include name="src"/>
-    </dirset>
-  </path>
-  
-  
-  <target name="compile.module.mercurial-server" depends="compile.module.mercurial-server.production,compile.module.mercurial-server.tests" description="Compile module mercurial-server"/>
-  
-  <target name="compile.module.mercurial-server.production" depends="compile.module.mercurial-common" description="Compile module mercurial-server; production classes">
-    <mkdir dir="${mercurial-server.output.dir}"/>
-    <javac destdir="${mercurial-server.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true">
-      <compilerarg line="${compiler.args.mercurial-server}"/>
-      <bootclasspath refid="mercurial-server.module.bootclasspath"/>
-      <classpath refid="mercurial-server.module.production.classpath"/>
-      <src refid="mercurial-server.module.sourcepath"/>
-      <patternset refid="excluded.from.compilation.mercurial-server"/>
-    </javac>
-    
-    <copy todir="${mercurial-server.output.dir}">
-      <fileset dir="${module.mercurial-server.basedir}/mercurial-server/resources">
-        <patternset refid="compiler.resources"/>
-        <type type="file"/>
-      </fileset>
-      <fileset dir="${module.mercurial-server.basedir}/mercurial-server/src">
-        <patternset refid="compiler.resources"/>
-        <type type="file"/>
-      </fileset>
-    </copy>
-  </target>
-  
-  <target name="compile.module.mercurial-server.tests" depends="compile.module.mercurial-server.production" description="compile module mercurial-server; test classes" unless="skip.tests"/>
-  
-  <target name="clean.module.mercurial-server" description="cleanup module">
-    <delete dir="${mercurial-server.output.dir}"/>
-    <delete dir="${mercurial-server.testoutput.dir}"/>
-  </target>
-  
-  
-  <!-- Module mercurial-tests -->
-  
-  <dirname property="module.mercurial-tests.basedir" file="${ant.file}"/>
-  
-  
-  
-  <property name="compiler.args.mercurial-tests" value="${compiler.args}"/>
-  
-  <property name="mercurial-tests.output.dir" value="${module.mercurial-tests.basedir}/mercurial-tests/classes"/>
-  <property name="mercurial-tests.testoutput.dir" value="${module.mercurial-tests.basedir}/mercurial-tests/classes"/>
-  
-  <path id="mercurial-tests.module.bootclasspath">
-    <!-- Paths to be included in compilation bootclasspath -->
-  </path>
-  
-  <path id="mercurial-tests.module.production.classpath">
-    <pathelement location="${mercurial-server.output.dir}"/>
-    <path refid="library.teamcityapi-server.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.log4j.classpath"/>
-    <path refid="library.junit.classpath"/>
-    <path refid="library.testng.classpath"/>
-    <path refid="library.jmock.classpath"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <pathelement location="${mercurial-agent.output.dir}"/>
-    <path refid="library.teamcity-testsapi.classpath"/>
-    <path refid="library.teamcity-impl.classpath"/>
-    <path refid="library.teamcityapi-agent.classpath"/>
-    <path refid="library.teamcity_vcs_api.classpath"/>
-  </path>
-  
-  <path id="mercurial-tests.runtime.production.module.classpath">
-    <pathelement location="${mercurial-tests.output.dir}"/>
-    <pathelement location="${mercurial-server.output.dir}"/>
-    <path refid="library.teamcityapi-server.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.log4j.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.jdom.classpath"/>
-    <path refid="library.teamcity_vcs_api.classpath"/>
-    <path refid="library.junit.classpath"/>
-    <path refid="library.testng.classpath"/>
-    <path refid="library.jmock.classpath"/>
-    <pathelement location="${mercurial-agent.output.dir}"/>
-    <path refid="library.teamcityapi-agent.classpath"/>
-    <path refid="library.teamcity-testsapi.classpath"/>
-    <path refid="library.teamcity-impl.classpath"/>
-  </path>
-  
-  <path id="mercurial-tests.module.classpath">
-    <pathelement location="${mercurial-tests.output.dir}"/>
-    <pathelement location="${mercurial-server.output.dir}"/>
-    <path refid="library.teamcityapi-server.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.log4j.classpath"/>
-    <path refid="library.junit.classpath"/>
-    <path refid="library.testng.classpath"/>
-    <path refid="library.jmock.classpath"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <pathelement location="${mercurial-agent.output.dir}"/>
-    <path refid="library.teamcity-testsapi.classpath"/>
-    <path refid="library.teamcity-impl.classpath"/>
-    <path refid="library.teamcityapi-agent.classpath"/>
-    <path refid="library.teamcity_vcs_api.classpath"/>
-  </path>
-  
-  <path id="mercurial-tests.runtime.module.classpath">
-    <pathelement location="${mercurial-tests.output.dir}"/>
-    <pathelement location="${mercurial-server.output.dir}"/>
-    <path refid="library.teamcityapi-server.classpath"/>
-    <path refid="library.idea-openapi.classpath"/>
-    <path refid="library.log4j.classpath"/>
-    <pathelement location="${mercurial-common.output.dir}"/>
-    <path refid="library.teamcityapi-common.classpath"/>
-    <path refid="library.jdom.classpath"/>
-    <path refid="library.teamcity_vcs_api.classpath"/>
-    <path refid="library.junit.classpath"/>
-    <path refid="library.testng.classpath"/>
-    <path refid="library.jmock.classpath"/>
-    <pathelement location="${mercurial-agent.output.dir}"/>
-    <path refid="library.teamcityapi-agent.classpath"/>
-    <path refid="library.teamcity-testsapi.classpath"/>
-    <path refid="library.teamcity-impl.classpath"/>
-  </path>
-  
-  
-  <patternset id="excluded.from.module.mercurial-tests">
-    <patternset refid="ignored.files"/>
-  </patternset>
-  
-  <patternset id="excluded.from.compilation.mercurial-tests">
-    <patternset refid="excluded.from.module.mercurial-tests"/>
-  </patternset>
-  
-  <path id="mercurial-tests.module.test.sourcepath">
-    <dirset dir="${module.mercurial-tests.basedir}/mercurial-tests">
-      <include name="src"/>
-    </dirset>
-  </path>
-  
-  
-  <target name="compile.module.mercurial-tests" depends="compile.module.mercurial-tests.production,compile.module.mercurial-tests.tests" description="Compile module mercurial-tests"/>
-  
-  <target name="compile.module.mercurial-tests.production" depends="compile.module.mercurial-server,compile.module.mercurial-common,compile.module.mercurial-agent" description="Compile module mercurial-tests; production classes"/>
-  
-  <target name="compile.module.mercurial-tests.tests" depends="compile.module.mercurial-tests.production" description="compile module mercurial-tests; test classes" unless="skip.tests">
-    <mkdir dir="${mercurial-tests.testoutput.dir}"/>
-    <javac destdir="${mercurial-tests.testoutput.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true">
-      <compilerarg line="${compiler.args.mercurial-tests}"/>
-      <bootclasspath refid="mercurial-tests.module.bootclasspath"/>
-      <classpath refid="mercurial-tests.module.classpath"/>
-      <src refid="mercurial-tests.module.test.sourcepath"/>
-      <patternset refid="excluded.from.compilation.mercurial-tests"/>
-    </javac>
-    
-    <copy todir="${mercurial-tests.testoutput.dir}">
-      <fileset dir="${module.mercurial-tests.basedir}/mercurial-tests/src">
-        <patternset refid="compiler.resources"/>
-        <type type="file"/>
-      </fileset>
-    </copy>
-  </target>
-  
-  <target name="clean.module.mercurial-tests" description="cleanup module">
-    <delete dir="${mercurial-tests.output.dir}"/>
-    <delete dir="${mercurial-tests.testoutput.dir}"/>
-  </target>
-  
-  <target name="init" description="Build initialization">
-    <!-- Perform any build initialization in this target -->
-  </target>
-  
-  <target name="clean" depends="clean.module.main, clean.module.mercurial-common, clean.module.mercurial-agent, clean.module.mercurial-server, clean.module.mercurial-tests" description="cleanup all"/>
-  
-  <target name="build.modules" depends="init, clean, compile.module.main, compile.module.mercurial-common, compile.module.mercurial-agent, compile.module.mercurial-server, compile.module.mercurial-tests" description="build all modules"/>
-  
-  <target name="all" depends="build.modules" description="build all"/>
-</project>
\ No newline at end of file
--- a/teamcity-common.xml	Fri Jul 22 12:26:37 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,304 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Copyright 2000-2014 JetBrains s.r.o.
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~ http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<project name="TeamCityPluginCommon">
-
-  <!--
-  Tasks:
-                package.teamcity.plugin
-                deploy.teamcity.plugin
-                undeploy.teamcity.plugin
-                unpack.teamcity
-
-  Targets:
-                check.teamcitydistribution
-  -->
-
-  <property name="path.variable.teamcitydistribution" value="${teamcity.distribution}"/>
-
-  <property name="teamcity.internal.default.out" value="dist"/>
-
-
-  <macrodef name="package.teamcity.plugin" description="packages TeamCity plugin">
-    <attribute name="name" description="name of the plugin"/>
-    <attribute name="server.output" default="" description="path to compiled server plugin output"/>
-    <attribute name="agent.output" default="" description="path to compiled agent plugin output"/>
-    <attribute name="common.output" default="" description="path to compiled common plugin output"/>
-    <attribute name="out" default="${teamcity.internal.default.out}" description="directory to put prepared plugin zip into"/>
-    <attribute name="plugin.descriptor.file" default="${basedir}/teamcity-plugin.xml" description="path to teamcity-plugin.xml file"/>
-    <attribute name="common.jar.name" default="@{name}-common.jar" description="name of the shared jar between server and agent"/>
-    <attribute name="out.unpacked" default="@{out}/unpacked"
-               description="name of the directory to store unpacked plugin (not packed into zip)"/>
-
-    <attribute name="server.lib.dir" default="" description="directory to get libs for the server part"/>
-    <attribute name="server.lib.includes" default="none should match" description="includes pattern of the files in the directory"/>
-    <attribute name="plugin.version" default="SNAPSHOT"
-               description="the version of the plugin to put into teamcity-plugin.xml instead of '@Plugin_Version@'"/>
-    <attribute name="plugin.vendor" default="Unknown vendor"
-               description="name of the vendor to put into teamcity-plugin.xml instead of '@Plugin_Vendor@'"/>
-    <attribute name="plugin.vendor.url" default=""
-               description="vendor URL to put into teamcity-plugin.xml instead of '@Plugin_Vendor_Url@'"/>
-
-    <element name="server-additional-files" optional="yes" description="fileset of the files to pack into root of the server plugin part"/>
-    <element name="agent-additional-files" optional="yes" description="fileset of the files to pack into root of the agent plugin part"/>
-
-    <sequential>
-
-      <antcall target="check.already.defined"/>
-
-      <property name="teamcity.internal.distrib.prep" value="${basedir}/temp/dist_prep"/>
-      <property name="teamcity.internal.distrib.prep.agent" value="${teamcity.internal.distrib.prep}/agent"/>
-      <property name="teamcity.internal.distrib.prep.common" value="${teamcity.internal.distrib.prep}/common"/>
-      <property name="teamcity.internal.distrib.prep.agent.jars" value="${teamcity.internal.distrib.prep.agent}/unpacked"/>
-
-
-      <!-- build jars -->
-
-      <delete dir="@{out.unpacked}" quiet="true"/>
-      <delete dir="${teamcity.internal.distrib.prep}" quiet="true"/>
-
-      <mkdir dir="@{out.unpacked}"/>
-
-      <condition property="common.needed">
-        <length string="@{common.output}" when="greater" length="0"/>
-      </condition>
-      <condition property="server.needed">
-        <length string="@{server.output}" when="greater" length="0"/>
-      </condition>
-      <condition property="agent.needed">
-        <length string="@{agent.output}" when="greater" length="0"/>
-      </condition>
-
-      <condition property="plugin.descriptor.file.needed">
-        <and>
-          <available file="@{plugin.descriptor.file}"/>
-          <length string="@{plugin.descriptor.file}" when="greater" length="0"/>
-        </and>
-      </condition>
-
-      <mkdir dir="${teamcity.internal.distrib.prep.common}"/>
-      <antcall target="prepare.common.part">
-        <param name="common.output" value="@{common.output}"/>
-        <param name="common.jar.path" value="${teamcity.internal.distrib.prep.common}/@{common.jar.name}"/>
-      </antcall>
-
-      <antcall target="prepare.server.part">
-        <param name="out.unpacked" value="@{out.unpacked}"/>
-        <param name="name" value="@{name}"/>
-        <param name="server.output" value="@{server.output}"/>
-        <param name="common.jar.path" value="${teamcity.internal.distrib.prep.common}/@{common.jar.name}"/>
-        <param name="lib.dir" value="@{server.lib.dir}"/>
-        <param name="lib.includes" value="@{server.lib.includes}"/>
-      </antcall>
-
-      <antcall target="prepare.agent.part">
-        <param name="out.unpacked" value="@{out.unpacked}"/>
-        <param name="name" value="@{name}"/>
-        <param name="agent.output" value="@{agent.output}"/>
-        <param name="common.jar.path" value="${teamcity.internal.distrib.prep.common}/@{common.jar.name}"/>
-      </antcall>
-
-      <!-- copy additional agent files -->
-      <mkdir dir="${teamcity.internal.distrib.prep.agent.jars}/@{name}" />
-      <copy todir="${teamcity.internal.distrib.prep.agent.jars}/@{name}">
-        <fileset dir="${basedir}" excludes="**"/>
-        <agent-additional-files/>
-      </copy>
-
-      <antcall target="pack.agent.part">
-        <param name="out.unpacked" value="@{out.unpacked}"/>
-        <param name="name" value="@{name}"/>
-      </antcall>
-
-      <!-- copy teamcity-plugin.xml -->
-      <antcall target="prepare.plugin.descriptor.file">
-        <param name="source" value="@{plugin.descriptor.file}"/>
-        <param name="dest" value="@{out.unpacked}/teamcity-plugin.xml"/>
-        <param name="plugin.version" value="@{plugin.version}"/>
-        <param name="plugin.vendor" value="@{plugin.vendor}"/>
-        <param name="plugin.vendor.url" value="@{plugin.vendor.url}"/>
-      </antcall>
-
-      <!-- copy additional server plugin files -->
-      <copy todir="@{out.unpacked}">
-        <fileset dir="${basedir}" excludes="**"/>
-        <server-additional-files/>
-      </copy>
-
-      <!-- clean -->
-      <echo message="Cleaning..."/>
-      <delete dir="${teamcity.internal.distrib.prep}" quiet="true"/>
-
-      <!-- package in zip -->
-      <echo message="Packaging zip..."/>
-      <delete file="@{out}/@{name}.zip" quiet="true"/>
-      <zip destfile="@{out}/@{name}.zip">
-        <fileset dir="@{out.unpacked}"/>
-      </zip>
-      <echo message="To install the plugin, place '@{out}\@{name}.zip' into '.BuildServer/plugins' directory"/>
-
-    </sequential>
-  </macrodef>
-
-  <target name="check.teamcitydistribution" description="checks whether TeamCity distribution ready to be used by IDEA-generated build">
-    <check.property name="path.variable.teamcitydistribution"
-                    fail-message="Please define 'teamcity.distribution' or 'path.variable.teamcitydistribution' property (e.g. in build.properties file). The property should point to unpacked TeamCity .tar.gz or .exe distribution."
-        />
-
-    <condition property="teamcity.distribution.not.present">
-      <not>
-        <and>
-          <available file="${path.variable.teamcitydistribution}/webapps/ROOT/WEB-INF/lib"/>
-        </and>
-      </not>
-    </condition>
-    <fail if="teamcity.distribution.not.present"
-          message="Cannot find TeamCity distribution at path '${path.variable.teamcitydistribution}'. The property 'teamcity.distribution' or 'path.variable.teamcitydistribution' should point to unpacked TeamCity .tar.gz or .exe distribution."/>
-    <echo message="Using ${path.variable.teamcitydistribution} as TeamCity distribution" />
-  </target>
-
-  <macrodef name="deploy.teamcity.plugin">
-    <attribute name="name"/>
-    <attribute name="teamcity.data.path" default="${user.home}/.BuildServer" description="path to .BuildServer"/>
-    <attribute name="out" default="${teamcity.internal.default.out}" description="directory storing prepared plugin zip"/>
-
-    <sequential>
-      <copy file="@{out}/@{name}.zip" todir="@{teamcity.data.path}/plugins" failonerror="true"/>
-    </sequential>
-  </macrodef>
-
-  <macrodef name="undeploy.teamcity.plugin">
-    <attribute name="name"/>
-    <attribute name="teamcity.data.path" default="${user.home}/.BuildServer" description="path to .BuildServer"/>
-
-    <sequential>
-      <delete file="@{teamcity.data.path}/plugins/@{name}.zip" quiet="true"/>
-    </sequential>
-  </macrodef>
-
-
-  <macrodef name="unpack.teamcity" description="TeamCity distribution unpacking">
-    <attribute name="distribution.dir" default="${basedir}/teamcity-dist"
-               description="path to put unpacked TeamCity distribution into. Warning: the content of the directory will be deleted!"/>
-    <attribute name="teamcity.data.path" default="${user.home}/.BuildServer" description="path to .BuildServer"/>
-    <attribute name="teamcity.tar.gz-location" default="${basedir}" description="path where TeamCity-NNNN.tar.gz file resides"/>
-
-    <sequential>
-      <delete dir="@{distribution.dir}" quiet="true"/>
-      <mkdir dir="@{distribution.dir}"/>
-
-      <!-- TODO: issue error if there are several matching files -->
-
-      <untar compression="gzip" dest="@{distribution.dir}">
-        <fileset dir="@{teamcity.tar.gz-location}">
-          <include name="*.tar.gz"/>
-        </fileset>
-      </untar>
-
-      <move todir="@{distribution.dir}">
-        <fileset dir="@{distribution.dir}\TeamCity">
-          <include name="**"/>
-        </fileset>
-      </move>
-    </sequential>
-  </macrodef>
-
-
-  <!--   ** Implementation **   -->
-
-  <macrodef name="check.property">
-    <attribute name="name"/>
-    <attribute name="fail-message" default=""/>
-    <attribute name="check-path" default=""/>
-    <sequential>
-      <condition property="is.configured.@{name}">
-        <not>
-          <and>
-            <isset property="@{name}"/>
-            <length string="${@{name}}" when="greater" length="0"/>
-          </and>
-        </not>
-      </condition>
-      <fail if="is.configured.@{name}"
-            message="Property '@{name}' not defined. @{fail-message}"/>
-    </sequential>
-  </macrodef>
-
-
-  <target name="prepare.common.part" if="common.needed">
-    <jar destfile="${common.jar.path}">
-      <fileset dir="${common.output}"/>
-    </jar>
-  </target>
-
-
-  <target name="prepare.server.part" if="server.needed">
-    <mkdir dir="${out.unpacked}/server"/>
-
-    <jar destfile="${out.unpacked}/server/${name}.jar">
-      <fileset dir="${server.output}"/>
-    </jar>
-
-    <copy todir="${out.unpacked}/server" failonerror="false">
-      <fileset file="${common.jar.path}"/>
-      <fileset dir="${lib.dir}" includes="${lib.includes}"/>
-    </copy>
-  </target>
-
-  <target name="pack.agent.part" if="agent.needed">
-    <zip destfile="${out.unpacked}/agent/${name}.zip">
-      <fileset dir="${teamcity.internal.distrib.prep.agent.jars}"/>
-    </zip>
-  </target>
-
-  <target name="prepare.agent.part" if="agent.needed">
-    <!-- prepare.agent.part -->
-    <mkdir dir="${teamcity.internal.distrib.prep.agent}"/>
-    <mkdir dir="${teamcity.internal.distrib.prep.agent.jars}/${name}/lib"/>
-    <mkdir dir="${out.unpacked}/agent"/>
-
-    <jar destfile="${teamcity.internal.distrib.prep.agent.jars}/${name}/lib/${name}.jar">
-      <fileset dir="${agent.output}"/>
-    </jar>
-
-    <copy todir="${teamcity.internal.distrib.prep.agent.jars}/${name}/lib" failonerror="false">
-      <fileset file="${common.jar.path}"/>
-    </copy>
-  </target>
-
-  <target name="prepare.plugin.descriptor.file" if="plugin.descriptor.file.needed">
-    <echo message="Copying plugin descriptor file '${source}' to '${dest}'."/>
-    <copy file="${source}" tofile="${dest}" failonerror="false"/>
-
-    <echo message="Replacing '@Plugin_Version@', '@Plugin_Vendor@' and '@Plugin_Vendor_Url@' in the copied plugin descriptor file."/>
-    <replace file="${dest}">
-      <replacefilter token="@version@" value="${plugin.version}"/>
-      <replacefilter token="@Plugin_Version@" value="${plugin.version}"/>
-      <replacefilter token="@Plugin_Vendor@" value="${plugin.vendor}"/>
-      <replacefilter token="@Plugin_Vendor_Url@" value="${plugin.vendor.url}"/>
-    </replace>
-  </target>
-
-  <target name="check.already.defined">
-    <condition property="already.defined">
-      <isset property="teamcity.internal.distrib.prep"/>
-    </condition>
-    <fail if="already.defined"
-          message="It seems you are trying to use the script several times in the same context. This script does not support such use. Please call this script as a separate Ant process, via 'ant' task."/>
-  </target>
-
-</project>
\ No newline at end of file