]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add by-status option to 'arc branch'
authorAdam Hupp <ahupp@fb.com>
Fri, 24 Jun 2011 16:16:49 +0000 (09:16 -0700)
committerAdam Hupp <ahupp@fb.com>
Wed, 29 Jun 2011 03:35:23 +0000 (20:35 -0700)
Summary:
This diff adds a '--by-status' argument to arc branch that sorts the
output by status.  Example output:

    Accepted
      my-branch                         Amazing change
    Needs Revision
      nah-nah                           Not so good change
    Needs Review
      in-progress-change                I have no idea
    No Revision
      etc                               etc

Blame Rev:

Task ID:  #

Reviewers: epriestley, slawekbiel

Test Plan:
Ran it with and without --by-status, saw expected output in both cases.

DiffCamp Revision:

Revert Plan:

Database Impact:

Memcache Impact:

Other Notes:

EImportant:

- begin *PUBLIC* platform impact section -
Bugzilla: #
- end platform impact -

Differential Revision: 512

src/workflow/branch/ArcanistBranchWorkflow.php

index 0f2f3369bdb2f6f91e20ae2320d6261ffcc4beff..8019a2305fd28354f4dbfa44ee013d8132dcbfdd 100644 (file)
@@ -57,6 +57,9 @@ EOTEXT
         'help' =>
           "Include committed and abandoned revisions",
       ),
+      'by-status' => array(
+        'help' => 'Group output by revision status.',
+      ),
     );
   }
 
@@ -78,6 +81,7 @@ EOTEXT
         $branch->setStatus('Not Yours');
         continue;
       }
+
       $rev_id = $branch->getRevisionId();
       if ($rev_id) {
         $status = idx($revision_status, $rev_id, 'Unknown Status');
@@ -137,16 +141,35 @@ EOTEXT
       $longest_name = max(strlen($branch->getFormattedName()), $longest_name);
       $longest_status = max(strlen($branch->getStatus()), $longest_status);
     }
-    foreach ($this->branches as $branch) {
-      $name_markdown = $branch->getFormattedName();
-      $status_markdown = $branch->getFormattedStatus();
-      $subject = $branch->getCommitSubject();
-      $subject_pad = $longest_status - strlen($branch->getStatus()) + 4;
-      $name_markdown =
-        str_pad($name_markdown, $longest_name + 4, ' ');
-      $subject =
-        str_pad($subject, strlen($subject) + $subject_pad, ' ', STR_PAD_LEFT);
-      echo "$name_markdown $status_markdown $subject\n";
+
+    if ($this->getArgument('by-status')) {
+      $by_status = mgroup($this->branches, 'getStatus');
+      foreach (array('Accepted', 'Needs Revision',
+                     'Needs Review', 'No Revision') as $status) {
+        $branches = idx($by_status, $status);
+        if (!$branches) {
+          continue;
+        }
+        echo reset($branches)->getFormattedStatus()."\n";
+        foreach ($branches as $branch) {
+          $name_markdown = $branch->getFormattedName();
+          $subject = $branch->getCommitSubject();
+          $name_markdown = str_pad($name_markdown, $longest_name + 4, ' ');
+          echo "  $name_markdown $subject\n";
+        }
+      }
+    } else {
+      foreach ($this->branches as $branch) {
+        $name_markdown = $branch->getFormattedName();
+        $status_markdown = $branch->getFormattedStatus();
+        $subject = $branch->getCommitSubject();
+        $subject_pad = $longest_status - strlen($branch->getStatus()) + 4;
+        $name_markdown =
+          str_pad($name_markdown, $longest_name + 4, ' ');
+        $subject =
+          str_pad($subject, strlen($subject) + $subject_pad, ' ', STR_PAD_LEFT);
+        echo "$name_markdown $status_markdown $subject\n";
+      }
     }
   }
 }