# HG changeset patch # User Dmitry Neverov # Date 1351085646 -14400 # Node ID e4210c35aa24d9e2fc87578708172fe634596914 # Parent 6ff7f6e77b989ae31968522b06b8742c3f9f0a37# Parent 7d3527fe45564966b81fb83953709faa173543e1 Merge branch Faradi-7.1.x diff -r 7d3527fe4556 -r e4210c35aa24 .hgignore --- a/.hgignore Wed Oct 24 16:46:18 2012 +0400 +++ b/.hgignore Wed Oct 24 17:34:06 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 diff -r 7d3527fe4556 -r e4210c35aa24 .idea/ant.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/ant.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff -r 7d3527fe4556 -r e4210c35aa24 .idea/artifacts/mercurial_agent_jar.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/artifacts/mercurial_agent_jar.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,14 @@ + + + $PROJECT_DIR$/out/artifacts/mercurial_agent_jar + + + file://$PROJECT_DIR$/build/ant.build.xml + replace-tokens-in-teamcity-plugin-xml + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/artifacts/mercurial_common_jar.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/artifacts/mercurial_common_jar.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/out/artifacts/mercurial_common_jar + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/artifacts/mercurial_server_jar.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/artifacts/mercurial_server_jar.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/out/artifacts/mercurial_server_jar + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/artifacts/mercurial_server_tc_jar.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/artifacts/mercurial_server_tc_jar.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,8 @@ + + + $PROJECT_DIR$/out/artifacts/mercurial_server_tc_jar + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/artifacts/plugin.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/artifacts/plugin.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,29 @@ + + + $PROJECT_DIR$/out/artifacts/plugin + + + file://$PROJECT_DIR$/build/ant.build.xml + replace-tokens-in-teamcity-plugin-xml + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/artifacts/zip.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/artifacts/zip.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,10 @@ + + + $PROJECT_DIR$/dist + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/compiler.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/compiler.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,30 @@ + + + + + + diff -r 7d3527fe4556 -r e4210c35aa24 .idea/copyright/profiles_settings.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/copyright/profiles_settings.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/encodings.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/encodings.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,5 @@ + + + + + diff -r 7d3527fe4556 -r e4210c35aa24 .idea/inspectionProfiles/Project_Default.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/inspectionProfiles/Project_Default.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/inspectionProfiles/profiles_settings.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/inspectionProfiles/profiles_settings.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/IDEA_openapi.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/IDEA_openapi.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/JMock.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/JMock.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/JUnit.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/JUnit.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/Log4j.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/Log4j.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/TeamCityAPI_agent.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/TeamCityAPI_agent.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/TeamCityAPI_common.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/TeamCityAPI_common.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/TeamCityAPI_server.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/TeamCityAPI_server.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/TeamCity_TestsAPI.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/TeamCity_TestsAPI.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/TeamCity_Vcs_Api.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/TeamCity_Vcs_Api.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/TeamCity_impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/TeamCity_impl.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/TestNG.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/TestNG.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/libraries/jdom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/libraries/jdom.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/misc.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/misc.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,9 @@ + + + + + + + + + diff -r 7d3527fe4556 -r e4210c35aa24 .idea/modules.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/modules.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff -r 7d3527fe4556 -r e4210c35aa24 .idea/scopes/scope_settings.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/scopes/scope_settings.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff -r 7d3527fe4556 -r e4210c35aa24 .idea/uiDesigner.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/uiDesigner.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 7d3527fe4556 -r e4210c35aa24 .idea/vcs.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.idea/vcs.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,7 @@ + + + + + + + diff -r 7d3527fe4556 -r e4210c35aa24 build/ant.build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build/ant.build.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java --- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandUtil.java Wed Oct 24 17:34:06 2012 +0400 @@ -41,7 +41,7 @@ @NotNull final String command, @NotNull final Set 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; diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-server-tc/mercurial-server-tc.iml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-server-tc/mercurial-server-tc.iml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-server-tc/src/META-INF/build-server-plugin-mercurial-tc.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-server-tc/src/META-INF/build-server-plugin-mercurial-tc.xml Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,6 @@ + + + + + + diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-server-tc/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialBranchSupport.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-server-tc/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialBranchSupport.java Wed Oct 24 17:34:06 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 getBranchRootOptions(@NotNull VcsRoot original, @NotNull String branchName) { + final Map options = new HashMap(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 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; + } +} diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-server/mercurial-server.iml --- a/mercurial-server/mercurial-server.iml Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial-server/mercurial-server.iml Wed Oct 24 17:34:06 2012 +0400 @@ -19,6 +19,7 @@ + diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialServerExtension.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialServerExtension.java Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,4 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial; + +public interface MercurialServerExtension { +} diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java --- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Wed Oct 24 17:34:06 2012 +0400 @@ -52,7 +52,7 @@ *

Working copy of repository is created in the $TEAMCITY_DATA_PATH/system/caches/hg_<hash code> folder. *

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; @@ -63,6 +63,7 @@ private final FileFilter myIgnoreDotHgFilter = new IgnoreDotHgFilter(); private final FileFilter myAcceptAllFilter = new AcceptAllFilter(); private final HgTestConnectionSupport myTestConnection; + private final Collection myExtensions; public MercurialVcsSupport(@NotNull final VcsManager vcsManager, @NotNull final SBuildServer server, @@ -73,7 +74,8 @@ @NotNull final RepoFactory repoFactory, @NotNull final MirrorManager mirrorManager, @NotNull final HgVcsRootFactory hgVcsRootFactory, - @NotNull final HgTestConnectionSupport testConnection) { + @NotNull final HgTestConnectionSupport testConnection, + @NotNull final Collection extensions) { myVcsManager = vcsManager; myConfig = config; myMirrorManager = mirrorManager; @@ -81,6 +83,7 @@ myRepoFactory = repoFactory; myHgVcsRootFactory = hgVcsRootFactory; myTestConnection = testConnection; + myExtensions = extensions; resetCacheHandlerManager.registerHandler(new MercurialResetCacheHandler(myMirrorManager)); dispatcher.addListener(new BuildServerAdapter() { @Override @@ -442,12 +445,7 @@ } @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 branchRevisions = getBranchesRevisions(hgRoot); String defaultBranchName = hgRoot.getBranchName(); @@ -457,7 +455,7 @@ e.setRoot(root); throw e; } - return RepositoryStateFactory.createRepositoryState(branchRevisions, defaultBranchName); + return RepositoryStateData.createVersionState(defaultBranchName, branchRevisions); } @NotNull @@ -472,58 +470,18 @@ } @NotNull - public Map getBranchRootOptions(@NotNull VcsRoot root, @NotNull String branchName) { - final Map options = new HashMap(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 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 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 collectChanges(@NotNull VcsRoot root, - @NotNull RepositoryState fromState, - @NotNull RepositoryState toState, + @NotNull RepositoryStateData fromState, + @NotNull RepositoryStateData toState, @NotNull CheckoutRules rules) throws VcsException { Set reportedCsetIds = new HashSet(); List changes = new ArrayList(); @@ -559,7 +517,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) @@ -769,7 +727,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()); } @@ -801,4 +759,14 @@ public ListFilesPolicy getListFilesPolicy() { return new ListFilesSupport(this, myHgVcsRootFactory); } + + + @Nullable + public T getVcsExtension(@NotNull Class klass) { + for (MercurialServerExtension e : myExtensions) { + if (klass.isInstance(e)) + return klass.cast(e); + } + return null; + } } diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-tests/mercurial-tests.iml --- a/mercurial-tests/mercurial-tests.iml Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial-tests/mercurial-tests.iml Wed Oct 24 17:34:06 2012 +0400 @@ -18,6 +18,8 @@ + + diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java Wed Oct 24 17:34:06 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.*; diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java Wed Oct 24 17:34:06 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; diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java Wed Oct 24 17:34:06 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; diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialSupportBuilder.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialSupportBuilder.java Wed Oct 24 17:34:06 2012 +0400 @@ -0,0 +1,81 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial; + +import jetbrains.buildServer.serverSide.BuildServerListener; +import jetbrains.buildServer.serverSide.SBuildServer; +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 ServerPluginConfigBuilder myConfigBuilder; + private ServerPluginConfig myConfig; + private List myExtensions = new ArrayList(); + private HgVcsRootFactory myHgRootFactory; + + public static MercurialSupportBuilder mercurialSupport() { + return new MercurialSupportBuilder(); + } + + @NotNull + public MercurialVcsSupport build() throws IOException { + if (myContext == null) + myContext = new Mockery(); + VcsManager vcsManager = myContext.mock(VcsManager.class); + final SBuildServer server = myContext.mock(SBuildServer.class); + final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); + myContext.checking(new Expectations() {{ + allowing(server).getExecutor(); will(returnValue(executor)); + }}); + EventDispatcher dispatcher = EventDispatcher.create(BuildServerListener.class); + if (myConfig == null) + myConfig = myConfigBuilder.build(); + myHgRootFactory = new HgVcsRootFactory(myConfig); + MirrorManagerImpl mirrorManager = new MirrorManagerImpl(myConfig); + ServerHgPathProvider hgPathProvider = new ServerHgPathProvider(myConfig); + RepoFactory repoFactory = new RepoFactory(myConfig, new ServerCommandSettingsFactory()); + 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))); + }}); + return new MercurialVcsSupport(vcsManager, server, dispatcher, resetCacheManager, myConfig, hgPathProvider, + repoFactory, mirrorManager, myHgRootFactory, testConnection, myExtensions); + } + + + public MercurialSupportBuilder withContext(@NotNull Mockery context) { + myContext = context; + return this; + } + + public MercurialSupportBuilder withConfig(@NotNull ServerPluginConfigBuilder config) { + myConfigBuilder = config; + return this; + } + + 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; + } +} diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java Wed Oct 24 17:34:06 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() { @@ -530,8 +527,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"); @@ -539,8 +541,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); } @@ -577,12 +584,11 @@ assertEquals(russianLocaleVersion, defaultLocaleVersion); } - public void collect_changes_between_states() throws Exception { VcsRootImpl root = createVcsRoot(myRep2Path); List 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"))); @@ -595,8 +601,8 @@ public void collect_changes_between_states_does_not_report_duplicate_changes() throws Exception { VcsRootImpl root = createVcsRoot(myRep2Path); List 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"))); diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RevisionFormatTest.java Wed Oct 24 17:34:06 2012 +0400 @@ -108,7 +108,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 entry : state.getBranchRevisions().entrySet()) { String branchName = entry.getKey(); String revision = entry.getKey(); diff -r 7d3527fe4556 -r e4210c35aa24 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java --- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Util.java Wed Oct 24 17:34:06 2012 +0400 @@ -1,12 +1,12 @@ 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.ResetCacheHandler; import jetbrains.buildServer.util.cache.ResetCacheRegister; import jetbrains.buildServer.vcs.CheckoutRules; import jetbrains.buildServer.vcs.VcsException; @@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; +import java.util.Collections; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -58,8 +59,12 @@ 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); + final ResetCacheRegister resetCacheManager = context.mock(ResetCacheRegister.class); + context.checking(new Expectations() {{ + allowing(resetCacheManager).registerHandler(with(any(ResetCacheHandler.class))); + }}); + return new MercurialVcsSupport(vcsManager, server, dispatcher, resetCacheManager, config, hgPathProvider, + repoFactory, mirrorManager, hgVcsRootFactory, testConnection, Collections.emptyList()); } diff -r 7d3527fe4556 -r e4210c35aa24 mercurial.ipr --- a/mercurial.ipr Wed Oct 24 16:46:18 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,486 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - http://www.w3.org/1999/xhtml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 7d3527fe4556 -r e4210c35aa24 mercurial.xml --- a/mercurial.xml Wed Oct 24 16:46:18 2012 +0400 +++ b/mercurial.xml Wed Oct 24 17:34:06 2012 +0400 @@ -1,644 +1,601 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file