1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-10 08:52:39 +01:00

Provide repository API method for getting all files

Test Plan:
  print_r(iterator_to_array($api->getAllFiles())); // Under Git.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2038

Differential Revision: https://secure.phabricator.com/D3940
This commit is contained in:
vrana 2012-11-08 23:22:29 -08:00
parent 827c1bc1c5
commit d3f351caae
4 changed files with 33 additions and 0 deletions

View file

@ -527,6 +527,12 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
return $files; return $files;
} }
public function getAllFiles() {
$future = $this->buildLocalFuture(array('ls-files -z'));
return id(new LinesOfALargeExecFuture($future))
->setDelimiter("\0");
}
public function getBlame($path) { public function getBlame($path) {
// TODO: 'git blame' supports --porcelain and we should probably use it. // TODO: 'git blame' supports --porcelain and we should probably use it.
list($stdout) = $this->execxLocal( list($stdout) = $this->execxLocal(

View file

@ -245,6 +245,12 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
return $this->localCommitInfo; return $this->localCommitInfo;
} }
public function getAllFiles() {
// TODO: Handle paths with newlines.
$future = $this->buildLocalFuture(array('manifest'));
return new LinesOfALargeExecFuture($future);
}
public function getBlame($path) { public function getBlame($path) {
list($stdout) = $this->execxLocal( list($stdout) = $this->execxLocal(
'annotate -u -v -c --rev %s -- %s', 'annotate -u -v -c --rev %s -- %s',

View file

@ -148,6 +148,11 @@ abstract class ArcanistRepositoryAPI {
} }
} }
/**
* @return Traversable
*/
abstract public function getAllFiles();
abstract public function getBlame($path); abstract public function getBlame($path);
abstract public function getWorkingCopyStatus(); abstract public function getWorkingCopyStatus();
abstract public function getRawDiffText($path); abstract public function getRawDiffText($path);

View file

@ -465,6 +465,22 @@ Index: {$path}
EODIFF; EODIFF;
} }
public function getAllFiles() {
// TODO: Handle paths with newlines.
$future = $this->buildLocalFuture(array('list -R'));
return new PhutilCallbackFilterIterator(
new LinesOfALargeExecFuture($future),
array($this, 'filterFiles'));
}
public function filterFiles($path) {
// NOTE: SVN uses '/' also on Windows.
if ($path == '' || substr($path, -1) == '/') {
return null;
}
return $path;
}
public function getBlame($path) { public function getBlame($path) {
$blame = array(); $blame = array();