diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php index 9aedfbf1..f1849fcd 100644 --- a/src/repository/api/ArcanistGitAPI.php +++ b/src/repository/api/ArcanistGitAPI.php @@ -533,6 +533,21 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { ->setDelimiter("\0"); } + public function getChangedFiles($since_commit) { + list($stdout) = $this->execxLocal( + 'diff --name-status -z %s', + $since_commit); + $return = array(); + foreach (array_chunk(explode("\0", $stdout), 2) as $val) { + if (count($val) != 2) { + break; + } + list($status, $path) = $val; + $return[$path] = ($status == 'D' ? false : true); + } + return $return; + } + public function getBlame($path) { // TODO: 'git blame' supports --porcelain and we should probably use it. list($stdout) = $this->execxLocal( diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index 749f753f..62573fe9 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -251,6 +251,21 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { return new LinesOfALargeExecFuture($future); } + public function getChangedFiles($since_commit) { + list($stdout) = $this->execxLocal( + 'status --rev %s -0', + $since_commit); + $return = array(); + foreach (explode("\0", $stdout) as $val) { + $match = null; + if (preg_match('/^(.) (.+)/', $val, $match)) { + list(, $status, $path) = $match; + $return[$path] = ($status == 'R' ? false : true); + } + } + return $return; + } + public function getBlame($path) { list($stdout) = $this->execxLocal( 'annotate -u -v -c --rev %s -- %s', diff --git a/src/repository/api/ArcanistRepositoryAPI.php b/src/repository/api/ArcanistRepositoryAPI.php index 2c0469db..df4e899c 100644 --- a/src/repository/api/ArcanistRepositoryAPI.php +++ b/src/repository/api/ArcanistRepositoryAPI.php @@ -188,6 +188,10 @@ abstract class ArcanistRepositoryAPI { throw new ArcanistCapabilityNotSupportedException($this); } + public function getChangedFiles($since_commit) { + throw new ArcanistCapabilityNotSupportedException($this); + } + public function amendCommit($message) { throw new ArcanistCapabilityNotSupportedException($this); } diff --git a/src/repository/api/ArcanistSubversionAPI.php b/src/repository/api/ArcanistSubversionAPI.php index a57c891a..30d85753 100644 --- a/src/repository/api/ArcanistSubversionAPI.php +++ b/src/repository/api/ArcanistSubversionAPI.php @@ -473,6 +473,22 @@ EODIFF; array($this, 'filterFiles')); } + public function getChangedFiles($since_commit) { + // TODO: Handle paths with newlines. + list($stdout) = $this->execxLocal( + 'diff --revision %s:HEAD', + $since_commit); + $return = array(); + foreach (explode("\n", $stdout) as $val) { + $match = null; + if (preg_match('/^(.)\S*\s+(.+)/', $val, $match)) { + list(, $status, $path) = $match; + $return[$path] = ($status == 'D' ? false : true); + } + } + return $return; + } + public function filterFiles($path) { // NOTE: SVN uses '/' also on Windows. if ($path == '' || substr($path, -1) == '/') {