1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 16:22:42 +01:00

Improve Arcanist + Windows + SVN compatibility

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
This commit is contained in:
epriestley 2012-07-16 17:28:13 -07:00
parent 19e718a267
commit cb56743521
2 changed files with 34 additions and 22 deletions

View file

@ -988,7 +988,13 @@ final class ArcanistDiffParser {
$text = preg_replace('/'.$ansi_color_pattern.'/', '', $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;
}

View 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',
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);
$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;
}