]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Provide repository API method for getting all files
authorvrana <jakubv@fb.com>
Fri, 9 Nov 2012 07:22:29 +0000 (23:22 -0800)
committervrana <jakubv@fb.com>
Tue, 13 Nov 2012 02:17:03 +0000 (18:17 -0800)
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

src/repository/api/ArcanistGitAPI.php
src/repository/api/ArcanistMercurialAPI.php
src/repository/api/ArcanistRepositoryAPI.php
src/repository/api/ArcanistSubversionAPI.php

index e9a170c59820567fde21da45f888b470c6308747..9aedfbf1f4e8f60502bb79f87c3e02993c6a5152 100644 (file)
@@ -527,6 +527,12 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
     return $files;
   }
 
+  public function getAllFiles() {
+    $future = $this->buildLocalFuture(array('ls-files -z'));
+    return id(new LinesOfALargeExecFuture($future))
+      ->setDelimiter("\0");
+  }
+
   public function getBlame($path) {
     // TODO: 'git blame' supports --porcelain and we should probably use it.
     list($stdout) = $this->execxLocal(
index 83d94d4dd4bee5161847a47c28ccd415d49cde73..749f753ff5de65812b56b716e14282ebb1aedbbe 100644 (file)
@@ -245,6 +245,12 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
     return $this->localCommitInfo;
   }
 
+  public function getAllFiles() {
+    // TODO: Handle paths with newlines.
+    $future = $this->buildLocalFuture(array('manifest'));
+    return new LinesOfALargeExecFuture($future);
+  }
+
   public function getBlame($path) {
     list($stdout) = $this->execxLocal(
       'annotate -u -v -c --rev %s -- %s',
index d177ca14527583b8fd67243383f1e163906b6bda..2c0469db9e6d74edda1eff16c5152292c69bbff1 100644 (file)
@@ -148,6 +148,11 @@ abstract class ArcanistRepositoryAPI {
     }
   }
 
+  /**
+   * @return Traversable
+   */
+  abstract public function getAllFiles();
+
   abstract public function getBlame($path);
   abstract public function getWorkingCopyStatus();
   abstract public function getRawDiffText($path);
index ab0285861c788ed8df56034710a146356ceea4ff..a57c891a272e237eac37032cbd2d45289d465ceb 100644 (file)
@@ -465,6 +465,22 @@ Index: {$path}
 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) {
     $blame = array();