changeset 8:2cb2df5a0dcd

fix working directory update (use pull command)
author Pavel.Sher
date Mon, 14 Jul 2008 20:52:10 +0400
parents 06104e41d5c2
children 7dadebd03515
files main.iml mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java mercurial.ipr mercurial/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java mercurial/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java
diffstat 5 files changed, 47 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.iml	Mon Jul 14 20:52:10 2008 +0400
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/.hg" />
+      <excludeFolder url="file://$MODULE_DIR$/dist" />
+      <excludeFolder url="file://$MODULE_DIR$/test-output" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntryProperties />
+  </component>
+</module>
+
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java	Mon Jul 14 20:29:29 2008 +0400
+++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java	Mon Jul 14 20:52:10 2008 +0400
@@ -49,14 +49,6 @@
     assertEquals("5:1d2cc6f3bc29", myVcs.getCurrentVersion(vcsRoot));
   }
 
-  public void testUpdateWorkingDir() throws Exception {
-    VcsRootImpl vcsRoot = createVcsRoot();
-    myVcs.getCurrentVersion(vcsRoot);
-
-    List<ModificationData> changes = myVcs.collectBuildChanges(vcsRoot, "0:9875b412a788", "3:9522278aa38d", new CheckoutRules(""));
-    assertEquals(3, changes.size());
-  }
-
   public void testCollectChanges() throws Exception {
     VcsRootImpl vcsRoot = createVcsRoot();
 
--- a/mercurial.ipr	Mon Jul 14 20:29:29 2008 +0400
+++ b/mercurial.ipr	Mon Jul 14 20:52:10 2008 +0400
@@ -317,9 +317,7 @@
       <SplitterProportionsDataImpl />
     </option>
   </component>
-  <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.5.latest" project-jdk-type="JavaSDK">
-    <output url="file://$PROJECT_DIR$/out" />
-  </component>
+  <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="true" project-jdk-name="1.5.latest" project-jdk-type="JavaSDK" />
   <component name="ResourceManagerContainer">
     <option name="myResourceBundles">
       <value>
--- a/mercurial/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Mon Jul 14 20:29:29 2008 +0400
+++ b/mercurial/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java	Mon Jul 14 20:52:10 2008 +0400
@@ -290,8 +290,8 @@
     synchronized (root) {
       if (hasRepositoryCopy(new File(workDir))) {
         // update
-        UpdateCommand up = new UpdateCommand(settings);
-        up.execute();
+        PullCommand pull = new PullCommand(settings);
+        pull.execute();
       } else {
         // clone
         CloneCommand cl = new CloneCommand(settings);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/PullCommand.java	Mon Jul 14 20:52:10 2008 +0400
@@ -0,0 +1,29 @@
+package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
+
+import com.intellij.execution.configurations.GeneralCommandLine;
+import org.jetbrains.annotations.NotNull;
+import jetbrains.buildServer.ExecResult;
+import jetbrains.buildServer.SimpleCommandLineProcessRunner;
+import jetbrains.buildServer.vcs.VcsException;
+
+/**
+ * @author Pavel.Sher
+ *         Date: 14.07.2008
+ */
+public class PullCommand {
+  private Settings mySettings;
+
+  public PullCommand(@NotNull final Settings settings) {
+    mySettings = settings;
+  }
+
+  public void execute() throws VcsException {
+    GeneralCommandLine cli = new GeneralCommandLine();
+    cli.setExePath(mySettings.getHgCommandPath());
+    cli.setWorkDirectory(mySettings.getWorkingDir());
+    cli.addParameter("pull");
+    cli.addParameter(mySettings.getRepository());
+    final ExecResult res = SimpleCommandLineProcessRunner.runCommand(cli, null);
+    CommandUtil.checkCommandFailed("hg pull", res);
+  }
+}