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