changeset 774:ce67edf7bae9

allow to include hg extensions defined in VCS root
author eugene.petrenko@jetbrains.com
date Tue, 25 Feb 2014 13:11:18 +0100
parents bb37c581f463
children dd3a471a1188
files mercurial-agent/src/META-INF/build-agent-plugin-mercurial.xml mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentRepoFactory.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Constants.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettingsForRoot.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettingsForRootImpl.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettingsWeaver.java mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ExtensionsWeaver.java mercurial-server/src/META-INF/build-server-plugin-mercurial.xml mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialSupportBuilder.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubrepoChangesTest.java
diffstat 14 files changed, 179 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial-agent/src/META-INF/build-agent-plugin-mercurial.xml	Tue Feb 25 12:51:24 2014 +0100
+++ b/mercurial-agent/src/META-INF/build-agent-plugin-mercurial.xml	Tue Feb 25 13:11:18 2014 +0100
@@ -26,4 +26,7 @@
   <bean id="mirrorCleaner" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.AgentMirrorCleaner" />
   <bean id="commandSettingsFactory" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.AgentCommandSettingsFactory" />
   <bean id="agentRepoFactory" class="jetbrains.buildServer.buildTriggers.vcs.mercurial.AgentRepoFactory"/>
+
+  <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsForRootImpl"/>
+  <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ExtensionsWeaver"/>
 </beans>
--- a/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentRepoFactory.java	Tue Feb 25 12:51:24 2014 +0100
+++ b/mercurial-agent/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentRepoFactory.java	Tue Feb 25 13:11:18 2014 +0100
@@ -16,7 +16,7 @@
 
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
-import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsFactory;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsForRoot;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
@@ -25,16 +25,16 @@
 
 public class AgentRepoFactory implements HgRepoFactory {
 
-  private final CommandSettingsFactory myCommandSettingsFactory;
+  private final CommandSettingsForRoot myCommandSettingsFactory;
   private final HgPathProvider myHgPathProvider;
 
-  public AgentRepoFactory(@NotNull CommandSettingsFactory commandSettingsFactory,
+  public AgentRepoFactory(@NotNull CommandSettingsForRoot commandSettingsFactory,
                           @NotNull HgPathProvider hgPathProvider) {
     myCommandSettingsFactory = commandSettingsFactory;
     myHgPathProvider = hgPathProvider;
   }
 
   public HgRepo createRepo(@NotNull HgVcsRoot root, @NotNull File workingDir) throws VcsException {
-    return new HgRepo(myCommandSettingsFactory, workingDir, myHgPathProvider.getHgPath(root), root.getAuthSettings());
+    return new HgRepo(myCommandSettingsFactory.forRoot(root), workingDir, myHgPathProvider.getHgPath(root), root.getAuthSettings());
   }
 }
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Constants.java	Tue Feb 25 12:51:24 2014 +0100
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/Constants.java	Tue Feb 25 13:11:18 2014 +0100
@@ -32,6 +32,7 @@
   String USE_TAGS_AS_BRANCHES = "useTagsAsBranches";
   String INCLUDE_SUBREPOS_IN_PATCH = "includeSubreposInPatch";
   String USE_ARCHIVE_FOR_PATCH = "useArchiveForPatch";
+  String HG_EXTENSIONS = "hg.extensions";
 
   String GLOBAL_DETECT_SUBREPO_CHANGES = "teamcity.hg.detectSubrepoChanges";
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettingsForRoot.java	Tue Feb 25 13:11:18 2014 +0100
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Created 25.02.14 12:58
+ *
+ * @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
+ */
+public interface CommandSettingsForRoot {
+  @NotNull CommandSettingsFactory forRoot(@NotNull HgVcsRoot root);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettingsForRootImpl.java	Tue Feb 25 13:11:18 2014 +0100
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Created 25.02.14 13:01
+ *
+ * @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
+ */
+public class CommandSettingsForRootImpl implements CommandSettingsForRoot {
+  private final CommandSettingsFactory myFactory;
+  private final CommandSettingsWeaver[] myWeavers;
+
+  public CommandSettingsForRootImpl(@NotNull CommandSettingsFactory factory,
+                                    @NotNull final CommandSettingsWeaver... weavers) {
+    myFactory = factory;
+    myWeavers = weavers;
+  }
+
+  @NotNull
+  public CommandSettingsFactory forRoot(@NotNull final HgVcsRoot root) {
+    return new CommandSettingsFactory() {
+      @NotNull
+      public CommandSettings create() {
+        CommandSettings settings = myFactory.create();
+        for (CommandSettingsWeaver weaver : myWeavers) {
+          settings = weaver.update(root, settings);
+        }
+        return settings;
+      }
+    };
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettingsWeaver.java	Tue Feb 25 13:11:18 2014 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Created 25.02.14 13:02
+ *
+ * @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
+ */
+public interface CommandSettingsWeaver {
+  @NotNull
+  CommandSettings update(@NotNull HgVcsRoot root, @NotNull CommandSettings settings);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/ExtensionsWeaver.java	Tue Feb 25 13:11:18 2014 +0100
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
+
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants;
+import jetbrains.buildServer.util.StringUtil;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Created 25.02.14 13:03
+ *
+ * @author Eugene Petrenko (eugene.petrenko@jetbrains.com)
+ */
+public class ExtensionsWeaver implements CommandSettingsWeaver {
+  @NotNull
+  public CommandSettings update(@NotNull HgVcsRoot root, @NotNull CommandSettings settings) {
+    String extensions = root.getProperty(Constants.HG_EXTENSIONS);
+    if (StringUtil.isEmpty(extensions)) return settings;
+
+    for (String _line : extensions.split("[\\r\\n]+")) {
+      String line = _line.trim();
+      if (line.isEmpty()) continue;
+
+      if (!line.contains("=")) line += "=";
+
+      settings = settings.withGlobalArguments("--config", "extensions." + line);
+    }
+
+    return settings;
+  }
+}
--- a/mercurial-server/src/META-INF/build-server-plugin-mercurial.xml	Tue Feb 25 12:51:24 2014 +0100
+++ b/mercurial-server/src/META-INF/build-server-plugin-mercurial.xml	Tue Feb 25 13:11:18 2014 +0100
@@ -31,4 +31,7 @@
 
   <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialCommitsInfoBuilderSupport"/>
   <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialModificationInfoBuilder"/>
+
+  <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsForRootImpl"/>
+  <bean class="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ExtensionsWeaver"/>
 </beans>
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java	Tue Feb 25 12:51:24 2014 +0100
+++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/RepoFactory.java	Tue Feb 25 13:11:18 2014 +0100
@@ -18,6 +18,7 @@
 
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsFactory;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsForRoot;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot;
 import jetbrains.buildServer.vcs.VcsException;
 import org.jetbrains.annotations.NotNull;
@@ -31,12 +32,12 @@
 public class RepoFactory implements HgRepoFactory {
 
   protected final ServerPluginConfig myConfig;
-  protected final CommandSettingsFactory myCommandSettingsFactory;
+  protected final CommandSettingsForRoot myCommandSettingsFactory;
   protected final HgPathProvider myHgPathProvider;
 
 
   public RepoFactory(@NotNull ServerPluginConfig config,
-                     @NotNull CommandSettingsFactory commandSettingsFactory,
+                     @NotNull CommandSettingsForRoot commandSettingsFactory,
                      @NotNull HgPathProvider hgPathProvider) throws IOException {
     myConfig = config;
     myCommandSettingsFactory = commandSettingsFactory;
@@ -54,7 +55,7 @@
 
   @NotNull
   public ServerHgRepo createRepo(@NotNull HgVcsRoot root, @NotNull File workingDir) throws VcsException {
-    return create(workingDir, myHgPathProvider.getHgPath(root), root.getAuthSettings(), myCommandSettingsFactory, myConfig);
+    return create(workingDir, myHgPathProvider.getHgPath(root), root.getAuthSettings(), myCommandSettingsFactory.forRoot(root), myConfig);
   }
 
   public void dispose() {
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java	Tue Feb 25 12:51:24 2014 +0100
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentMirrorCleanerTest.java	Tue Feb 25 13:11:18 2014 +0100
@@ -17,6 +17,8 @@
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
 import jetbrains.buildServer.agent.*;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsForRootImpl;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ExtensionsWeaver;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.vcs.*;
 import jetbrains.buildServer.vcs.impl.VcsRootImpl;
@@ -62,7 +64,7 @@
 
     AgentPluginConfigImpl pluginConfig = new AgentPluginConfigImpl(agentConfig);
     myMirrorManager = new MirrorManagerImpl(pluginConfig);
-    AgentRepoFactory repoFactory = new AgentRepoFactory(new TestCommandSettingsFactory(), new AgentHgPathProvider(agentConfig));
+    AgentRepoFactory repoFactory = new AgentRepoFactory(new CommandSettingsForRootImpl(new TestCommandSettingsFactory(), new ExtensionsWeaver()), new AgentHgPathProvider(agentConfig));
     myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig, myMirrorManager, repoFactory);
     myCleaner = new AgentMirrorCleaner(myMirrorManager);
     myLogger = myContext.mock(BuildProgressLogger.class);
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Tue Feb 25 12:51:24 2014 +0100
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutTest.java	Tue Feb 25 13:11:18 2014 +0100
@@ -18,6 +18,8 @@
 import jetbrains.buildServer.agent.AgentRunningBuild;
 import jetbrains.buildServer.agent.BuildAgentConfiguration;
 import jetbrains.buildServer.agent.BuildProgressLogger;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsForRootImpl;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ExtensionsWeaver;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.util.FileUtil;
 import jetbrains.buildServer.util.TestFor;
@@ -75,7 +77,7 @@
     final AgentPluginConfigImpl pluginConfig = new AgentPluginConfigImpl(agentConfig);
     myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig,
             new MirrorManagerImpl(pluginConfig),
-            new AgentRepoFactory(new TestCommandSettingsFactory(), new AgentHgPathProvider(agentConfig)));
+            new AgentRepoFactory(new CommandSettingsForRootImpl(new TestCommandSettingsFactory(), new ExtensionsWeaver()), new AgentHgPathProvider(agentConfig)));
 
     myLogger = myContext.mock(BuildProgressLogger.class);
     myContext.checking(new Expectations() {{
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java	Tue Feb 25 12:51:24 2014 +0100
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/AgentSideCheckoutWithSubreposTest.java	Tue Feb 25 13:11:18 2014 +0100
@@ -21,6 +21,8 @@
 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.CommandSettingsForRootImpl;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ExtensionsWeaver;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.exception.ConnectionRefusedException;
 import jetbrains.buildServer.util.FileUtil;
@@ -83,7 +85,7 @@
     myMirrorManager = new MirrorManagerImpl(pluginConfig);
     myVcsSupport = new MercurialAgentSideVcsSupport(pluginConfig,
             myMirrorManager,
-            new AgentRepoFactory(new TestCommandSettingsFactory(), new AgentHgPathProvider(agentConfig)));
+            new AgentRepoFactory(new CommandSettingsForRootImpl(new TestCommandSettingsFactory(), new ExtensionsWeaver()), new AgentHgPathProvider(agentConfig)));
 
     myLogger = myContext.mock(BuildProgressLogger.class);
     myContext.checking(new Expectations() {{
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialSupportBuilder.java	Tue Feb 25 12:51:24 2014 +0100
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialSupportBuilder.java	Tue Feb 25 13:11:18 2014 +0100
@@ -16,6 +16,8 @@
 
 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
 
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandSettingsForRootImpl;
+import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.ExtensionsWeaver;
 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
 import jetbrains.buildServer.serverSide.ServerListener;
 import jetbrains.buildServer.util.EventDispatcher;
@@ -52,7 +54,7 @@
     MirrorManagerImpl mirrorManager = new MirrorManagerImpl(myConfig);
     myHgPathProvider = new ServerHgPathProvider(myConfig);
     if (myRepoFactory == null)
-      myRepoFactory = new RepoFactory(myConfig, new TestCommandSettingsFactory(), myHgPathProvider);
+      myRepoFactory = new RepoFactory(myConfig, new CommandSettingsForRootImpl(new TestCommandSettingsFactory(), new ExtensionsWeaver()), myHgPathProvider);
     HgTestConnectionSupport testConnection = new HgTestConnectionSupport(myHgRootFactory, myRepoFactory, mirrorManager, myHgPathProvider);
     final ResetCacheRegister resetCacheManager = myContext.mock(ResetCacheRegister.class);
     myContext.checking(new Expectations() {{
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubrepoChangesTest.java	Tue Feb 25 12:51:24 2014 +0100
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/SubrepoChangesTest.java	Tue Feb 25 13:11:18 2014 +0100
@@ -227,7 +227,7 @@
             .build();
 
     final AtomicInteger catCallCounter = new AtomicInteger(0);
-    RepoFactory repoFactory = new RepoFactory(pluginConfig, new TestCommandSettingsFactory(), myHgPathProvider) {
+    RepoFactory repoFactory = new RepoFactory(pluginConfig, new CommandSettingsForRootImpl(new TestCommandSettingsFactory(), new ExtensionsWeaver()), myHgPathProvider) {
       @NotNull
       @Override
       protected ServerHgRepo create(@NotNull File workingDir, @NotNull String hgPath, @NotNull AuthSettings authSettings, @NotNull CommandSettingsFactory commandSettingsFactory, @NotNull ServerPluginConfig config) {