]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Make "arc list" use "differential.query", not "differential.find"
authorepriestley <git@epriestley.com>
Mon, 6 Feb 2012 21:08:01 +0000 (13:08 -0800)
committerepriestley <git@epriestley.com>
Mon, 6 Feb 2012 21:08:01 +0000 (13:08 -0800)
Summary: Move toward deprecating "differntial.find". Also update the output to
be more inline with "arc branch".

Test Plan: Ran "arc list", "arc branch".

Reviewers: btrahan, arice

Reviewed By: arice

CC: aran, epriestley
Maniphest Tasks: T838

Differential Revision: https://secure.phabricator.com/D1579

src/branch/BranchInfo.php
src/workflow/list/ArcanistListWorkflow.php
src/workflow/list/__init__.php

index 39d14d64956a23d08e25511c77b09ed4a849da93..3af27dabbe591e88caa18979156af568d99446bb 100644 (file)
@@ -151,15 +151,13 @@ final class BranchInfo {
    * Generates a colored status name
    */
   public function getFormattedStatus() {
-    return phutil_console_format(
-      '<fg:'.$this->getColorForStatus().'>%s</fg>',
-      $this->status);
+    return self::renderColorizedRevisionStatus($this->status);
   }
 
   /**
    * Assigns a pretty color based on the status
    */
-  private function getColorForStatus() {
+  private static function getColorForStatus($status) {
     static $status_to_color = array(
       'Committed' => 'cyan',
       'Needs Review' => 'magenta',
@@ -168,7 +166,13 @@ final class BranchInfo {
       'No Revision' => 'blue',
       'Abandoned' => 'default',
     );
-    return idx($status_to_color, $this->status, 'default');
+    return idx($status_to_color, $status, 'default');
+  }
+
+  public static function renderColorizedRevisionStatus($status) {
+    return phutil_console_format(
+      '<fg:'.self::getColorForStatus($status).'>%s</fg>',
+      $status);
   }
 
 }
index f020ebf184cb09724c4fa6ca86dc2f04513a7ee2..4e63e56cf22ebe927509333894390efc84747a89 100644 (file)
@@ -26,7 +26,7 @@ final class ArcanistListWorkflow extends ArcanistBaseWorkflow {
   public function getCommandHelp() {
     return phutil_console_format(<<<EOTEXT
       **list**
-          Supports: git, svn
+          Supports: git, svn, hg
           List your open Differential revisions.
 EOTEXT
       );
@@ -45,40 +45,55 @@ EOTEXT
   }
 
   public function run() {
-
-    $conduit = $this->getConduit();
-    $repository_api = $this->getRepositoryAPI();
-
-    $revision_future = $conduit->callMethod(
-      'differential.find',
+    $revisions = $this->getConduit()->callMethodSynchronous(
+      'differential.query',
       array(
-        'guids' => array($this->getUserPHID()),
-        'query' => 'open',
+        'authors' => array($this->getUserPHID()),
+        'status'  => 'status-open',
       ));
 
-    $revisions = array();
-    foreach ($revision_future->resolve() as $revision_dict) {
-      $revisions[] = ArcanistDifferentialRevisionRef::newFromDictionary(
-        $revision_dict);
-    }
-
     if (!$revisions) {
       echo "You have no open Differential revisions.\n";
       return 0;
     }
 
+    $repository_api = $this->getRepositoryAPI();
+
+    $info = array();
 
-    foreach ($revisions as $revision) {
-      $revision_path = Filesystem::resolvePath($revision->getSourcePath());
+    $status_len = 0;
+    foreach ($revisions as $key => $revision) {
+      $revision_path = Filesystem::resolvePath($revision['sourcePath']);
       $current_path  = Filesystem::resolvePath($repository_api->getPath());
-      $from_here = ($revision_path == $current_path);
+      if ($revision_path == $current_path) {
+        $info[$key]['here'] = 1;
+      } else {
+        $info[$key]['here'] = 0;
+      }
+      $info[$key]['sort'] = sprintf(
+        '%d%04d%08d',
+        $info[$key]['here'],
+        $revision['status'],
+        $revision['id']);
+      $info[$key]['statusColorized'] =
+        BranchInfo::renderColorizedRevisionStatus(
+          $revision['statusName']);
+      $status_len = max(
+        $status_len,
+        strlen($info[$key]['statusColorized']));
+    }
 
+    $info = isort($info, 'sort');
+    foreach ($info as $key => $spec) {
+      $revision = $revisions[$key];
       printf(
-        "  %15s | %s | D%d | %s\n",
-        $revision->getStatusName(),
-        $from_here ? '*' : ' ',
-        $revision->getID(),
-        $revision->getName());
+        "%s %-".($status_len + 4)."s D%d: %s\n",
+        $spec['here']
+          ? phutil_console_format('**%s**', '*')
+          : ' ',
+        $spec['statusColorized'],
+        $revision['id'],
+        $revision['title']);
     }
 
     return 0;
index 06d6373b115015296b034d87c75f025b2aa7644a..5fe9d98c5f731e13221f3dc1e6c3bdf067ad343c 100644 (file)
@@ -6,11 +6,12 @@
 
 
 
-phutil_require_module('arcanist', 'differential/revision');
+phutil_require_module('arcanist', 'branch');
 phutil_require_module('arcanist', 'workflow/base');
 
 phutil_require_module('phutil', 'console');
 phutil_require_module('phutil', 'filesystem');
+phutil_require_module('phutil', 'utils');
 
 
 phutil_require_source('ArcanistListWorkflow.php');