changeset 518:5634b52d72ad

Merge branch Faradi-7.1.x
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Fri, 30 Nov 2012 17:25:41 +0400
parents 4688509f4e3a (diff) 9c22b0679417 (current diff)
children a467f08ac929
files
diffstat 90 files changed, 1784 insertions(+), 1313 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Fri Nov 30 17:24:32 2012 +0400
+++ b/.hgignore	Fri Nov 30 17:25:41 2012 +0400
@@ -2,4 +2,7 @@
 test-output
 .iws
 dist
-mercurial.properties
\ No newline at end of file
+mercurial.properties
+syntax: glob
+.idea/workspace.xml
+out
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/ant.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="AntConfiguration">
+    <defaultAnt bundledAnt="true" />
+    <buildFile url="file://$PROJECT_DIR$/build.xml">
+      <additionalClassPath />
+      <antReference projectDefault="true" />
+      <customJdkName value="" />
+      <maximumHeapSize value="128" />
+      <maximumStackSize value="32" />
+      <properties />
+    </buildFile>
+    <buildFile url="file://$PROJECT_DIR$/build/ant.build.xml">
+      <additionalClassPath />
+      <antReference projectDefault="true" />
+      <customJdkName value="" />
+      <maximumHeapSize value="128" />
+      <maximumStackSize value="2" />
+      <properties />
+    </buildFile>
+  </component>
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/artifacts/mercurial_agent_jar.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,14 @@
+<component name="ArtifactManager">
+  <artifact type="jar" name="mercurial-agent.jar">
+    <output-path>$PROJECT_DIR$/out/artifacts/mercurial_agent_jar</output-path>
+    <properties id="ant-postprocessing">
+      <options enabled="true">
+        <file>file://$PROJECT_DIR$/build/ant.build.xml</file>
+        <target>replace-tokens-in-teamcity-plugin-xml</target>
+      </options>
+    </properties>
+    <root id="archive" name="mercurial-agent.jar">
+      <element id="module-output" name="mercurial-agent" />
+    </root>
+  </artifact>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/artifacts/mercurial_common_jar.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,8 @@
+<component name="ArtifactManager">
+  <artifact type="jar" name="mercurial-common.jar">
+    <output-path>$PROJECT_DIR$/out/artifacts/mercurial_common_jar</output-path>
+    <root id="archive" name="mercurial-common.jar">
+      <element id="module-output" name="mercurial-common" />
+    </root>
+  </artifact>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/artifacts/mercurial_server_jar.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,8 @@
+<component name="ArtifactManager">
+  <artifact type="jar" name="mercurial-server.jar">
+    <output-path>$PROJECT_DIR$/out/artifacts/mercurial_server_jar</output-path>
+    <root id="archive" name="mercurial-server.jar">
+      <element id="module-output" name="mercurial-server" />
+    </root>
+  </artifact>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/artifacts/mercurial_server_tc_jar.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,8 @@
+<component name="ArtifactManager">
+  <artifact type="jar" name="mercurial-server-tc.jar">
+    <output-path>$PROJECT_DIR$/out/artifacts/mercurial_server_tc_jar</output-path>
+    <root id="archive" name="mercurial-server-tc.jar">
+      <element id="module-output" name="mercurial-server-tc" />
+    </root>
+  </artifact>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/artifacts/plugin.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,29 @@
+<component name="ArtifactManager">
+  <artifact name="plugin">
+    <output-path>$PROJECT_DIR$/out/artifacts/plugin</output-path>
+    <properties id="ant-postprocessing">
+      <options enabled="true">
+        <file>file://$PROJECT_DIR$/build/ant.build.xml</file>
+        <target>replace-tokens-in-teamcity-plugin-xml</target>
+      </options>
+    </properties>
+    <root id="root">
+      <element id="directory" name="server">
+        <element id="artifact" artifact-name="mercurial-server.jar" />
+        <element id="artifact" artifact-name="mercurial-common.jar" />
+        <element id="artifact" artifact-name="mercurial-server-tc.jar" />
+      </element>
+      <element id="directory" name="agent">
+        <element id="archive" name="mercurial.zip">
+          <element id="directory" name="mercurial">
+            <element id="directory" name="lib">
+              <element id="artifact" artifact-name="mercurial-common.jar" />
+              <element id="artifact" artifact-name="mercurial-agent.jar" />
+            </element>
+          </element>
+        </element>
+      </element>
+      <element id="file-copy" path="$PROJECT_DIR$/teamcity-plugin.xml" />
+    </root>
+  </artifact>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/artifacts/zip.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,10 @@
+<component name="ArtifactManager">
+  <artifact name="zip">
+    <output-path>$PROJECT_DIR$/dist</output-path>
+    <root id="root">
+      <element id="archive" name="mercurial.zip">
+        <element id="artifact" artifact-name="plugin" />
+      </element>
+    </root>
+  </artifact>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/compiler.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <option name="DEFAULT_COMPILER" value="Javac" />
+    <resourceExtensions>
+      <entry name=".+\.(properties|xml|html|dtd|tld)" />
+      <entry name=".+\.(gif|png|jpeg|jpg)" />
+    </resourceExtensions>
+    <wildcardResourcePatterns>
+      <entry name="?*.properties" />
+      <entry name="?*.xml" />
+      <entry name="?*.gif" />
+      <entry name="?*.png" />
+      <entry name="?*.jpeg" />
+      <entry name="?*.jpg" />
+      <entry name="?*.html" />
+      <entry name="?*.dtd" />
+      <entry name="?*.tld" />
+      <entry name="?*.jsp" />
+      <entry name="?*.tag" />
+      <entry name="?*.template" />
+      <entry name="do-not-load-in-vcs-mode" />
+    </wildcardResourcePatterns>
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="false">
+        <processorPath useClasspath="true" />
+      </profile>
+    </annotationProcessing>
+  </component>
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/copyright/profiles_settings.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,5 @@
+<component name="CopyrightManager">
+  <settings default="">
+    <module2copyright />
+  </settings>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/encodings.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/inspectionProfiles/Project_Default.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,11 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0" is_locked="false">
+    <option name="myName" value="Project Default" />
+    <option name="myLocal" value="false" />
+    <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
+      <option name="processCode" value="true" />
+      <option name="processLiterals" value="true" />
+      <option name="processComments" value="true" />
+    </inspection_tool>
+  </profile>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/inspectionProfiles/profiles_settings.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,15 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="PROJECT_PROFILE" value="Project Default" />
+    <option name="USE_PROJECT_PROFILE" value="true" />
+    <version value="1.0" />
+    <list size="6">
+      <item index="0" class="java.lang.String" itemvalue="TYPO" />
+      <item index="1" class="java.lang.String" itemvalue="WEAK WARNING" />
+      <item index="2" class="java.lang.String" itemvalue="INFO" />
+      <item index="3" class="java.lang.String" itemvalue="WARNING" />
+      <item index="4" class="java.lang.String" itemvalue="ERROR" />
+      <item index="5" class="java.lang.String" itemvalue="SERVER PROBLEM" />
+    </list>
+  </settings>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/IDEA_openapi.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,12 @@
+<component name="libraryTable">
+  <library name="IDEA-openapi">
+    <CLASSES>
+      <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/resources_en.jar!/" />
+      <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/util.jar!/" />
+      <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/openapi.jar!/" />
+      <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/annotations.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES />
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/JMock.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,15 @@
+<component name="libraryTable">
+  <library name="JMock">
+    <CLASSES>
+      <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/hamcrest-library-1.1.jar!/" />
+      <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/hamcrest-core-1.1.jar!/" />
+      <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/jmock-2.5.1.jar!/" />
+      <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/jmock-SNAPSHOT.jar!/" />
+      <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/hamcrest-integration-1.1.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/hamcrest-integration-1.1.jar!/" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/JUnit.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,9 @@
+<component name="libraryTable">
+  <library name="JUnit">
+    <CLASSES>
+      <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/junit-3.8.1.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES />
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/Log4j.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,9 @@
+<component name="libraryTable">
+  <library name="Log4j">
+    <CLASSES>
+      <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/log4j-1.2.12.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES />
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/TeamCityAPI_agent.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,12 @@
+<component name="libraryTable">
+  <library name="TeamCityAPI-agent">
+    <CLASSES>
+      <root url="jar://$TeamCityDistribution$/devPackage/agent-api.jar!/" />
+      <root url="jar://$TeamCityDistribution$/buildAgent/lib/agent.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="jar://$TeamCityDistribution$/devPackage/src/openApi-source.jar!/" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/TeamCityAPI_common.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,11 @@
+<component name="libraryTable">
+  <library name="TeamCityAPI-common">
+    <CLASSES>
+      <root url="jar://$TeamCityDistribution$/devPackage/common-api.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="jar://$TeamCityDistribution$/devPackage/src/openApi-source.jar!/" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/TeamCityAPI_server.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,12 @@
+<component name="libraryTable">
+  <library name="TeamCityAPI-server">
+    <CLASSES>
+      <root url="jar://$TeamCityDistribution$/devPackage/server-api.jar!/" />
+      <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/server.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="jar://$TeamCityDistribution$/devPackage/src/openApi-source.jar!/" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/TeamCity_TestsAPI.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,10 @@
+<component name="libraryTable">
+  <library name="TeamCity-TestsAPI">
+    <CLASSES>
+      <root url="jar://$TeamCityDistribution$/devPackage/tests/patches-test.jar!/" />
+      <root url="jar://$TeamCityDistribution$/devPackage/tests/tests-support.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES />
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/TeamCity_Vcs_Api.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,12 @@
+<component name="libraryTable">
+  <library name="TeamCity Vcs Api">
+    <CLASSES>
+      <root url="jar://$TeamCityDistribution$/devPackage/server-common-api.jar!/" />
+      <root url="jar://$TeamCityDistribution$/devPackage/server-vcs-api.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES>
+      <root url="jar://$TeamCityDistribution$/devPackage/src/openApi-source.jar!/" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/TeamCity_impl.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,10 @@
+<component name="libraryTable">
+  <library name="TeamCity-impl">
+    <CLASSES>
+      <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/patches-impl.jar!/" />
+      <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/trove4j.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES />
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/TestNG.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,9 @@
+<component name="libraryTable">
+  <library name="TestNG">
+    <CLASSES>
+      <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/testng-5.7-jdk15.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES />
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/libraries/jdom.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,9 @@
+<component name="libraryTable">
+  <library name="jdom">
+    <CLASSES>
+      <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/jdom.jar!/" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES />
+  </library>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/misc.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="EntryPointsManager">
+    <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>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/modules.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/main.iml" filepath="$PROJECT_DIR$/main.iml" />
+      <module fileurl="file://$PROJECT_DIR$/mercurial-agent/mercurial-agent.iml" filepath="$PROJECT_DIR$/mercurial-agent/mercurial-agent.iml" />
+      <module fileurl="file://$PROJECT_DIR$/mercurial-common/mercurial-common.iml" filepath="$PROJECT_DIR$/mercurial-common/mercurial-common.iml" />
+      <module fileurl="file://$PROJECT_DIR$/mercurial-server/mercurial-server.iml" filepath="$PROJECT_DIR$/mercurial-server/mercurial-server.iml" />
+      <module fileurl="file://$PROJECT_DIR$/mercurial-server-tc/mercurial-server-tc.iml" filepath="$PROJECT_DIR$/mercurial-server-tc/mercurial-server-tc.iml" />
+      <module fileurl="file://$PROJECT_DIR$/mercurial-tests/mercurial-tests.iml" filepath="$PROJECT_DIR$/mercurial-tests/mercurial-tests.iml" />
+    </modules>
+  </component>
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/runConfigurations/tests.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,38 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="tests" type="TestNG" factoryName="TestNG">
+    <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
+    <module name="mercurial-tests" />
+    <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+    <option name="ALTERNATIVE_JRE_PATH" value="" />
+    <option name="SUITE_NAME" value="$PROJECT_DIR$/mercurial-tests/src/testng.xml" />
+    <option name="PACKAGE_NAME" value="" />
+    <option name="MAIN_CLASS_NAME" value="" />
+    <option name="METHOD_NAME" value="" />
+    <option name="GROUP_NAME" value="" />
+    <option name="TEST_OBJECT" value="SUITE" />
+    <option name="VM_PARAMETERS" value="-ea" />
+    <option name="PARAMETERS" value="" />
+    <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
+    <option name="OUTPUT_DIRECTORY" value="" />
+    <option name="ANNOTATION_TYPE" />
+    <option name="ENV_VARIABLES" />
+    <option name="PASS_PARENT_ENVS" value="true" />
+    <option name="TEST_SEARCH_SCOPE">
+      <value defaultName="moduleWithDependencies" />
+    </option>
+    <option name="USE_DEFAULT_REPORTERS" value="false" />
+    <option name="PROPERTIES_FILE" value="" />
+    <envs />
+    <properties />
+    <listeners />
+    <RunnerSettings RunnerId="Debug">
+      <option name="DEBUG_PORT" value="51735" />
+      <option name="TRANSPORT" value="0" />
+      <option name="LOCAL" value="true" />
+    </RunnerSettings>
+    <RunnerSettings RunnerId="Run" />
+    <ConfigurationWrapper RunnerId="Debug" />
+    <ConfigurationWrapper RunnerId="Run" />
+    <method />
+  </configuration>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/scopes/scope_settings.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,5 @@
+<component name="DependencyValidationManager">
+  <state>
+    <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+  </state>
+</component>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/uiDesigner.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Palette2">
+    <group name="Swing">
+      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+      </item>
+      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
+        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+        <initial-values>
+          <property name="text" value="Button" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="RadioButton" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="CheckBox" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+        <initial-values>
+          <property name="text" value="Label" />
+        </initial-values>
+      </item>
+      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+          <preferred-size width="150" height="-1" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+          <preferred-size width="150" height="50" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+          <preferred-size width="200" height="200" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+      </item>
+      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+      </item>
+      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+          <preferred-size width="-1" height="20" />
+        </default-constraints>
+      </item>
+      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+      </item>
+      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+      </item>
+    </group>
+  </component>
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.idea/vcs.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="hg4idea" />
+  </component>
+</project>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/ant.build.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,24 @@
+<project name="build hooks" default="replace-tokens-in-teamcity-plugin-xml" basedir=".">
+
+
+  <target name="replace-tokens-in-teamcity-plugin-xml">
+    <property name="home" value="${artifact.output.path}"/>
+
+    <echo message="replacing tokens in teamcity-plugin.xml file under ${home}"/>
+
+    <condition property="build.number" value="snapshot" else="${build.number}">
+      <not>
+        <isset property="build.number"/>
+      </not>
+    </condition>
+
+    <echo message="Setting version to: ${build.number}"/>
+    <!-- update all references in teamcity-plugin.xml files -->
+    <replace dir="${home}" summary="true">
+      <include name="**/teamcity-plugin.xml"/>
+
+      <replacefilter token="@Plugin_Version@" value="${build.number}"/>
+    </replace>
+  </target>
+
+</project>
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepo.java	Fri Nov 30 17:25:41 2012 +0400
@@ -1,5 +1,6 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
+import com.intellij.openapi.util.Trinity;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.*;
 import jetbrains.buildServer.log.Loggers;
 import jetbrains.buildServer.util.FileUtil;
@@ -10,6 +11,7 @@
 import java.io.IOException;
 import java.util.*;
 
+import static java.util.Collections.emptyList;
 import static java.util.Collections.emptyMap;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.HgFileUtil.deleteDir;
 import static jetbrains.buildServer.util.FileUtil.isEmptyDir;
@@ -87,6 +89,10 @@
     return new VersionCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir);
   }
 
+  public ParentsCommand parents() {
+    return new ParentsCommand(myCommandSettingsFactory.create(), myHgPath, myWorkingDir);
+  }
+
   public String path() {
     return myWorkingDir.getAbsolutePath();
   }
@@ -153,11 +159,79 @@
     return getSubrepositories(new ChangeSet(revision));
   }
 
+  public List<SubRepoConfigChange> getSubrepoConfigChanges(@NotNull String revision) throws VcsException {
+    if (containsSubrepoConfigChange(revision)) {
+      List<String> parents = parents().ofRevision(revision).call();
+      return getSubrepoConfigChanges(revision, parents.get(0));//what about merges?
+    }
+    return emptyList();
+  }
+
+  public List<SubRepoConfigChange> getSubrepoConfigChanges(@NotNull ChangeSet cset) {
+    if (containsSubrepoConfigChange(cset))
+      return getSubrepoConfigChanges(cset.getId(), cset.getParents().get(0).getId());
+    return emptyList();
+  }
+
+  private List<SubRepoConfigChange> getSubrepoConfigChanges(@NotNull String revision, @NotNull String parentRevision) {
+    Map<String, SubRepo> curSubrepos = getSubrepositories(revision);
+    Map<String, SubRepo> prevSubrepos = getSubrepositories(parentRevision);
+    return getSubrepoConfigChanges(prevSubrepos, curSubrepos);
+
+  }
+
+  private List<SubRepoConfigChange> getSubrepoConfigChanges(@NotNull Map<String, SubRepo> prevSubrepos,
+                                                            @NotNull Map<String, SubRepo> curSubrepos) {
+    List<SubRepoConfigChange> configChanges = new ArrayList<SubRepoConfigChange>();
+    for (Map.Entry<String, SubRepo> e : curSubrepos.entrySet()) {
+      SubRepo curSubrepo = e.getValue();
+      SubRepo prevSubrepo = prevSubrepos.remove(e.getKey());
+      if (prevSubrepo == null) {
+        configChanges.add(new SubRepoConfigChange(e.getKey(), null, curSubrepo));
+      } else {
+        String prevRevision = prevSubrepo.revision();
+        String currentRevision = curSubrepo.revision();
+        if (!currentRevision.equals(prevRevision))
+          configChanges.add(new SubRepoConfigChange(e.getKey(), prevSubrepo, curSubrepo));
+      }
+    }
+    for (Map.Entry<String, SubRepo> e : prevSubrepos.entrySet()) {
+      configChanges.add(new SubRepoConfigChange(e.getKey(), e.getValue(), null));
+    }
+    return configChanges;
+  }
+
+  private boolean containsSubrepoConfigChange(@NotNull ChangeSet cset) {
+    for (FileStatus f : cset.getModifiedFiles()) {
+      if (containsSubrepoConfigChange(f))
+        return true;
+    }
+    return false;
+  }
+
+  private boolean containsSubrepoConfigChange(@NotNull String revision) throws VcsException {
+    List<FileStatus> changedFiles = status()
+            .fromRevision(revision)
+            .toRevision(revision)
+            .showAllFiles()
+            .call();
+    for (FileStatus f : changedFiles) {
+      if (containsSubrepoConfigChange(f))
+        return true;
+    }
+    return false;
+  }
+
+  private boolean containsSubrepoConfigChange(@NotNull FileStatus f) {
+    return f.getPath().equals(".hgsubstate");
+  }
+
+  //path->subrepo
   public Map<String, SubRepo> getSubrepositories(@NotNull ChangeSet cset) {
     String revId = cset.getId();
     Map<String, SubRepo> subrepos = mySubreposCache.get(revId);
     if (subrepos != null)
-      return subrepos;
+      return new HashMap<String, SubRepo>(subrepos);
     CatCommand cc = cat();
     cc.setRevId(revId);
     File catDir = null;
@@ -167,7 +241,7 @@
       File hgsubstate = new File(catDir, ".hgsubstate");
       subrepos = readSubrepositories(hgsub, hgsubstate);
       mySubreposCache.put(revId, subrepos);
-      return subrepos;
+      return new HashMap<String, SubRepo>(subrepos);
     } catch (VcsException e) {
       return emptyMap();
     } finally {
@@ -190,15 +264,11 @@
           String path = entry.getKey();
           String url = entry.getValue();
           String revision = path2revision.get(path);
-          if (revision != null) {
+          if (revision != null)
             result.put(path, new SubRepo(this, path, url, revision));
-          } else {
-//              myLogger.warning("Cannot find revision for subrepository at path " + path + " skip it");
-          }
         }
         return result;
       } catch (IOException e) {
-//          myLogger.warning("Error while trying to read subrepositories " + e.getMessage());
         return emptyMap();
       }
     } else {
@@ -211,11 +281,8 @@
     Map<String, String> result = new HashMap<String, String>();
     for (String line : FileUtil.readFile(hgsub)) {
       String[] parts = line.split(" = ");
-      if (parts.length == 2) {
+      if (parts.length == 2)
         result.put(parts[0], parts[1]);
-      } else {
-//          myLogger.warning("Cannot parse the line '" + line + "' from .hgsub, skip it");
-      }
     }
     return result;
   }
@@ -226,11 +293,8 @@
     Map<String, String> result = new HashMap<String, String>();
     for (String line : FileUtil.readFile(hgsubstate)) {
       String[] parts = line.split(" ");
-      if (parts.length == 2) {
+      if (parts.length == 2)
         result.put(parts[1], parts[0]);
-      } else {
-//          myLogger.warning("Cannot parse the line '" + line + "' from .hgsubstate, skip it");
-      }
     }
     return result;
   }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepo.java	Fri Nov 30 17:25:41 2012 +0400
@@ -34,6 +34,8 @@
 
   @NotNull
   public String revision() {
+    if (myRevision.length() > 12)
+      return myRevision.substring(0, 12);
     return myRevision;
   }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubRepoConfigChange.java	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,37 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * A change in subrepo configuration
+ */
+public class SubRepoConfigChange {
+
+  private final String myPath;
+  private final SubRepo myPrevious;
+  private final SubRepo myCurrent;
+
+  public SubRepoConfigChange(@NotNull String path,
+                             @Nullable SubRepo previous,
+                             @Nullable SubRepo current) {
+    myPath = path;
+    myPrevious = previous;
+    myCurrent = current;
+  }
+
+  @NotNull
+  public String getPath() {
+    return myPath;
+  }
+
+  @Nullable
+  public SubRepo getPrevious() {
+    return myPrevious;
+  }
+
+  @Nullable
+  public SubRepo getCurrent() {
+    return myCurrent;
+  }
+}
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommand.java	Fri Nov 30 17:25:41 2012 +0400
@@ -15,6 +15,7 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
 
+import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
@@ -58,6 +59,10 @@
     return cl;
   }
 
+  protected CommandResult runCommand(@NotNull MercurialCommandLine cli) throws VcsException {
+    return CommandUtil.runCommand(cli, myCommandSettings);
+  }
+
   protected Set<String> getPrivateData() {
     return emptySet();
   }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java	Fri Nov 30 17:25:41 2012 +0400
@@ -41,7 +41,7 @@
                                    @NotNull final String command,
                                    @NotNull final Set<String> privateData) {
     final long start = System.currentTimeMillis();
-    ExecResult res = SimpleCommandLineProcessRunner.runCommand(cli, null, new SimpleCommandLineProcessRunner.RunCommandEventsAdapter() {
+    ExecResult res = SimpleCommandLineProcessRunner.runCommand(cli, null, new SimpleCommandLineProcessRunner.ProcessRunCallbackAdapter() {
       @Override
       public Integer getOutputIdleSecondsTimeout() {
         return executionTimeout;
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/HgVcsRoot.java	Fri Nov 30 17:25:41 2012 +0400
@@ -43,8 +43,12 @@
   private File myCustomWorkingDir;
 
   public HgVcsRoot(@NotNull final VcsRoot vcsRoot) {
+    this(vcsRoot, vcsRoot.getProperty(Constants.REPOSITORY_PROP));
+  }
+
+  public HgVcsRoot(@NotNull VcsRoot vcsRoot, @NotNull String repository) {
     myRoot = vcsRoot;
-    myRepository = getProperty(Constants.REPOSITORY_PROP);
+    myRepository = repository;
     myHgCommandPath = getProperty(Constants.HG_COMMAND_PATH_PROP);
     myBranchName = getProperty(Constants.BRANCH_NAME_PROP);
     myCustomClonePath = getProperty(Constants.SERVER_CLONE_PATH_PROP);
@@ -61,6 +65,10 @@
     return myRepository;
   }
 
+  public HgVcsRoot withUrl(@NotNull String repositoryUrl) {
+    return new HgVcsRoot(this, repositoryUrl);
+  }
+
   /**
    * Returns name of the branch to use (returns 'default' if no branch specified)
    * @return see above
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ParentsCommand.java	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,38 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
+
+import jetbrains.buildServer.vcs.VcsException;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ParentsCommand extends BaseCommand {
+
+  private String myRevision;
+
+  public ParentsCommand(@NotNull CommandSettings commandSettings,
+                        @NotNull String hgPath,
+                        @NotNull File workingDir) {
+    super(commandSettings, hgPath, workingDir);
+  }
+
+  public ParentsCommand ofRevision(@NotNull String revision) {
+    myRevision = revision;
+    return this;
+  }
+
+  public List<String> call() throws VcsException {
+    MercurialCommandLine cli = createCommandLine();
+    cli.addParameter("parents");
+    cli.addParameter("-q");
+    if (myRevision != null)
+      cli.addParameters("-r", myRevision);
+    CommandResult res = runCommand(cli);
+    List<String> parentRevisions = new ArrayList<String>();
+    for (String line : res.getStdout().split("\n")) {
+      parentRevisions.add(new ChangeSet(line).getId());
+    }
+    return parentRevisions;
+  }
+}
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VcsRootCommand.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/VcsRootCommand.java	Fri Nov 30 17:25:41 2012 +0400
@@ -23,10 +23,6 @@
   }
 
 
-  protected CommandResult runCommand(@NotNull MercurialCommandLine cli) throws VcsException {
-    return CommandUtil.runCommand(cli, myCommandSettings);
-  }
-
   protected CommandResult runCommand(@NotNull MercurialCommandLine cli, @NotNull CommandSettings s) throws VcsException {
     s.setPrivateData(getPrivateData());
     return CommandUtil.runCommand(cli, s);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-server-tc/mercurial-server-tc.iml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" 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="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="TeamCity Vcs Api" level="project" />
+    <orderEntry type="library" name="TeamCityAPI-server" level="project" />
+    <orderEntry type="module" module-name="mercurial-server" />
+    <orderEntry type="library" name="TeamCityAPI-common" level="project" />
+    <orderEntry type="module" module-name="mercurial-common" />
+  </component>
+</module>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-server-tc/src/META-INF/build-server-plugin-mercurial-tc.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans default-autowire="constructor">
+    <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialExtensionRegistry"/>
+    <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialBranchSupport"/>
+    <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialCleaner"/>
+</beans>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-server-tc/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialBranchSupport.java	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,78 @@
+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 jetbrains.buildServer.vcs.impl.VcsRootImpl;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class MercurialBranchSupport implements BranchSupport, MercurialServerExtension {
+
+  private HgVcsRootFactory myHgRootFactory;
+  private MercurialVcsSupport myMercurialSupport;
+
+  public MercurialBranchSupport() {
+  }
+
+  public void setMercurialSupport(@NotNull MercurialVcsSupport mercurialSupport) {
+    myMercurialSupport = mercurialSupport;
+  }
+
+  public void setHgRootFactory(@NotNull HgVcsRootFactory hgRootFactory) {
+    myHgRootFactory = hgRootFactory;
+  }
+
+  @NotNull
+  public String getRemoteRunOnBranchPattern() {
+    return "remote-run/*";
+  }
+
+  @NotNull
+  public RepositoryStateData getCurrentState(@NotNull VcsRoot repository) throws VcsException {
+    return myMercurialSupport.getCurrentState(repository);
+  }
+
+  @NotNull
+  public Map<String, String> getBranchRootOptions(@NotNull VcsRoot original, @NotNull String branchName) {
+    final Map<String, String> options = new HashMap<String, String>(original.getProperties());
+    options.put(Constants.BRANCH_NAME_PROP, branchName);
+    return options;
+  }
+
+  @Nullable
+  public PersonalBranchDescription getPersonalBranchDescription(@NotNull VcsRoot original, @NotNull String branchName) throws VcsException {
+    HgVcsRoot hgRoot = myHgRootFactory.createHgRoot(original);
+    VcsRoot branchRoot = createBranchRoot(original, branchName);
+    String baseVersion = myMercurialSupport.getCurrentVersion(original);
+    String branchVersion = myMercurialSupport.getCurrentVersion(branchRoot);
+    String mergeBase = myMercurialSupport.getMergeBase(hgRoot, baseVersion, branchVersion);
+
+    if (mergeBase == null)
+      return null;
+
+    List<ChangeSet> changeSets = myMercurialSupport.createRepo(hgRoot)
+            .log()
+            .fromRevision(mergeBase)
+            .toRevision(branchVersion)
+            .showCommitsFromAllBranches()
+            .call();
+    if (changeSets.size() > 1) {//when branch points to the commit in original branch we get 1 cset
+      String branchId = changeSets.get(1).getId();
+      String username = changeSets.get(changeSets.size() - 1).getUser();
+      return new PersonalBranchDescription(branchId, username);
+    } else {
+      return null;
+    }
+  }
+
+  private VcsRoot createBranchRoot(VcsRoot original, String branchName) {
+    VcsRootImpl result = new VcsRootImpl(original.getId(), original.getProperties());
+    result.addProperty(Constants.BRANCH_NAME_PROP, branchName);
+    return result;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-server-tc/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialCleaner.java	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,24 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import jetbrains.buildServer.serverSide.BuildServerAdapter;
+import jetbrains.buildServer.serverSide.BuildServerListener;
+import jetbrains.buildServer.serverSide.SBuildServer;
+import jetbrains.buildServer.util.EventDispatcher;
+import jetbrains.buildServer.vcs.VcsManager;
+import org.jetbrains.annotations.NotNull;
+
+public class MercurialCleaner implements MercurialServerExtension {
+
+  public MercurialCleaner(@NotNull final SBuildServer server,
+                          @NotNull final VcsManager vcsManager,
+                          @NotNull final EventDispatcher<BuildServerListener> dispatcher,
+                          @NotNull final ServerPluginConfig config,
+                          @NotNull final MirrorManager mirrorManager) {
+    dispatcher.addListener(new BuildServerAdapter() {
+      @Override
+      public void cleanupFinished() {
+        server.getExecutor().submit(new Cleanup(vcsManager, mirrorManager, config));
+      }
+    });
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-server-tc/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialExtensionRegistry.java	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,13 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+public class MercurialExtensionRegistry {
+
+  public MercurialExtensionRegistry(@NotNull MercurialVcsSupport vcs,
+                                    @NotNull Collection<MercurialServerExtension> extensions) {
+    vcs.setExtensions(extensions);
+  }
+}
--- a/mercurial-server/mercurial-server.iml	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-server/mercurial-server.iml	Fri Nov 30 17:25:41 2012 +0400
@@ -19,6 +19,7 @@
     <orderEntry type="library" exported="" name="IDEA-openapi" level="project" />
     <orderEntry type="library" exported="" name="Log4j" level="project" />
     <orderEntry type="module" module-name="mercurial-common" />
+    <orderEntry type="library" name="TeamCity Vcs Api" level="project" />
   </component>
 </module>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialServerExtension.java	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,4 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+public interface MercurialServerExtension {
+}
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Fri Nov 30 17:25:41 2012 +0400
@@ -15,7 +15,6 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
-import jetbrains.buildServer.BuildAgent;
 import jetbrains.buildServer.Used;
 import jetbrains.buildServer.buildTriggers.vcs.AbstractVcsPropertiesProcessor;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.*;
@@ -28,7 +27,6 @@
 import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.util.cache.ResetCacheRegister;
 import jetbrains.buildServer.vcs.*;
-import jetbrains.buildServer.vcs.impl.VcsRootImpl;
 import jetbrains.buildServer.vcs.patches.PatchBuilder;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -52,9 +50,8 @@
  * <p>Working copy of repository is created in the $TEAMCITY_DATA_PATH/system/caches/hg_&lt;hash code> folder.
  * <p>Personal builds (remote runs) are not yet supported, they require corresponding functionality from the IDE.
  */
-public class MercurialVcsSupport extends ServerVcsSupport implements LabelingSupport, VcsFileContentProvider, BranchSupport,
+public class MercurialVcsSupport extends ServerVcsSupport implements LabelingSupport, VcsFileContentProvider,
         CollectChangesBetweenRoots, CollectChangesBetweenRepositories, BuildPatchByCheckoutRules {
-  private final VcsManager myVcsManager;
   private final MirrorManager myMirrorManager;
   private final ServerPluginConfig myConfig;
   private final HgPathProvider myHgPathProvider;
@@ -63,10 +60,9 @@
   private final FileFilter myIgnoreDotHgFilter = new IgnoreDotHgFilter();
   private final FileFilter myAcceptAllFilter = new AcceptAllFilter();
   private final HgTestConnectionSupport myTestConnection;
+  private Collection<MercurialServerExtension> myExtensions;
 
-  public MercurialVcsSupport(@NotNull final VcsManager vcsManager,
-                             @NotNull final SBuildServer server,
-                             @NotNull final EventDispatcher<BuildServerListener> dispatcher,
+  public MercurialVcsSupport(@NotNull final EventDispatcher<ServerListener> dispatcher,
                              @NotNull final ResetCacheRegister resetCacheHandlerManager,
                              @NotNull final ServerPluginConfig config,
                              @NotNull final HgPathProvider hgPathProvider,
@@ -74,7 +70,6 @@
                              @NotNull final MirrorManager mirrorManager,
                              @NotNull final HgVcsRootFactory hgVcsRootFactory,
                              @NotNull final HgTestConnectionSupport testConnection) {
-    myVcsManager = vcsManager;
     myConfig = config;
     myMirrorManager = mirrorManager;
     myHgPathProvider = hgPathProvider;
@@ -82,30 +77,19 @@
     myHgVcsRootFactory = hgVcsRootFactory;
     myTestConnection = testConnection;
     resetCacheHandlerManager.registerHandler(new MercurialResetCacheHandler(myMirrorManager));
-    dispatcher.addListener(new BuildServerAdapter() {
-      @Override
-      public void cleanupFinished() {
-        server.getExecutor().submit(new Cleanup(myVcsManager, myMirrorManager, myConfig));
-      }
-
+    dispatcher.addListener(new ServerListenerAdapter() {
       @Override
       public void serverShutdown() {
         myRepoFactory.dispose();
       }
-
-      @Override
-      public void sourcesVersionReleased(@NotNull final BuildAgent agent) {
-        super.sourcesVersionReleased(agent);
-        server.getExecutor().submit(new Runnable() {
-          public void run() {
-            deleteWithLocking(myMirrorManager.getMirrors());
-          }
-        });
-      }
     });
     logUsedHg();
   }
 
+  public void setExtensions(@NotNull Collection<MercurialServerExtension> extensions) {
+    myExtensions = extensions;
+  }
+
   private void logUsedHg() {
     String hgPath = myConfig.getHgPath();
     if (hgPath != null)
@@ -114,17 +98,6 @@
       Loggers.VCS.info("Server-wide hg path is not set, will use path from the VCS root settings");
   }
 
-  private void deleteWithLocking(Collection<File> filesForDelete) {
-    for (File f : filesForDelete) {
-      lockWorkDir(f);
-      try {
-        FileUtil.delete(f);
-      } finally {
-        unlockWorkDir(f);
-      }
-    }
-  }
-
   private List<VcsChange> toVcsChanges(final List<FileStatus> modifiedFiles, String prevVer, String curVer, CheckoutRules rules) {
     List<VcsChange> files = new ArrayList<VcsChange>();
     for (FileStatus mf: modifiedFiles) {
@@ -443,22 +416,15 @@
   }
 
   @NotNull
-  public String getRemoteRunOnBranchPattern() {
-    return "remote-run/*";
-  }
-
-  @NotNull
-  public RepositoryState getCurrentState(@NotNull VcsRoot root) throws VcsException {
+  public RepositoryStateData getCurrentState(@NotNull VcsRoot root) throws VcsException {
     HgVcsRoot hgRoot = myHgVcsRootFactory.createHgRoot(root);
     Map<String, String> branchRevisions = getBranchesRevisions(hgRoot);
     String defaultBranchName = hgRoot.getBranchName();
     if (branchRevisions.get(defaultBranchName) == null) {
-      VcsException e = new VcsException("Cannot find revision of the default branch '" +
+      throw new VcsException("Cannot find revision of the default branch '" +
               defaultBranchName + "' of vcs root " + LogUtil.describe(root));
-      e.setRoot(root);
-      throw e;
     }
-    return RepositoryStateFactory.createRepositoryState(branchRevisions, defaultBranchName);
+    return RepositoryStateData.createVersionState(defaultBranchName, branchRevisions);
   }
 
   @NotNull
@@ -473,58 +439,18 @@
   }
 
   @NotNull
-  public Map<String, String> getBranchRootOptions(@NotNull VcsRoot root, @NotNull String branchName) {
-    final Map<String, String> options = new HashMap<String, String>(root.getProperties());
-    options.put(Constants.BRANCH_NAME_PROP, branchName);
-    return options;
-  }
-
-
-  @Nullable
-  public PersonalBranchDescription getPersonalBranchDescription(@NotNull VcsRoot root, @NotNull String branchName) throws VcsException {
-    HgVcsRoot hgRoot = myHgVcsRootFactory.createHgRoot(root);
-    VcsRoot branchRoot = createBranchRoot(root, branchName);
-    String baseVersion = getCurrentVersion(root);
-    String branchVersion = getCurrentVersion(branchRoot);
-    String mergeBase = getMergeBase(hgRoot, baseVersion, branchVersion);
-
-    if (mergeBase == null)
-      return null;
-
-    List<ChangeSet> changeSets = createRepo(hgRoot).log()
-            .fromRevision(mergeBase)
-            .toRevision(branchVersion)
-            .showCommitsFromAllBranches()
-            .call();
-    if (changeSets.size() > 1) {//when branch points to the commit in original branch we get 1 cset
-      String branchId = changeSets.get(1).getId();
-      String username = changeSets.get(changeSets.size() - 1).getUser();
-      return new PersonalBranchDescription(branchId, username);
-    } else {
-      return null;
-    }
-  }
-
-
-  private VcsRoot createBranchRoot(VcsRoot original, String branchName) {
-    VcsRootImpl result = new VcsRootImpl(original.getId(), original.getProperties());
-    result.addProperty(Constants.BRANCH_NAME_PROP, branchName);
-    return result;
-  }
-
-  @NotNull
   public List<ModificationData> collectChanges(@NotNull VcsRoot fromRoot,
-                                               @NotNull RepositoryState fromState,
+                                               @NotNull RepositoryStateData fromState,
                                                @NotNull VcsRoot toRoot,
-                                               @NotNull RepositoryState toState,
+                                               @NotNull RepositoryStateData toState,
                                                @NotNull CheckoutRules rules) throws VcsException {
     return collectChanges(toRoot, fromState, toState, rules);
   }
 
   @NotNull
   public List<ModificationData> collectChanges(@NotNull VcsRoot root,
-                                               @NotNull RepositoryState fromState,
-                                               @NotNull RepositoryState toState,
+                                               @NotNull RepositoryStateData fromState,
+                                               @NotNull RepositoryStateData toState,
                                                @NotNull CheckoutRules rules) throws VcsException {
     Set<String> reportedCsetIds = new HashSet<String>();
     List<ModificationData> changes = new ArrayList<ModificationData>();
@@ -560,7 +486,7 @@
 
 
   @Nullable
-  private String getMergeBase(@NotNull HgVcsRoot root, @NotNull String revision1, @NotNull String revision2) throws VcsException {
+  public String getMergeBase(@NotNull HgVcsRoot root, @NotNull String revision1, @NotNull String revision2) throws VcsException {
     String result = createRepo(root).mergeBase()
             .revision1(revision1)
             .revision2(revision2)
@@ -633,7 +559,8 @@
     String fromCommit = new ChangeSetRevision(fromVersion).getId();
     String toCommit = new ChangeSetRevision(toVersion).getId();
     try {
-      List<ChangeSet> changesets = createRepo(root).collectChanges(root)
+      ServerHgRepo repo = createRepo(root);
+      List<ChangeSet> changesets = repo.collectChanges(root)
               .fromRevision(fromCommit)
               .toRevision(toCommit)
               .call();
@@ -643,6 +570,8 @@
         if (cset.getId().equals(fromCommit))
           iter.remove();//skip already reported changes
       }
+      if (myConfig.detectSubrepoChanges())
+        changesets.addAll(getSubrepoChangesets(root, repo, changesets));
       return changesets;
     } catch (UnknownRevisionException e) {
       Loggers.VCS.warn("Revision '" + e.getRevision() + "' is unknown, will return no changes");
@@ -650,6 +579,26 @@
     }
   }
 
+  @NotNull
+  private List<ChangeSet> getSubrepoChangesets(@NotNull HgVcsRoot root,
+                                               @NotNull HgRepo repo,
+                                               @NotNull List<ChangeSet> csets) throws VcsException {
+    List<ChangeSet> subrepoCsets = new ArrayList<ChangeSet>();
+    for (ChangeSet cset : csets) {
+      List<SubRepoConfigChange> subrepoConfigChanges = repo.getSubrepoConfigChanges(cset);
+      for (SubRepoConfigChange c : subrepoConfigChanges) {
+        if (c.getCurrent() != null && c.getPrevious() != null && c.getCurrent().url().equals(c.getPrevious().url())) {
+          String subrepoUrl = c.getCurrent().isRelative() ? root.getRepository() + "/" + c.getCurrent().url() : c.getCurrent().url();
+          String fromRevision = c.getPrevious().revision();
+          String toRevision = c.getCurrent().revision();
+          HgVcsRoot subrepoRoot = root.withUrl(subrepoUrl);
+          syncRepository(subrepoRoot);
+          subrepoCsets.addAll(getChangesets(subrepoRoot, fromRevision, toRevision));
+        }
+      }
+    }
+    return subrepoCsets;
+  }
 
   @NotNull
   public BuildPatchPolicy getBuildPatchPolicy() {
@@ -770,7 +719,7 @@
     }
   }
 
-  ServerHgRepo createRepo(@NotNull HgVcsRoot root) throws VcsException {
+  public ServerHgRepo createRepo(@NotNull HgVcsRoot root) throws VcsException {
     return myRepoFactory.create(getWorkingDir(root), myHgPathProvider.getHgPath(root), root.getAuthSettings());
   }
 
@@ -802,4 +751,14 @@
   public ListFilesPolicy getListFilesPolicy() {
     return new ListFilesSupport(this, myHgVcsRootFactory);
   }
+
+
+  @Nullable
+  public <T extends VcsExtension> T getVcsExtension(@NotNull Class<T> klass) {
+    for (MercurialServerExtension e : myExtensions) {
+      if (klass.isInstance(e))
+        return klass.cast(e);
+    }
+    return null;
+  }
 }
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfig.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfig.java	Fri Nov 30 17:25:41 2012 +0400
@@ -21,4 +21,6 @@
 
   @NotNull
   Set<Long> getRevsetParentRootIds();
+
+  public boolean detectSubrepoChanges();
 }
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfigImpl.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfigImpl.java	Fri Nov 30 17:25:41 2012 +0400
@@ -1,6 +1,7 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
 import com.intellij.openapi.diagnostic.Logger;
+import jetbrains.buildServer.serverSide.CachePaths;
 import jetbrains.buildServer.serverSide.ServerPaths;
 import jetbrains.buildServer.serverSide.TeamCityProperties;
 import org.jetbrains.annotations.NotNull;
@@ -24,8 +25,8 @@
 
   private final File myCachesDir;
 
-  public ServerPluginConfigImpl(@NotNull final ServerPaths paths) {
-    myCachesDir = new File(paths.getCachesDir(), "mercurial");
+  public ServerPluginConfigImpl(@NotNull final CachePaths paths) {
+    myCachesDir = paths.getCacheDirectory("mercurial");
   }
 
   public boolean isUsePullProtocol() {
@@ -67,4 +68,8 @@
     }
     return ids;
   }
+
+  public boolean detectSubrepoChanges() {
+    return false;
+  }
 }
--- a/mercurial-tests/mercurial-tests.iml	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/mercurial-tests.iml	Fri Nov 30 17:25:41 2012 +0400
@@ -18,6 +18,8 @@
     <orderEntry type="library" name="TeamCity-TestsAPI" level="project" />
     <orderEntry type="library" name="TeamCity-impl" level="project" />
     <orderEntry type="library" name="TeamCityAPI-agent" level="project" />
+    <orderEntry type="library" name="TeamCity Vcs Api" level="project" />
+    <orderEntry type="module" module-name="mercurial-server-tc" />
   </component>
 </module>
 
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -3,7 +3,6 @@
 import com.intellij.openapi.diagnostic.Logger;
 import jetbrains.buildServer.TempFiles;
 import jetbrains.buildServer.agent.*;
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettings;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.log.Log4jFactory;
 import jetbrains.buildServer.vcs.*;
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -18,7 +18,6 @@
 import jetbrains.buildServer.agent.AgentRunningBuild;
 import jetbrains.buildServer.agent.BuildAgentConfiguration;
 import jetbrains.buildServer.agent.BuildProgressLogger;
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettings;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.util.TestFor;
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -7,7 +7,6 @@
 import jetbrains.buildServer.agent.BuildProgressLogger;
 import jetbrains.buildServer.agent.vcs.UpdateByIncludeRules2;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings;
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettings;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.ConnectionRefusedException;
 import jetbrains.buildServer.log.Log4jFactory;
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/DagFeaturesTest.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/DagFeaturesTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -7,13 +7,13 @@
 import jetbrains.buildServer.vcs.CheckoutRules;
 import jetbrains.buildServer.vcs.ModificationData;
 import jetbrains.buildServer.vcs.impl.VcsRootImpl;
-import org.jmock.Mockery;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import java.io.File;
 import java.util.List;
 
+import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
@@ -37,7 +37,7 @@
     ServerPluginConfig config = new ServerPluginConfigBuilder()
             .cachesDir(myTempFiles.createTempDir())
             .build();
-    myHg = Util.createMercurialServerSupport(new Mockery(), config);
+    myHg = mercurialSupport().withConfig(config).build();
 
     File original = new File("mercurial-tests/testData/rep2");
     File copy = new File(myTempFiles.createTempDir(), "rep2");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepoTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,65 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import com.intellij.openapi.diagnostic.Logger;
+import jetbrains.buildServer.TempFiles;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
+import jetbrains.buildServer.log.Log4jFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertTrue;
+
+@Test
+public class HgRepoTest {
+
+  static {
+    Logger.setFactory(new Log4jFactory());
+  }
+
+  private TempFiles myTempFiles;
+
+  @BeforeMethod
+  public void setUp() throws IOException {
+    myTempFiles = new TempFiles();
+  }
+
+  @AfterMethod
+  public void tearDown() {
+    myTempFiles.cleanup();
+  }
+
+  public void subrepos() throws Exception {
+    File repository = myTempFiles.createTempDir();
+    copyRepository(new File("mercurial-tests/testData/subrepos/r1"), repository);
+    HgRepo repo = new HgRepo(new TestCommandSettingsFactory(), repository, Util.getHgPath(), new AuthSettings());
+    List<SubRepoConfigChange> changes = repo.getSubrepoConfigChanges("09c256b6163e");
+    assertEquals(1, changes.size());
+    SubRepoConfigChange c = changes.get(0);
+    assertEquals("r2", c.getPath());
+    //noinspection ConstantConditions
+    assertTrue(c.getPrevious().revision().startsWith("9e4a2fef1a1c"));
+    //noinspection ConstantConditions
+    assertTrue(c.getCurrent().revision().startsWith("ebb884b1b691"));
+
+    changes = repo.getSubrepoConfigChanges("4d7b3db8779f");
+    assertEquals(1, changes.size());
+    c = changes.get(0);
+    assertEquals("r2", c.getPath());
+    //noinspection ConstantConditions
+    assertTrue(c.getPrevious().revision().startsWith("916933c1dd8e"));
+    assertNull(c.getCurrent());
+
+    changes = repo.getSubrepoConfigChanges("d350e7209906");
+    assertEquals(1, changes.size());
+  }
+
+}
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ListFilesSupportTest.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ListFilesSupportTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -9,7 +9,6 @@
 import jetbrains.buildServer.vcs.VcsFileData;
 import jetbrains.buildServer.vcs.VcsRoot;
 import org.jetbrains.annotations.NotNull;
-import org.jmock.Mockery;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -17,6 +16,7 @@
 import java.io.IOException;
 import java.util.Collection;
 
+import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot;
 import static org.testng.AssertJUnit.assertFalse;
@@ -40,11 +40,10 @@
   @BeforeMethod
   protected void setUp() throws Exception {
     TempFiles tempFiles = new TempFiles();
-    Mockery context = new Mockery();
     ServerPluginConfig myPluginConfig = new ServerPluginConfigBuilder()
             .cachesDir(tempFiles.createTempDir())
             .build();
-    myVcs = Util.createMercurialServerSupport(context, myPluginConfig);
+    myVcs = mercurialSupport().withConfig(myPluginConfig).build();
 
     myRemoteRepoDir = tempFiles.createTempDir();
     copyRepository(new File("mercurial-tests/testData/rep1"), myRemoteRepoDir);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialSupportBuilder.java	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,68 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsFactory;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
+import jetbrains.buildServer.serverSide.BuildServerListener;
+import jetbrains.buildServer.serverSide.SBuildServer;
+import jetbrains.buildServer.serverSide.ServerListener;
+import jetbrains.buildServer.util.EventDispatcher;
+import jetbrains.buildServer.util.cache.ResetCacheHandler;
+import jetbrains.buildServer.util.cache.ResetCacheRegister;
+import jetbrains.buildServer.vcs.VcsManager;
+import org.jetbrains.annotations.NotNull;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+public class MercurialSupportBuilder {
+
+  private Mockery myContext;
+  private ServerPluginConfig myConfig;
+  private List<MercurialServerExtension> myExtensions = new ArrayList<MercurialServerExtension>();
+  private HgVcsRootFactory myHgRootFactory;
+  private CommandSettingsFactory myCommandSettingsFactory = new TestCommandSettingsFactory();
+
+  public static MercurialSupportBuilder mercurialSupport() {
+    return new MercurialSupportBuilder();
+  }
+
+  @NotNull
+  public MercurialVcsSupport build() throws IOException {
+    if (myContext == null)
+      myContext = new Mockery();
+    EventDispatcher<ServerListener> dispatcher = EventDispatcher.create(ServerListener.class);
+    myHgRootFactory = new HgVcsRootFactory(myConfig);
+    MirrorManagerImpl mirrorManager = new MirrorManagerImpl(myConfig);
+    ServerHgPathProvider hgPathProvider = new ServerHgPathProvider(myConfig);
+    RepoFactory repoFactory = new RepoFactory(myConfig, myCommandSettingsFactory);
+    HgTestConnectionSupport testConnection = new HgTestConnectionSupport(myHgRootFactory, repoFactory, mirrorManager, hgPathProvider);
+    final ResetCacheRegister resetCacheManager = myContext.mock(ResetCacheRegister.class);
+    myContext.checking(new Expectations() {{
+      allowing(resetCacheManager).registerHandler(with(any(ResetCacheHandler.class)));
+    }});
+    MercurialVcsSupport vcs = new MercurialVcsSupport(dispatcher, resetCacheManager, myConfig, hgPathProvider,
+            repoFactory, mirrorManager, myHgRootFactory, testConnection);
+    vcs.setExtensions(myExtensions);
+    return vcs;
+  }
+
+
+  public MercurialSupportBuilder withConfig(@NotNull ServerPluginConfig config) {
+    myConfig = config;
+    return this;
+  }
+
+  public MercurialSupportBuilder withExtension(@NotNull MercurialServerExtension extension) {
+    myExtensions.add(extension);
+    return this;
+  }
+
+  public HgVcsRootFactory getHgRootFactory() {
+    return myHgRootFactory;
+  }
+}
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -15,7 +15,6 @@
  */
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
-import com.intellij.execution.configurations.GeneralCommandLine;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.*;
 import jetbrains.buildServer.util.TestFor;
 import jetbrains.buildServer.vcs.*;
@@ -24,7 +23,6 @@
 import org.hamcrest.Description;
 import org.hamcrest.TypeSafeMatcher;
 import org.jetbrains.annotations.NotNull;
-import org.jmock.Mockery;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -35,11 +33,11 @@
 import java.util.*;
 
 import static com.intellij.openapi.util.io.FileUtil.*;
+import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.buildPatch;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot;
 import static jetbrains.buildServer.util.Util.map;
-import static jetbrains.buildServer.vcs.RepositoryStateFactory.createRepositoryState;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.hasItem;
 
@@ -53,11 +51,10 @@
   @BeforeMethod
   protected void setUp() throws Exception {
     super.setUp();
-    Mockery context = new Mockery();
     myPluginConfig = new ServerPluginConfigBuilder()
             .cachesDir(myTempFiles.createTempDir())
             .build();
-    myVcs = Util.createMercurialServerSupport(context, myPluginConfig);
+    myVcs = mercurialSupport().withConfig(myPluginConfig).build();
   }
 
   protected String getTestDataPath() {
@@ -532,8 +529,13 @@
 
 
   public void test_getPersonalBranchDescription_when_branch_contains_commits() throws Exception {
+    MercurialBranchSupport branchSupport = new MercurialBranchSupport();
+    MercurialSupportBuilder vcsBuilder = new MercurialSupportBuilder();
+    MercurialVcsSupport vcs = vcsBuilder.withConfig(myPluginConfig).withExtension(branchSupport).build();
+    branchSupport.setMercurialSupport(vcs);
+    branchSupport.setHgRootFactory(vcsBuilder.getHgRootFactory());
     VcsRootImpl originalRoot = createVcsRoot(simpleRepo());
-    PersonalBranchDescription description = myVcs.getPersonalBranchDescription(originalRoot, "name with space");
+    PersonalBranchDescription description = vcs.getVcsExtension(BranchSupport.class).getPersonalBranchDescription(originalRoot, "name with space");
     assertNotNull(description);
     assertEquals(description.getBranchId(), "376dcf05cd2a");
     assertEquals(description.getUsername(), "Pavel.Sher");
@@ -541,8 +543,13 @@
 
 
   public void test_getPersonalBranchDescription_when_branch_doesnot_contain_commits() throws Exception {
+    MercurialBranchSupport branchSupport = new MercurialBranchSupport();
+    MercurialSupportBuilder vcsBuilder = new MercurialSupportBuilder();
+    MercurialVcsSupport vcs = vcsBuilder.withConfig(myPluginConfig).withExtension(branchSupport).build();
+    branchSupport.setMercurialSupport(vcs);
+    branchSupport.setHgRootFactory(vcsBuilder.getHgRootFactory());
     VcsRootImpl originalRoot = createVcsRoot(simpleRepo());
-    PersonalBranchDescription description = myVcs.getPersonalBranchDescription(originalRoot, "default");
+    PersonalBranchDescription description = vcs.getVcsExtension(BranchSupport.class).getPersonalBranchDescription(originalRoot, "default");
     assertNull(description);
   }
 
@@ -579,12 +586,11 @@
     assertEquals(russianLocaleVersion, defaultLocaleVersion);
   }
 
-
   public void collect_changes_between_states() throws Exception {
     VcsRootImpl root = createVcsRoot(myRep2Path);
     List<ModificationData> changes = myVcs.collectChanges(root,
-            createRepositoryState(map("default", "1e620196c4b6"), "default"),
-            createRepositoryState(map("default", "505c5b9d01e6", "personal-branch", "96b78d73081d"), "default"),
+            RepositoryStateData.createVersionState("default", map("default", "1e620196c4b6")),
+            RepositoryStateData.createVersionState("default", map("default", "505c5b9d01e6", "personal-branch", "96b78d73081d")),
             CheckoutRules.DEFAULT);
     assertEquals(changes.size(), 4);
     assertThat(changes, hasItem(withVersion("dec47d2d49bf")));
@@ -597,8 +603,8 @@
   public void collect_changes_between_states_does_not_report_duplicate_changes() throws Exception {
     VcsRootImpl root = createVcsRoot(myRep2Path);
     List<ModificationData> changes = myVcs.collectChanges(root,
-            createRepositoryState(map("default", "8c44244d6645"), "default"),
-            createRepositoryState(map("default", "505c5b9d01e6", "personal-branch", "9ec402c74298"), "default"),
+            RepositoryStateData.createVersionState("default", map("default", "8c44244d6645")),
+            RepositoryStateData.createVersionState("default", map("default", "505c5b9d01e6", "personal-branch", "9ec402c74298")),
             CheckoutRules.DEFAULT);
     assertEquals(changes.size(), 8);
     assertThat(changes, hasItem(withVersion("9ec402c74298")));
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -8,7 +8,6 @@
 import jetbrains.buildServer.vcs.*;
 import jetbrains.buildServer.vcs.patches.PatchTestCase;
 import org.jetbrains.annotations.NotNull;
-import org.jmock.Mockery;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -19,6 +18,7 @@
 import java.util.List;
 import java.util.Map;
 
+import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.buildPatch;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository;
 import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot;
@@ -38,11 +38,10 @@
   @BeforeMethod
   public void setUp() throws Exception {
     myTempFiles = new TempFiles();
-    Mockery context = new Mockery();
-    ServerPluginConfig myPluginConfig = new ServerPluginConfigBuilder()
+    ServerPluginConfig pluginConfig = new ServerPluginConfigBuilder()
             .cachesDir(myTempFiles.createTempDir())
             .build();
-    myVcs = Util.createMercurialServerSupport(context, myPluginConfig);
+    myVcs = mercurialSupport().withConfig(pluginConfig).build();
 
     myRemoteRepoDir = copyRepository(myTempFiles, new File("mercurial-tests/testData/rep1").getAbsolutePath());
     myRoot = vcsRoot().withUrl(myRemoteRepoDir.getAbsolutePath()).build();
@@ -108,7 +107,7 @@
 
 
   public void should_not_include_revnum_in_current_state() throws VcsException {
-    RepositoryState state = myVcs.getCurrentState(myRoot);
+    RepositoryStateData state = myVcs.getCurrentState(myRoot);
     for (Map.Entry<String, String> entry : state.getBranchRevisions().entrySet()) {
       String branchName = entry.getKey();
       String revision = entry.getKey();
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProviderTest.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerHgPathProviderTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -46,7 +46,7 @@
 
 
   private HgVcsRoot createHgRoot() throws Exception {
-    return new HgVcsRoot(new VcsRootBuilder().withHgPath(myVcsRootHgPath).build());
+    return new HgVcsRoot(new VcsRootBuilder().withUrl("some url").withHgPath(myVcsRootHgPath).build());
   }
 
 }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfigBuilder.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/ServerPluginConfigBuilder.java	Fri Nov 30 17:25:41 2012 +0400
@@ -15,6 +15,7 @@
   private String myHgPath;
   private File myCachesDir;
   private boolean myDontUseRevsets = false;
+  private boolean myDetectSubrepoChanges = false;
 
   @NotNull
   public ServerPluginConfig build() {
@@ -47,6 +48,10 @@
       public Set<Long> getRevsetParentRootIds() {
         return new HashSet<Long>();
       }
+
+      public boolean detectSubrepoChanges() {
+        return myDetectSubrepoChanges;
+      }
     };
   }
 
@@ -70,4 +75,9 @@
     myDontUseRevsets = true;
     return this;
   }
+
+  public ServerPluginConfigBuilder detectSubrepoChanges(boolean doDetect) {
+    myDetectSubrepoChanges = doDetect;
+    return this;
+  }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubrepoChangesTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -0,0 +1,97 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial;
+
+import com.intellij.openapi.diagnostic.Logger;
+import jetbrains.buildServer.TempFiles;
+import jetbrains.buildServer.log.Log4jFactory;
+import jetbrains.buildServer.vcs.CheckoutRules;
+import jetbrains.buildServer.vcs.ModificationData;
+import jetbrains.buildServer.vcs.VcsRoot;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport;
+import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository;
+import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot;
+import static org.testng.AssertJUnit.assertEquals;
+
+@Test
+public class SubrepoChangesTest {
+
+  static {
+    Logger.setFactory(new Log4jFactory());
+  }
+
+  private TempFiles myTempFiles;
+  private MercurialVcsSupport myVcs;
+  private File myRemoteRepo1;
+  private File myRemoteRepo2;
+  private File myRemoteRepo3;
+
+  @BeforeMethod
+  public void setUp() throws IOException {
+    myTempFiles = new TempFiles();
+    ServerPluginConfig pluginConfig = new ServerPluginConfigBuilder()
+            .cachesDir(myTempFiles.createTempDir())
+            .detectSubrepoChanges(true)
+            .build();
+    File remoteRepoParentDir = myTempFiles.createTempDir();
+    myRemoteRepo1 = new File(remoteRepoParentDir, "r1");
+    myRemoteRepo2 = new File(remoteRepoParentDir, "r2");
+    myRemoteRepo3 = new File(remoteRepoParentDir, "r3");
+    copyRepository(new File("mercurial-tests/testData/subrepos/r1"), myRemoteRepo1);
+    copyRepository(new File("mercurial-tests/testData/subrepos/r2"), myRemoteRepo2);
+    copyRepository(new File("mercurial-tests/testData/subrepos/r3"), myRemoteRepo3);
+    myVcs = mercurialSupport().withConfig(pluginConfig).build();
+  }
+
+  @AfterMethod
+  public void tearDown() {
+    myTempFiles.cleanup();
+  }
+
+
+  public void should_report_changes_from_subrepos() throws Exception {
+    VcsRoot root = vcsRoot().withUrl(myRemoteRepo1.getAbsolutePath()).build();
+    List<ModificationData> changes = myVcs.collectChanges(root, "d350e7209906", "09c256b6163e", CheckoutRules.DEFAULT);
+    assertEquals(3, changes.size());
+  }
+
+
+  public void should_not_report_any_changes_when_subrepo_removed() throws Exception {
+    VcsRoot root = vcsRoot().withUrl(myRemoteRepo1.getAbsolutePath()).build();
+    List<ModificationData> changes = myVcs.collectChanges(root, "34017377d9c3", "4d7b3db8779f", CheckoutRules.DEFAULT);
+    assertEquals(1, changes.size());
+  }
+
+
+  public void should_not_report_any_changes_when_subrepo_added() throws Exception {
+    VcsRoot root = vcsRoot().withUrl(myRemoteRepo1.getAbsolutePath()).build();
+    List<ModificationData> changes = myVcs.collectChanges(root, "4d7b3db8779f", "d350e7209906", CheckoutRules.DEFAULT);
+    assertEquals(1, changes.size());
+  }
+
+
+  public void should_report_subrepo_changes_recursevly() throws Exception {
+    VcsRoot root = vcsRoot().withUrl(myRemoteRepo1.getAbsolutePath()).build();
+    List<ModificationData> changes = myVcs.collectChanges(root, "09c256b6163e", "d64d9799c143", CheckoutRules.DEFAULT);
+    assertEquals(5, changes.size());
+  }
+
+
+  public void report_subrepo_changes_without_revsets() throws Exception {
+    ServerPluginConfig pluginConfig = new ServerPluginConfigBuilder()
+            .cachesDir(myTempFiles.createTempDir())
+            .detectSubrepoChanges(true)
+            .dontUseRevsets()
+            .build();
+    myVcs = mercurialSupport().withConfig(pluginConfig).build();
+    VcsRoot root = vcsRoot().withUrl(myRemoteRepo1.getAbsolutePath()).build();
+    List<ModificationData> changes = myVcs.collectChanges(root, "d350e7209906", "09c256b6163e", CheckoutRules.DEFAULT);
+    assertEquals(3, changes.size());
+  }
+}
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/UnrelatedResitoriesTest.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/UnrelatedResitoriesTest.java	Fri Nov 30 17:25:41 2012 +0400
@@ -8,7 +8,6 @@
 import jetbrains.buildServer.vcs.VcsException;
 import jetbrains.buildServer.vcs.impl.VcsRootImpl;
 import org.jetbrains.annotations.NotNull;
-import org.jmock.Mockery;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -16,6 +15,7 @@
 import java.io.File;
 import java.io.IOException;
 
+import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertTrue;
 
@@ -30,7 +30,6 @@
   private TempFiles myTempFiles;
   private File myRepositoryLocation;
   private VcsRootImpl myRoot;
-  private Mockery myContext;
   private ServerPluginConfig myPluginConfig;
 
   static {
@@ -39,7 +38,6 @@
 
   @BeforeMethod
   public void setUp() throws Exception {
-    myContext = new Mockery();
     myTempFiles = new TempFiles();
     myPluginConfig = new ServerPluginConfigBuilder()
             .cachesDir(myTempFiles.createTempDir())
@@ -88,6 +86,6 @@
   }
 
   private MercurialVcsSupport createVcs() throws IOException {
-    return Util.createMercurialServerSupport(myContext, myPluginConfig);
+    return mercurialSupport().withConfig(myPluginConfig).build();
   }
 }
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java	Fri Nov 30 17:25:41 2012 +0400
@@ -1,28 +1,17 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
 import jetbrains.buildServer.TempFiles;
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettings;
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
-import jetbrains.buildServer.serverSide.BuildServerListener;
-import jetbrains.buildServer.serverSide.SBuildServer;
-import jetbrains.buildServer.util.EventDispatcher;
 import jetbrains.buildServer.util.FileUtil;
-import jetbrains.buildServer.util.cache.ResetCacheRegister;
 import jetbrains.buildServer.vcs.CheckoutRules;
 import jetbrains.buildServer.vcs.VcsException;
-import jetbrains.buildServer.vcs.VcsManager;
 import jetbrains.buildServer.vcs.VcsRoot;
 import jetbrains.buildServer.vcs.patches.PatchBuilderImpl;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jmock.Expectations;
-import org.jmock.Mockery;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
 
 /**
  * @author dmitry.neverov
@@ -41,28 +30,6 @@
   }
 
 
-  public static MercurialVcsSupport createMercurialServerSupport(@NotNull Mockery context, ServerPluginConfig config) throws IOException {
-    return createMercurialServerSupport(context, config, new RepoFactory(config, new TestCommandSettingsFactory()));
-  }
-
-
-  public static MercurialVcsSupport createMercurialServerSupport(@NotNull Mockery context, @NotNull ServerPluginConfig config, @NotNull RepoFactory repoFactory) throws IOException {
-    VcsManager vcsManager = context.mock(VcsManager.class);
-    final SBuildServer server = context.mock(SBuildServer.class);
-    final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
-    context.checking(new Expectations() {{
-      allowing(server).getExecutor(); will(returnValue(executor));
-    }});
-    EventDispatcher<BuildServerListener> dispatcher = EventDispatcher.create(BuildServerListener.class);
-    HgVcsRootFactory hgVcsRootFactory = new HgVcsRootFactory(config);
-    MirrorManagerImpl mirrorManager = new MirrorManagerImpl(config);
-    ServerHgPathProvider hgPathProvider = new ServerHgPathProvider(config);
-    HgTestConnectionSupport testConnection = new HgTestConnectionSupport(hgVcsRootFactory, repoFactory, mirrorManager, hgPathProvider);
-    return new MercurialVcsSupport(vcsManager, server, dispatcher, new ResetCacheRegister(), config, hgPathProvider,
-            repoFactory, mirrorManager, hgVcsRootFactory, testConnection);
-  }
-
-
   public static File copyRepository(@NotNull TempFiles tempFiles, @NotNull String repPath) throws IOException {
     File tempDir = tempFiles.createTempDir();
     copyRepository(new File(repPath), tempDir);
--- a/mercurial-tests/src/testng.xml	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/src/testng.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -26,6 +26,8 @@
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.ListFilesSupportTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.RevisionFormatTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.HgFileUtilTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.SubrepoChangesTest"/>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.HgRepoTest"/>
     </classes>
   </test>
 </suite>
--- a/mercurial-tests/testData/subrepos/README	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/testData/subrepos/README	Fri Nov 30 17:25:41 2012 +0400
@@ -1,13 +1,21 @@
 r1 history:
+5:d64d9799c143 Recursive subrepos                           <- subrepository r2 = ../r3 (514c3e09cddf)
+4:09c256b6163e Subrepo update                               <- subrepository r2 = ../r3 (ebb884b1b691)
 3:d350e7209906 Add different subrepository in the same path <- subrepository r2 = ../r3 (9e4a2fef1a1c)
 2:4d7b3db8779f Remove subrepository                         <- subrepository removed
 1:34017377d9c3 Add subrepository                            <- subrepository r2 = ../r2 (916933c1dd8e)
 0:e4eced2b7381 Initial commit
 
 r2 history:
+2:ac0003deae69 three
+1:29053b4b29ce two
 0:916933c1dd8e Initial commit
 
 r3 history:
+4:514c3e09cddf Upgrade subrepo                              <- subrepository r2 = ../r2 (ac0003deae69)
+3:1f9eb39a3921 Add subrepo                                  <- subrepository r2 = ../r2 (916933c1dd8e)
+2:ebb884b1b691 two
+1:f41168ce47b7 one
 0:9e4a2fef1a1c Initial commit
 
 
Binary file mercurial-tests/testData/subrepos/r1/hg/dirstate has changed
Binary file mercurial-tests/testData/subrepos/r1/hg/store/00changelog.i has changed
Binary file mercurial-tests/testData/subrepos/r1/hg/store/00manifest.i has changed
Binary file mercurial-tests/testData/subrepos/r1/hg/store/data/.hgsubstate.i has changed
Binary file mercurial-tests/testData/subrepos/r1/hg/store/undo has changed
--- a/mercurial-tests/testData/subrepos/r1/hg/undo.desc	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/testData/subrepos/r1/hg/undo.desc	Fri Nov 30 17:25:41 2012 +0400
@@ -1,2 +1,2 @@
-3
+4
 commit
Binary file mercurial-tests/testData/subrepos/r1/hg/undo.dirstate has changed
Binary file mercurial-tests/testData/subrepos/r2/hg/dirstate has changed
Binary file mercurial-tests/testData/subrepos/r2/hg/store/00changelog.i has changed
Binary file mercurial-tests/testData/subrepos/r2/hg/store/00manifest.i has changed
Binary file mercurial-tests/testData/subrepos/r2/hg/store/data/b.i has changed
Binary file mercurial-tests/testData/subrepos/r2/hg/store/undo has changed
Binary file mercurial-tests/testData/subrepos/r3/hg/dirstate has changed
Binary file mercurial-tests/testData/subrepos/r3/hg/store/00changelog.i has changed
Binary file mercurial-tests/testData/subrepos/r3/hg/store/00manifest.i has changed
Binary file mercurial-tests/testData/subrepos/r3/hg/store/data/.hgsub.i has changed
Binary file mercurial-tests/testData/subrepos/r3/hg/store/data/.hgsubstate.i has changed
Binary file mercurial-tests/testData/subrepos/r3/hg/store/data/c.i has changed
--- a/mercurial-tests/testData/subrepos/r3/hg/store/fncache	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial-tests/testData/subrepos/r3/hg/store/fncache	Fri Nov 30 17:25:41 2012 +0400
@@ -1,1 +1,3 @@
+data/.hgsubstate.i
+data/.hgsub.i
 data/c.i
Binary file mercurial-tests/testData/subrepos/r3/hg/store/undo has changed
Binary file mercurial-tests/testData/subrepos/r3/hg/undo.dirstate has changed
--- a/mercurial.ipr	Fri Nov 30 17:24:32 2012 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,490 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="AntConfiguration">
-    <defaultAnt bundledAnt="true" />
-    <buildFile url="file://$PROJECT_DIR$/build.xml">
-      <additionalClassPath />
-      <antReference projectDefault="true" />
-      <customJdkName value="" />
-      <maximumHeapSize value="128" />
-      <maximumStackSize value="32" />
-      <properties />
-    </buildFile>
-  </component>
-  <component name="BuildJarProjectSettings">
-    <option name="BUILD_JARS_ON_MAKE" value="false" />
-  </component>
-  <component name="ChangeBrowserSettings">
-    <option name="MAIN_SPLITTER_PROPORTION" value="0.3" />
-    <option name="MESSAGES_SPLITTER_PROPORTION" value="0.8" />
-    <option name="USE_DATE_BEFORE_FILTER" value="false" />
-    <option name="USE_DATE_AFTER_FILTER" value="false" />
-    <option name="USE_CHANGE_BEFORE_FILTER" value="false" />
-    <option name="USE_CHANGE_AFTER_FILTER" value="false" />
-    <option name="DATE_BEFORE" value="" />
-    <option name="DATE_AFTER" value="" />
-    <option name="CHANGE_BEFORE" value="" />
-    <option name="CHANGE_AFTER" value="" />
-    <option name="USE_USER_FILTER" value="false" />
-    <option name="USER" value="" />
-  </component>
-  <component name="ClearCaseSharedConfig">
-    <option name="myUseUcmModel" value="true" />
-  </component>
-  <component name="CodeStyleProjectProfileManger">
-    <option name="PROJECT_PROFILE" />
-    <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
-  </component>
-  <component name="CompilerConfiguration">
-    <option name="DEFAULT_COMPILER" value="Javac" />
-    <resourceExtensions>
-      <entry name=".+\.(properties|xml|html|dtd|tld)" />
-      <entry name=".+\.(gif|png|jpeg|jpg)" />
-    </resourceExtensions>
-    <wildcardResourcePatterns>
-      <entry name="?*.properties" />
-      <entry name="?*.xml" />
-      <entry name="?*.gif" />
-      <entry name="?*.png" />
-      <entry name="?*.jpeg" />
-      <entry name="?*.jpg" />
-      <entry name="?*.html" />
-      <entry name="?*.dtd" />
-      <entry name="?*.tld" />
-      <entry name="?*.jsp" />
-      <entry name="?*.tag" />
-      <entry name="?*.template" />
-    </wildcardResourcePatterns>
-    <annotationProcessing>
-      <profile default="true" name="Default" enabled="false">
-        <processorPath useClasspath="true" />
-      </profile>
-    </annotationProcessing>
-  </component>
-  <component name="CopyrightManager" default="">
-    <module2copyright />
-  </component>
-  <component name="DependenciesAnalyzeManager">
-    <option name="myForwardDirection" value="false" />
-  </component>
-  <component name="DependencyValidationManager">
-    <option name="SKIP_IMPORT_STATEMENTS" value="false" />
-  </component>
-  <component name="EclipseCompilerSettings">
-    <option name="GENERATE_NO_WARNINGS" value="true" />
-    <option name="DEPRECATION" value="false" />
-  </component>
-  <component name="EclipseEmbeddedCompilerSettings">
-    <option name="DEBUGGING_INFO" value="true" />
-    <option name="GENERATE_NO_WARNINGS" value="true" />
-    <option name="DEPRECATION" value="false" />
-    <option name="ADDITIONAL_OPTIONS_STRING" value="" />
-    <option name="MAXIMUM_HEAP_SIZE" value="128" />
-  </component>
-  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
-  <component name="EntryPointsManager">
-    <entry_points version="2.0" />
-  </component>
-  <component name="ErrorOptionsConfigurable.UI">
-    <option name="proportions">
-      <SplitterProportionsDataImpl />
-    </option>
-  </component>
-  <component name="ExportToHTMLSettings">
-    <option name="PRINT_LINE_NUMBERS" value="false" />
-    <option name="OPEN_IN_BROWSER" value="false" />
-    <option name="OUTPUT_DIRECTORY" />
-  </component>
-  <component name="GlobalLibrariesConfigurable.UI">
-    <option name="proportions">
-      <SplitterProportionsDataImpl />
-    </option>
-  </component>
-  <component name="IdProvider" IDEtalkID="317BB29ECB7DA19EFFA340ECF52563C6" />
-  <component name="InspectionProjectProfileManager">
-    <profiles>
-      <profile version="1.0" is_locked="false">
-        <option name="myName" value="Project Default" />
-        <option name="myLocal" value="false" />
-        <inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
-          <option name="processCode" value="true" />
-          <option name="processLiterals" value="true" />
-          <option name="processComments" value="true" />
-        </inspection_tool>
-      </profile>
-    </profiles>
-    <option name="PROJECT_PROFILE" value="Project Default" />
-    <option name="USE_PROJECT_PROFILE" value="true" />
-    <version value="1.0" />
-    <list size="6">
-      <item index="0" class="java.lang.String" itemvalue="TYPO" />
-      <item index="1" class="java.lang.String" itemvalue="WEAK WARNING" />
-      <item index="2" class="java.lang.String" itemvalue="INFO" />
-      <item index="3" class="java.lang.String" itemvalue="WARNING" />
-      <item index="4" class="java.lang.String" itemvalue="ERROR" />
-      <item index="5" class="java.lang.String" itemvalue="SERVER PROBLEM" />
-    </list>
-  </component>
-  <component name="JavadocGenerationManager">
-    <option name="OUTPUT_DIRECTORY" />
-    <option name="OPTION_SCOPE" value="protected" />
-    <option name="OPTION_HIERARCHY" value="true" />
-    <option name="OPTION_NAVIGATOR" value="true" />
-    <option name="OPTION_INDEX" value="true" />
-    <option name="OPTION_SEPARATE_INDEX" value="true" />
-    <option name="OPTION_DOCUMENT_TAG_USE" value="false" />
-    <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
-    <option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
-    <option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
-    <option name="OPTION_DEPRECATED_LIST" value="true" />
-    <option name="OTHER_OPTIONS" value="" />
-    <option name="HEAP_SIZE" />
-    <option name="LOCALE" />
-    <option name="OPEN_IN_BROWSER" value="true" />
-  </component>
-  <component name="JdkListConfigurable.UI">
-    <option name="proportions">
-      <SplitterProportionsDataImpl />
-    </option>
-  </component>
-  <component name="LogConsolePreferences">
-    <option name="FILTER_ERRORS" value="false" />
-    <option name="FILTER_WARNINGS" value="false" />
-    <option name="FILTER_INFO" value="true" />
-    <option name="CUSTOM_FILTER" />
-  </component>
-  <component name="ModuleStructureConfigurable.UI">
-    <option name="proportions">
-      <SplitterProportionsDataImpl />
-    </option>
-  </component>
-  <component name="Palette2">
-    <group name="Swing">
-      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
-      </item>
-      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
-      </item>
-      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
-      </item>
-      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
-        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
-      </item>
-      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
-        <initial-values>
-          <property name="text" value="Button" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
-        <initial-values>
-          <property name="text" value="RadioButton" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
-        <initial-values>
-          <property name="text" value="CheckBox" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
-        <initial-values>
-          <property name="text" value="Label" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
-          <preferred-size width="150" height="-1" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
-          <preferred-size width="150" height="-1" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
-          <preferred-size width="150" height="-1" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
-      </item>
-      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
-          <preferred-size width="200" height="200" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
-          <preferred-size width="200" height="200" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
-      </item>
-      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
-      </item>
-      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
-      </item>
-      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
-      </item>
-      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
-          <preferred-size width="-1" height="20" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
-      </item>
-      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
-      </item>
-    </group>
-  </component>
-  <component name="PerforceChangeBrowserSettings">
-    <option name="USE_CLIENT_FILTER" value="true" />
-    <option name="CLIENT" value="" />
-  </component>
-  <component name="ProjectDetails">
-    <option name="projectName" value="mercurial" />
-  </component>
-  <component name="ProjectDictionaryState">
-    <dictionary name="Pavel.Sher" />
-  </component>
-  <component name="ProjectKey">
-    <option name="state" value="project://C:\Work\mercurial\mercurial.ipr" />
-  </component>
-  <component name="ProjectLibrariesConfigurable.UI">
-    <option name="proportions">
-      <SplitterProportionsDataImpl />
-    </option>
-  </component>
-  <component name="ProjectModuleManager">
-    <modules>
-      <module fileurl="file://$PROJECT_DIR$/main.iml" filepath="$PROJECT_DIR$/main.iml" />
-      <module fileurl="file://$PROJECT_DIR$/mercurial-agent/mercurial-agent.iml" filepath="$PROJECT_DIR$/mercurial-agent/mercurial-agent.iml" />
-      <module fileurl="file://$PROJECT_DIR$/mercurial-common/mercurial-common.iml" filepath="$PROJECT_DIR$/mercurial-common/mercurial-common.iml" />
-      <module fileurl="file://$PROJECT_DIR$/mercurial-server/mercurial-server.iml" filepath="$PROJECT_DIR$/mercurial-server/mercurial-server.iml" />
-      <module fileurl="file://$PROJECT_DIR$/mercurial-tests/mercurial-tests.iml" filepath="$PROJECT_DIR$/mercurial-tests/mercurial-tests.iml" />
-    </modules>
-  </component>
-  <component name="ProjectResources">
-    <default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
-  </component>
-  <component name="ProjectRootConfigurable.UI">
-    <option name="proportions">
-      <SplitterProportionsDataImpl />
-    </option>
-  </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.6" project-jdk-type="JavaSDK" />
-  <component name="ResourceManagerContainer">
-    <option name="myResourceBundles">
-      <value>
-        <list size="0" />
-      </value>
-    </option>
-  </component>
-  <component name="ScopeChooserConfigurable.UI">
-    <option name="proportions">
-      <SplitterProportionsDataImpl />
-    </option>
-  </component>
-  <component name="Struts Assistant">
-    <option name="showInputs" value="true" />
-    <option name="resources">
-      <value>
-        <option name="strutsPath" />
-        <option name="strutsHelp" />
-      </value>
-    </option>
-    <option name="selectedTaglibs" />
-    <option name="selectedTaglibs" />
-    <option name="myStrutsValidationEnabled" value="true" />
-    <option name="myTilesValidationEnabled" value="true" />
-    <option name="myValidatorValidationEnabled" value="true" />
-    <option name="myReportErrorsAsWarnings" value="true" />
-  </component>
-  <component name="SvnBranchConfigurationManager">
-    <option name="myVersion" value="123" />
-    <option name="mySupportsUserInfoFilter" value="true" />
-  </component>
-  <component name="SvnChangesBrowserSettings">
-    <option name="USE_AUTHOR_FIELD" value="true" />
-    <option name="AUTHOR" value="" />
-    <option name="LOCATION" value="" />
-    <option name="USE_PROJECT_SETTINGS" value="true" />
-    <option name="USE_ALTERNATE_LOCATION" value="false" />
-  </component>
-  <component name="TeamCityRootDirectoryHolder">
-    <option name="myRelativeRootDirectory" />
-  </component>
-  <component name="VCS.FileViewConfiguration">
-    <option name="SELECTED_STATUSES" value="DEFAULT" />
-    <option name="SELECTED_COLUMNS" value="DEFAULT" />
-    <option name="SHOW_FILTERS" value="true" />
-    <option name="CUSTOMIZE_VIEW" value="true" />
-    <option name="SHOW_FILE_HISTORY_AS_TREE" value="true" />
-  </component>
-  <component name="VcsDirectoryMappings">
-    <mapping directory="" vcs="hg4idea" />
-  </component>
-  <component name="WebServicesPlugin" addRequiredLibraries="true" />
-  <component name="com.intellij.ide.util.scopeChooser.ScopeChooserConfigurable" proportions="" version="1">
-    <option name="myLastEditedConfigurable" />
-  </component>
-  <component name="com.intellij.jsf.UserDefinedFacesConfigs">
-    <option name="USER_DEFINED_CONFIGS">
-      <value>
-        <list size="0" />
-      </value>
-    </option>
-  </component>
-  <component name="com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectRootMasterDetailsConfigurable" proportions="" version="1">
-    <option name="myPlainMode" value="false" />
-    <option name="myLastEditedConfigurable" />
-  </component>
-  <component name="com.intellij.profile.ui.ErrorOptionsConfigurable" proportions="" version="1">
-    <option name="myLastEditedConfigurable" />
-  </component>
-  <component name="libraryTable">
-    <library name="IDEA-openapi">
-      <CLASSES>
-        <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/resources_en.jar!/" />
-        <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/util.jar!/" />
-        <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/openapi.jar!/" />
-        <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/annotations.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES />
-    </library>
-    <library name="jdom">
-      <CLASSES>
-        <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/jdom.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES />
-    </library>
-    <library name="JMock">
-      <CLASSES>
-        <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/hamcrest-library-1.1.jar!/" />
-        <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/hamcrest-core-1.1.jar!/" />
-        <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/jmock-2.5.1.jar!/" />
-        <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/jmock-SNAPSHOT.jar!/" />
-        <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/hamcrest-integration-1.1.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES>
-        <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/hamcrest-integration-1.1.jar!/" />
-      </SOURCES>
-    </library>
-    <library name="JUnit">
-      <CLASSES>
-        <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/junit-3.8.1.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES />
-    </library>
-    <library name="Log4j">
-      <CLASSES>
-        <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/log4j-1.2.12.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES />
-    </library>
-    <library name="TeamCity-impl">
-      <CLASSES>
-        <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/patches-impl.jar!/" />
-        <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/trove4j.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES />
-    </library>
-    <library name="TeamCity-TestsAPI">
-      <CLASSES>
-        <root url="jar://$TeamCityDistribution$/devPackage/tests/patches-test.jar!/" />
-        <root url="jar://$TeamCityDistribution$/devPackage/tests/tests-support.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES />
-    </library>
-    <library name="TeamCityAPI-agent">
-      <CLASSES>
-        <root url="jar://$TeamCityDistribution$/devPackage/agent-api.jar!/" />
-        <root url="jar://$TeamCityDistribution$/buildAgent/lib/agent.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES>
-        <root url="jar://$TeamCityDistribution$/devPackage/src/openApi-source.jar!/" />
-      </SOURCES>
-    </library>
-    <library name="TeamCityAPI-common">
-      <CLASSES>
-        <root url="jar://$TeamCityDistribution$/devPackage/common-api.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES>
-        <root url="jar://$TeamCityDistribution$/devPackage/src/openApi-source.jar!/" />
-      </SOURCES>
-    </library>
-    <library name="TeamCityAPI-server">
-      <CLASSES>
-        <root url="jar://$TeamCityDistribution$/devPackage/server-api.jar!/" />
-        <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/server.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES>
-        <root url="jar://$TeamCityDistribution$/devPackage/src/openApi-source.jar!/" />
-      </SOURCES>
-    </library>
-    <library name="TestNG">
-      <CLASSES>
-        <root url="jar://$PROJECT_DIR$/mercurial-tests/lib/testng-5.7-jdk15.jar!/" />
-      </CLASSES>
-      <JAVADOC />
-      <SOURCES />
-    </library>
-  </component>
-  <component name="testng.defaultConfiguration">
-    <outputDirectory />
-    <properties />
-  </component>
-</project>
-
--- a/mercurial.xml	Fri Nov 30 17:24:32 2012 +0400
+++ b/mercurial.xml	Fri Nov 30 17:25:41 2012 +0400
@@ -1,644 +1,601 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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="**/.sbas/**"/>
-    <exclude name="**/.IJI.*/**"/>
-    <exclude name="**/vssver.scc/**"/>
-    <exclude name="**/vssver2.scc/**"/>
-    <exclude name="**/*.orig/**"/>
-    <exclude name="**/*.lib/**"/>
-    <exclude name="**/*~/**"/>
-    <exclude name="**/__pycache__/**"/>
-    <exclude name="**/.bundle/**"/>
-    <exclude name="**/*.rbc/**"/>
-  </patternset>
-  <patternset id="library.patterns">
-    <include name="*.war"/>
-    <include name="*.ear"/>
-    <include name="*.apk"/>
-    <include name="*.zip"/>
-    <include name="*.swc"/>
-    <include name="*.egg"/>
-    <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>
-  
-  <!-- JDK definitions -->
-  
-  <property name="jdk.bin.1.5" value="${jdk.home.1.5}/bin"/>
-  <path id="jdk.classpath.1.5">
-    <fileset dir="${jdk.home.1.5}">
-      <include name="jre/lib/rt.jar"/>
-      <include name="jre/lib/jce.jar"/>
-      <include name="jre/lib/deploy.jar"/>
-      <include name="jre/lib/javaws.jar"/>
-      <include name="jre/lib/jsse.jar"/>
-      <include name="jre/lib/charsets.jar"/>
-      <include name="jre/lib/plugin.jar"/>
-      <include name="jre/lib/ext/localedata.jar"/>
-      <include name="jre/lib/ext/sunpkcs11.jar"/>
-      <include name="jre/lib/ext/sunjce_provider.jar"/>
-      <include name="jre/lib/ext/dnsns.jar"/>
-    </fileset>
-  </path>
-  
-  <property name="project.jdk.home" value="${jdk.home.1.5}"/>
-  <property name="project.jdk.bin" value="${jdk.bin.1.5}"/>
-  <property name="project.jdk.classpath" value="jdk.classpath.1.5"/>
-  
-  
-  <!-- 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.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>
-  
-  
-  <!-- Global Libraries -->
-  
-  
-  <!-- Application Server Libraries -->
-  
-  <!-- Modules -->
-  
-  
-  <!-- Module main -->
-  
-  <dirname property="module.main.basedir" file="${ant.file}"/>
-  
-  
-  <property name="module.jdk.home.main" value="${project.jdk.home}"/>
-  <property name="module.jdk.bin.main" value="${project.jdk.bin}"/>
-  <property name="module.jdk.classpath.main" value="${project.jdk.classpath}"/>
-  
-  <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 refid="${module.jdk.classpath.main}"/>
-  </path>
-  
-  <path id="main.runtime.production.module.classpath"/>
-  
-  <path id="main.module.classpath">
-    <path refid="${module.jdk.classpath.main}"/>
-  </path>
-  
-  <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="module.jdk.home.mercurial-common" value="${project.jdk.home}"/>
-  <property name="module.jdk.bin.mercurial-common" value="${project.jdk.bin}"/>
-  <property name="module.jdk.classpath.mercurial-common" value="${project.jdk.classpath}"/>
-  
-  <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="${module.jdk.classpath.mercurial-common}"/>
-    <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">
-    <path refid="${module.jdk.classpath.mercurial-common}"/>
-    <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" executable="${module.jdk.bin.mercurial-common}/javac">
-      <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="module.jdk.home.mercurial-agent" value="${project.jdk.home}"/>
-  <property name="module.jdk.bin.mercurial-agent" value="${project.jdk.bin}"/>
-  <property name="module.jdk.classpath.mercurial-agent" value="${project.jdk.classpath}"/>
-  
-  <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="${module.jdk.classpath.mercurial-agent}"/>
-    <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">
-    <path refid="${module.jdk.classpath.mercurial-agent}"/>
-    <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" executable="${module.jdk.bin.mercurial-agent}/javac">
-      <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="module.jdk.home.mercurial-server" value="${project.jdk.home}"/>
-  <property name="module.jdk.bin.mercurial-server" value="${project.jdk.bin}"/>
-  <property name="module.jdk.classpath.mercurial-server" value="${project.jdk.classpath}"/>
-  
-  <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="${module.jdk.classpath.mercurial-server}"/>
-    <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>
-  
-  <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>
-  
-  <path id="mercurial-server.module.classpath">
-    <path refid="${module.jdk.classpath.mercurial-server}"/>
-    <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>
-  
-  <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>
-  
-  
-  <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" executable="${module.jdk.bin.mercurial-server}/javac">
-      <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="module.jdk.home.mercurial-tests" value="${project.jdk.home}"/>
-  <property name="module.jdk.bin.mercurial-tests" value="${project.jdk.bin}"/>
-  <property name="module.jdk.classpath.mercurial-tests" value="${project.jdk.classpath}"/>
-  
-  <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">
-    <path refid="${module.jdk.classpath.mercurial-tests}"/>
-    <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>
-  
-  <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.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">
-    <path refid="${module.jdk.classpath.mercurial-tests}"/>
-    <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>
-  
-  <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.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" executable="${module.jdk.bin.mercurial-tests}/javac">
-      <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"/>
+<?xml version="1.0" encoding="UTF-8"?>
+<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