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

Make "arc list" use "differential.query", not "differential.find"

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
This commit is contained in:
epriestley 2012-02-06 13:08:01 -08:00
parent 6bb43de4bb
commit 84f9148655
3 changed files with 49 additions and 29 deletions

View 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);
}
}

View 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();
foreach ($revisions as $revision) {
$revision_path = Filesystem::resolvePath($revision->getSourcePath());
$info = array();
$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;

View 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');