]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Improve Arcanist + Windows + SVN compatibility
authorepriestley <git@epriestley.com>
Tue, 17 Jul 2012 00:28:13 +0000 (17:28 -0700)
committerepriestley <git@epriestley.com>
Tue, 17 Jul 2012 00:28:13 +0000 (17:28 -0700)
Summary: From "cmd.exe" with, e.g. SilkSVN, there are some issues getting arc to do anything useful. Resolve enough of them so that it's at least usable.

Test Plan: Created a revision from Windows / cmd.exe / arc / SVN.

Reviewers: btrahan, jungejason, vrana

Reviewed By: vrana

CC: aran
Differential Revision: https://secure.phabricator.com/D2984

src/parser/ArcanistDiffParser.php
src/repository/api/ArcanistSubversionAPI.php

index 0d73872e438a3a719bd915a6f0554e2d4ab331a6..f95f12fe9e91a03873c8633459053413e86df49b 100644 (file)
@@ -988,7 +988,13 @@ final class ArcanistDiffParser {
       $text = preg_replace('/'.$ansi_color_pattern.'/', '', $text);
     }
 
-    $this->text = explode("\n", $text);
+    // TODO: This is a hack for SVN + Windows.
+    if (strpos($text, "\r\n") !== false) {
+      $this->text = explode("\r\n", $text);
+    } else {
+      $this->text = explode("\n", $text);
+    }
+
     $this->line = 0;
   }
 
index 6c23727fbfb9c07b7ef42fa643fdc88cd6e9c5a3..ab1f680c542f738f88862d0b8f7e345a98277d03 100644 (file)
@@ -85,7 +85,7 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
 
   public function getSVNStatus($with_externals = false) {
     if ($this->svnStatus === null) {
-      list($status) = execx('(cd %s && svn --xml status)', $this->getPath());
+      list($status) = $this->execxLocal('--xml status');
       $xml = new SimpleXMLElement($status);
 
       if (count($xml->target) != 1) {
@@ -245,17 +245,13 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
       //
       // Work around this by cd-ing into the directory before executing
       // 'svn info'.
-      return new ExecFuture(
-        '(cd %s && svn info .)',
-        $this->getPath());
+      return $this->buildLocalFuture(array('info .'));
     } else {
       // Note: here and elsewhere we need to append "@" to the path because if
       // a file has a literal "@" in it, everything after that will be
       // interpreted as a revision. By appending "@" with no argument, SVN
       // parses it properly.
-      return new ExecFuture(
-        'svn info %s@',
-        $this->getPath($path));
+      return $this->buildLocalFuture(array('info %s@', $this->getPath($path)));
     }
   }
 
@@ -270,12 +266,25 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
     // want that, so prevent recursive diffing.
     $root = phutil_get_library_root('arcanist');
 
-    return new ExecFuture(
-      '(cd %s; svn diff --depth empty --diff-cmd %s -x -U%d %s)',
-      $this->getPath(),
-      $root.'/../scripts/repository/binary_safe_diff.sh',
-      $this->getDiffLinesOfContext(),
-      $path);
+    if (phutil_is_windows()) {
+      // TODO: Provide a binary_safe_diff script for Windows.
+      // TODO: Provide a diff command which can take lines of context somehow.
+      return $this->buildLocalFuture(
+        array(
+          'diff --depth empty %s',
+          $path,
+        ));
+    } else {
+      $diff_bin = $root.'/../scripts/repository/binary_safe_diff.sh';
+      $diff_cmd = Filesystem::resolvePath($diff_bin);
+      return $this->buildLocalFuture(
+        array(
+          'diff --depth empty --diff-cmd %s -x -U%d %s',
+          $diff_cmd,
+          $this->getDiffLinesOfContext(),
+          $path,
+        ));
+    }
   }
 
   public function primeSVNInfoResult($path, $result) {
@@ -302,6 +311,9 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
           "Error #{$err} executing svn info against '{$path}'.");
       }
 
+      // TODO: Hack for Windows.
+      $stdout = str_replace("\r\n", "\n", $stdout);
+
       $patterns = array(
         '/^(URL): (\S+)$/m',
         '/^(Revision): (\d+)$/m',
@@ -472,10 +484,7 @@ EODIFF;
   public function getBlame($path) {
     $blame = array();
 
-    list($stdout) = execx(
-      '(cd %s && svn blame %s)',
-      $this->getPath(),
-      $path);
+    list($stdout) = $this->execxLocal('blame %s', $path);
 
     $stdout = trim($stdout);
     if (!strlen($stdout)) {
@@ -500,10 +509,7 @@ EODIFF;
     // SVN issues warnings for nonexistent paths, directories, etc., but still
     // returns no error code. However, for new paths in the working copy it
     // fails. Assume that failure means the original file does not exist.
-    list($err, $stdout) = exec_manual(
-      '(cd %s && svn cat %s@)',
-      $this->getPath(),
-      $path);
+    list($err, $stdout) = $this->execManualLocal('cat %s@', $path);
     if ($err) {
       return null;
     }