diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php index 0d73872e..f95f12fe 100644 --- a/src/parser/ArcanistDiffParser.php +++ b/src/parser/ArcanistDiffParser.php @@ -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; } diff --git a/src/repository/api/ArcanistSubversionAPI.php b/src/repository/api/ArcanistSubversionAPI.php index 6c23727f..ab1f680c 100644 --- a/src/repository/api/ArcanistSubversionAPI.php +++ b/src/repository/api/ArcanistSubversionAPI.php @@ -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; }