From cc283a63a50f57fed7c9c96d3bca680170e9aa30 Mon Sep 17 00:00:00 2001 From: Adam Hupp Date: Fri, 24 Jun 2011 09:16:49 -0700 Subject: [PATCH] Add by-status option to 'arc branch' 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 --- .../branch/ArcanistBranchWorkflow.php | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/workflow/branch/ArcanistBranchWorkflow.php b/src/workflow/branch/ArcanistBranchWorkflow.php index 0f2f3369..8019a230 100644 --- a/src/workflow/branch/ArcanistBranchWorkflow.php +++ b/src/workflow/branch/ArcanistBranchWorkflow.php @@ -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"; + } } } }