1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Update "arc land" display of build failures, and rename "DisplayRef" to "RefView"

Summary:
Ref T13546. Show ongoing and failed builds more clearly in "arc land" output.

Also rename "DisplayRef" (which is not a "Ref") to "RefView" with the goal of improving clarity, and let callers "build...()" it so they can add more status, etc., information.

Get rid of "[DisplayRef|RefView]Interface". In theory, future refs (say, in Phabricator) might not do anything here, but every Ref just ends up implementing it. This could perhaps be subclassed more narrowly in the future if necessary.

Test Plan: Ran "arc land", grepped for various symbols.

Maniphest Tasks: T13546

Differential Revision: https://secure.phabricator.com/D21352
This commit is contained in:
epriestley 2020-06-10 17:15:42 -07:00
parent 33dfa859d8
commit 63f2e667b9
19 changed files with 172 additions and 195 deletions

View file

@ -168,8 +168,6 @@ phutil_register_library_map(array(
'ArcanistDifferentialDependencyGraph' => 'differential/ArcanistDifferentialDependencyGraph.php', 'ArcanistDifferentialDependencyGraph' => 'differential/ArcanistDifferentialDependencyGraph.php',
'ArcanistDifferentialRevisionHash' => 'differential/constants/ArcanistDifferentialRevisionHash.php', 'ArcanistDifferentialRevisionHash' => 'differential/constants/ArcanistDifferentialRevisionHash.php',
'ArcanistDifferentialRevisionStatus' => 'differential/constants/ArcanistDifferentialRevisionStatus.php', 'ArcanistDifferentialRevisionStatus' => 'differential/constants/ArcanistDifferentialRevisionStatus.php',
'ArcanistDisplayRef' => 'ref/ArcanistDisplayRef.php',
'ArcanistDisplayRefInterface' => 'ref/ArcanistDisplayRefInterface.php',
'ArcanistDoubleQuoteXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistDoubleQuoteXHPASTLinterRule.php', 'ArcanistDoubleQuoteXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistDoubleQuoteXHPASTLinterRule.php',
'ArcanistDoubleQuoteXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistDoubleQuoteXHPASTLinterRuleTestCase.php', 'ArcanistDoubleQuoteXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistDoubleQuoteXHPASTLinterRuleTestCase.php',
'ArcanistDownloadWorkflow' => 'workflow/ArcanistDownloadWorkflow.php', 'ArcanistDownloadWorkflow' => 'workflow/ArcanistDownloadWorkflow.php',
@ -415,6 +413,7 @@ phutil_register_library_map(array(
'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase.php', 'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase.php',
'ArcanistRef' => 'ref/ArcanistRef.php', 'ArcanistRef' => 'ref/ArcanistRef.php',
'ArcanistRefInspector' => 'inspector/ArcanistRefInspector.php', 'ArcanistRefInspector' => 'inspector/ArcanistRefInspector.php',
'ArcanistRefView' => 'ref/ArcanistRefView.php',
'ArcanistRemoteRef' => 'repository/remote/ArcanistRemoteRef.php', 'ArcanistRemoteRef' => 'repository/remote/ArcanistRemoteRef.php',
'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php', 'ArcanistRepositoryAPI' => 'repository/api/ArcanistRepositoryAPI.php',
'ArcanistRepositoryAPIMiscTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php', 'ArcanistRepositoryAPIMiscTestCase' => 'repository/api/__tests__/ArcanistRepositoryAPIMiscTestCase.php',
@ -1084,21 +1083,12 @@ phutil_register_library_map(array(
'ArcanistBrowseURIRef' => 'ArcanistRef', 'ArcanistBrowseURIRef' => 'ArcanistRef',
'ArcanistBrowseWorkflow' => 'ArcanistArcWorkflow', 'ArcanistBrowseWorkflow' => 'ArcanistArcWorkflow',
'ArcanistBuildBuildplanHardpointQuery' => 'ArcanistRuntimeHardpointQuery', 'ArcanistBuildBuildplanHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
'ArcanistBuildPlanRef' => array( 'ArcanistBuildPlanRef' => 'ArcanistRef',
'ArcanistRef',
'ArcanistDisplayRefInterface',
),
'ArcanistBuildPlanSymbolRef' => 'ArcanistSimpleSymbolRef', 'ArcanistBuildPlanSymbolRef' => 'ArcanistSimpleSymbolRef',
'ArcanistBuildRef' => array( 'ArcanistBuildRef' => 'ArcanistRef',
'ArcanistRef',
'ArcanistDisplayRefInterface',
),
'ArcanistBuildSymbolRef' => 'ArcanistSimpleSymbolRef', 'ArcanistBuildSymbolRef' => 'ArcanistSimpleSymbolRef',
'ArcanistBuildableBuildsHardpointQuery' => 'ArcanistRuntimeHardpointQuery', 'ArcanistBuildableBuildsHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
'ArcanistBuildableRef' => array( 'ArcanistBuildableRef' => 'ArcanistRef',
'ArcanistRef',
'ArcanistDisplayRefInterface',
),
'ArcanistBuildableSymbolRef' => 'ArcanistSimpleSymbolRef', 'ArcanistBuildableSymbolRef' => 'ArcanistSimpleSymbolRef',
'ArcanistBundle' => 'Phobject', 'ArcanistBundle' => 'Phobject',
'ArcanistBundleTestCase' => 'PhutilTestCase', 'ArcanistBundleTestCase' => 'PhutilTestCase',
@ -1196,10 +1186,6 @@ phutil_register_library_map(array(
'ArcanistDifferentialDependencyGraph' => 'AbstractDirectedGraph', 'ArcanistDifferentialDependencyGraph' => 'AbstractDirectedGraph',
'ArcanistDifferentialRevisionHash' => 'Phobject', 'ArcanistDifferentialRevisionHash' => 'Phobject',
'ArcanistDifferentialRevisionStatus' => 'Phobject', 'ArcanistDifferentialRevisionStatus' => 'Phobject',
'ArcanistDisplayRef' => array(
'Phobject',
'ArcanistTerminalStringInterface',
),
'ArcanistDoubleQuoteXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistDoubleQuoteXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistDoubleQuoteXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistDoubleQuoteXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistDownloadWorkflow' => 'ArcanistArcWorkflow', 'ArcanistDownloadWorkflow' => 'ArcanistArcWorkflow',
@ -1224,10 +1210,7 @@ phutil_register_library_map(array(
'ArcanistExtractUseXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistExtractUseXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistFileConfigurationSource' => 'ArcanistFilesystemConfigurationSource', 'ArcanistFileConfigurationSource' => 'ArcanistFilesystemConfigurationSource',
'ArcanistFileDataRef' => 'Phobject', 'ArcanistFileDataRef' => 'Phobject',
'ArcanistFileRef' => array( 'ArcanistFileRef' => 'ArcanistRef',
'ArcanistRef',
'ArcanistDisplayRefInterface',
),
'ArcanistFileSymbolRef' => 'ArcanistSimpleSymbolRef', 'ArcanistFileSymbolRef' => 'ArcanistSimpleSymbolRef',
'ArcanistFileUploader' => 'Phobject', 'ArcanistFileUploader' => 'Phobject',
'ArcanistFilenameLinter' => 'ArcanistLinter', 'ArcanistFilenameLinter' => 'ArcanistLinter',
@ -1357,10 +1340,7 @@ phutil_register_library_map(array(
'ArcanistLogicalOperatorsXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistLogicalOperatorsXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistLowercaseFunctionsXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistLowercaseFunctionsXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistLowercaseFunctionsXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistLowercaseFunctionsXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistMarkerRef' => array( 'ArcanistMarkerRef' => 'ArcanistRef',
'ArcanistRef',
'ArcanistDisplayRefInterface',
),
'ArcanistMarkersWorkflow' => 'ArcanistArcWorkflow', 'ArcanistMarkersWorkflow' => 'ArcanistArcWorkflow',
'ArcanistMercurialAPI' => 'ArcanistRepositoryAPI', 'ArcanistMercurialAPI' => 'ArcanistRepositoryAPI',
'ArcanistMercurialCommitMessageHardpointQuery' => 'ArcanistWorkflowMercurialHardpointQuery', 'ArcanistMercurialCommitMessageHardpointQuery' => 'ArcanistWorkflowMercurialHardpointQuery',
@ -1420,10 +1400,7 @@ phutil_register_library_map(array(
'ArcanistParenthesesSpacingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistParenthesesSpacingXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistParseStrUseXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistParseStrUseXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistParseStrUseXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistParseStrUseXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistPasteRef' => array( 'ArcanistPasteRef' => 'ArcanistRef',
'ArcanistRef',
'ArcanistDisplayRefInterface',
),
'ArcanistPasteSymbolRef' => 'ArcanistSimpleSymbolRef', 'ArcanistPasteSymbolRef' => 'ArcanistSimpleSymbolRef',
'ArcanistPasteWorkflow' => 'ArcanistArcWorkflow', 'ArcanistPasteWorkflow' => 'ArcanistArcWorkflow',
'ArcanistPatchWorkflow' => 'ArcanistWorkflow', 'ArcanistPatchWorkflow' => 'ArcanistWorkflow',
@ -1454,6 +1431,10 @@ phutil_register_library_map(array(
'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistRaggedClassTreeEdgeXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistRef' => 'ArcanistHardpointObject', 'ArcanistRef' => 'ArcanistHardpointObject',
'ArcanistRefInspector' => 'Phobject', 'ArcanistRefInspector' => 'Phobject',
'ArcanistRefView' => array(
'Phobject',
'ArcanistTerminalStringInterface',
),
'ArcanistRemoteRef' => 'ArcanistRef', 'ArcanistRemoteRef' => 'ArcanistRef',
'ArcanistRepositoryAPI' => 'Phobject', 'ArcanistRepositoryAPI' => 'Phobject',
'ArcanistRepositoryAPIMiscTestCase' => 'PhutilTestCase', 'ArcanistRepositoryAPIMiscTestCase' => 'PhutilTestCase',
@ -1473,10 +1454,7 @@ phutil_register_library_map(array(
'ArcanistRevisionBuildableHardpointQuery' => 'ArcanistRuntimeHardpointQuery', 'ArcanistRevisionBuildableHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
'ArcanistRevisionCommitMessageHardpointQuery' => 'ArcanistRuntimeHardpointQuery', 'ArcanistRevisionCommitMessageHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
'ArcanistRevisionParentRevisionsHardpointQuery' => 'ArcanistRuntimeHardpointQuery', 'ArcanistRevisionParentRevisionsHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
'ArcanistRevisionRef' => array( 'ArcanistRevisionRef' => 'ArcanistRef',
'ArcanistRef',
'ArcanistDisplayRefInterface',
),
'ArcanistRevisionRefSource' => 'Phobject', 'ArcanistRevisionRefSource' => 'Phobject',
'ArcanistRevisionSymbolRef' => 'ArcanistSimpleSymbolRef', 'ArcanistRevisionSymbolRef' => 'ArcanistSimpleSymbolRef',
'ArcanistRuboCopLinter' => 'ArcanistExternalLinter', 'ArcanistRuboCopLinter' => 'ArcanistExternalLinter',
@ -1517,10 +1495,7 @@ phutil_register_library_map(array(
'ArcanistSymbolRef' => 'ArcanistRef', 'ArcanistSymbolRef' => 'ArcanistRef',
'ArcanistSyntaxErrorXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistSyntaxErrorXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistSystemConfigurationSource' => 'ArcanistFilesystemConfigurationSource', 'ArcanistSystemConfigurationSource' => 'ArcanistFilesystemConfigurationSource',
'ArcanistTaskRef' => array( 'ArcanistTaskRef' => 'ArcanistRef',
'ArcanistRef',
'ArcanistDisplayRefInterface',
),
'ArcanistTaskSymbolRef' => 'ArcanistSimpleSymbolRef', 'ArcanistTaskSymbolRef' => 'ArcanistSimpleSymbolRef',
'ArcanistTasksWorkflow' => 'ArcanistWorkflow', 'ArcanistTasksWorkflow' => 'ArcanistWorkflow',
'ArcanistTautologicalExpressionXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistTautologicalExpressionXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
@ -1570,10 +1545,7 @@ phutil_register_library_map(array(
'ArcanistUselessOverridingMethodXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase', 'ArcanistUselessOverridingMethodXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistUserAbortException' => 'ArcanistUsageException', 'ArcanistUserAbortException' => 'ArcanistUsageException',
'ArcanistUserConfigurationSource' => 'ArcanistFilesystemConfigurationSource', 'ArcanistUserConfigurationSource' => 'ArcanistFilesystemConfigurationSource',
'ArcanistUserRef' => array( 'ArcanistUserRef' => 'ArcanistRef',
'ArcanistRef',
'ArcanistDisplayRefInterface',
),
'ArcanistUserSymbolHardpointQuery' => 'ArcanistRuntimeHardpointQuery', 'ArcanistUserSymbolHardpointQuery' => 'ArcanistRuntimeHardpointQuery',
'ArcanistUserSymbolRef' => 'ArcanistSymbolRef', 'ArcanistUserSymbolRef' => 'ArcanistSymbolRef',
'ArcanistUserSymbolRefInspector' => 'ArcanistRefInspector', 'ArcanistUserSymbolRefInspector' => 'ArcanistRefInspector',

View file

@ -305,7 +305,7 @@ abstract class ArcanistLandEngine
$viewer->getMonogram())); $viewer->getMonogram()));
foreach ($unauthored as $revision_ref) { foreach ($unauthored as $revision_ref) {
$display_ref = $revision_ref->newDisplayRef(); $display_ref = $revision_ref->newRefView();
$author_ref = $revision_ref->getAuthorRef(); $author_ref = $revision_ref->getAuthorRef();
if ($author_ref) { if ($author_ref) {
@ -373,7 +373,7 @@ abstract class ArcanistLandEngine
phutil_count($planned))); phutil_count($planned)));
foreach ($planned as $revision_ref) { foreach ($planned as $revision_ref) {
echo tsprintf('%s', $revision_ref->newDisplayRef()); echo tsprintf('%s', $revision_ref->newRefView());
} }
$query = pht( $query = pht(
@ -402,7 +402,7 @@ abstract class ArcanistLandEngine
$example_ref->getStatusDisplayName())); $example_ref->getStatusDisplayName()));
foreach ($published as $revision_ref) { foreach ($published as $revision_ref) {
echo tsprintf('%s', $revision_ref->newDisplayRef()); echo tsprintf('%s', $revision_ref->newRefView());
} }
$query = pht( $query = pht(
@ -429,7 +429,7 @@ abstract class ArcanistLandEngine
phutil_count($not_accepted))); phutil_count($not_accepted)));
foreach ($not_accepted as $revision_ref) { foreach ($not_accepted as $revision_ref) {
$display_ref = $revision_ref->newDisplayRef(); $display_ref = $revision_ref->newRefView();
$display_ref->appendLine( $display_ref->appendLine(
pht( pht(
'Status: %s', 'Status: %s',
@ -493,7 +493,7 @@ abstract class ArcanistLandEngine
foreach ($open_parents as $parent_phid => $spec) { foreach ($open_parents as $parent_phid => $spec) {
$parent_ref = $spec['ref']; $parent_ref = $spec['ref'];
$display_ref = $parent_ref->newDisplayRef(); $display_ref = $parent_ref->newRefView();
$display_ref->appendLine( $display_ref->appendLine(
pht( pht(
@ -686,38 +686,31 @@ abstract class ArcanistLandEngine
$prompt_key = 'arc.land.ongoing-builds'; $prompt_key = 'arc.land.ongoing-builds';
} }
$workflow = $this->getWorkflow();
echo tsprintf("\n"); echo tsprintf("\n");
foreach ($build_map as $build_item) { foreach ($build_map as $build_item) {
$revision_ref = $build_item['revisionRef']; $revision_ref = $build_item['revisionRef'];
$revision_view = $revision_ref->newRefView();
echo tsprintf('%s', $revision_ref->newDisplayRef()); $buildable_ref = $revision_ref->getBuildableRef();
$buildable_view = $buildable_ref->newRefView();
$raw_uri = $buildable_ref->getURI();
$raw_uri = $workflow->getAbsoluteURI($raw_uri);
$buildable_view->setURI($raw_uri);
$revision_view->addChild($buildable_view);
foreach ($build_item['buildRefs'] as $build_ref) { foreach ($build_item['buildRefs'] as $build_ref) {
echo tsprintf('%s', $build_ref->newDisplayRef()); $build_view = $build_ref->newRefView();
$buildable_view->addChild($build_view);
} }
echo tsprintf('%s', $revision_view);
echo tsprintf("\n"); echo tsprintf("\n");
} }
echo tsprintf(
"\n%s\n",
pht('You can review build details here:'));
// TODO: Only show buildables with problem builds.
$workflow = $this->getWorkflow();
foreach ($buildable_refs as $buildable) {
$display_ref = $buildable->newDisplayRef();
$raw_uri = $buildable->getURI();
$raw_uri = $workflow->getAbsoluteURI($raw_uri);
$display_ref->setURI($raw_uri);
echo tsprintf('%s', $display_ref);
}
$this->getWorkflow() $this->getWorkflow()
->getPrompt($prompt_key) ->getPrompt($prompt_key)
->setQuery($query) ->setQuery($query)
@ -777,7 +770,7 @@ abstract class ArcanistLandEngine
echo tsprintf( echo tsprintf(
"\n%s", "\n%s",
$revision_ref->newDisplayRef()); $revision_ref->newRefView());
foreach ($set->getCommits() as $commit) { foreach ($set->getCommits() as $commit) {
$is_implicit = $commit->getIsImplicitCommit(); $is_implicit = $commit->getIsImplicitCommit();
@ -969,7 +962,7 @@ abstract class ArcanistLandEngine
foreach ($revision_refs as $revision_ref) { foreach ($revision_refs as $revision_ref) {
echo tsprintf( echo tsprintf(
'%s', '%s',
$revision_ref->newDisplayRef()); $revision_ref->newRefView());
} }
echo tsprintf("\n"); echo tsprintf("\n");

View file

@ -108,7 +108,7 @@ final class ArcanistMercurialLandEngine
$marker_type)); $marker_type));
foreach ($named_markers as $named_marker) { foreach ($named_markers as $named_marker) {
echo tsprintf('%s', $named_marker->newDisplayRef()); echo tsprintf('%s', $named_marker->newRefView());
} }
echo tsprintf("\n"); echo tsprintf("\n");
@ -327,7 +327,7 @@ final class ArcanistMercurialLandEngine
pht('These branches were selected:')); pht('These branches were selected:'));
foreach ($branches as $branch) { foreach ($branches as $branch) {
echo tsprintf('%s', $branch->newDisplayRef()); echo tsprintf('%s', $branch->newRefView());
} }
echo tsprintf("\n"); echo tsprintf("\n");
@ -352,7 +352,7 @@ final class ArcanistMercurialLandEngine
foreach ($new_markers as $new_marker) { foreach ($new_markers as $new_marker) {
echo tsprintf('%s', $new_marker->newDisplayRef()); echo tsprintf('%s', $new_marker->newRefView());
} }
echo tsprintf("\n"); echo tsprintf("\n");

View file

@ -1,8 +0,0 @@
<?php
interface ArcanistDisplayRefInterface {
public function getDisplayRefObjectName();
public function getDisplayRefTitle();
}

View file

@ -5,8 +5,17 @@ abstract class ArcanistRef
abstract public function getRefDisplayName(); abstract public function getRefDisplayName();
final public function newDisplayRef() { final public function newRefView() {
return id(new ArcanistDisplayRef()) $ref_view = id(new ArcanistRefView())
->setRef($this); ->setRef($this);
$this->buildRefView($ref_view);
return $ref_view;
} }
protected function buildRefView(ArcanistRefView $view) {
return null;
}
} }

View file

@ -1,13 +1,16 @@
<?php <?php
final class ArcanistDisplayRef final class ArcanistRefView
extends Phobject extends Phobject
implements implements
ArcanistTerminalStringInterface { ArcanistTerminalStringInterface {
private $objectName;
private $title;
private $ref; private $ref;
private $uri; private $uri;
private $lines = array(); private $lines = array();
private $children = array();
public function setRef(ArcanistRef $ref) { public function setRef(ArcanistRef $ref) {
$this->ref = $ref; $this->ref = $ref;
@ -18,6 +21,24 @@ final class ArcanistDisplayRef
return $this->ref; return $this->ref;
} }
public function setObjectName($object_name) {
$this->objectName = $object_name;
return $this;
}
public function getObjectName() {
return $this->objectName;
}
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function getTitle() {
return $this->title;
}
public function setURI($uri) { public function setURI($uri) {
$this->uri = $uri; $this->uri = $uri;
return $this; return $this;
@ -27,21 +48,29 @@ final class ArcanistDisplayRef
return $this->uri; return $this->uri;
} }
public function addChild(ArcanistRefView $view) {
$this->children[] = $view;
return $this;
}
private function getChildren() {
return $this->children;
}
public function appendLine($line) { public function appendLine($line) {
$this->lines[] = $line; $this->lines[] = $line;
return $this; return $this;
} }
public function newTerminalString() { public function newTerminalString() {
return $this->newLines(0);
}
private function newLines($indent) {
$ref = $this->getRef(); $ref = $this->getRef();
if ($ref instanceof ArcanistDisplayRefInterface) { $object_name = $this->getObjectName();
$object_name = $ref->getDisplayRefObjectName(); $title = $this->getTitle();
$title = $ref->getDisplayRefTitle();
} else {
$object_name = null;
$title = $ref->getRefDisplayName();
}
if ($object_name !== null) { if ($object_name !== null) {
$reserve_width = phutil_utf8_console_strlen($object_name) + 1; $reserve_width = phutil_utf8_console_strlen($object_name) + 1;
@ -49,10 +78,18 @@ final class ArcanistDisplayRef
$reserve_width = 0; $reserve_width = 0;
} }
if ($indent) {
$indent_text = str_repeat(' ', $indent);
} else {
$indent_text = '';
}
$indent_width = strlen($indent_text);
$marker_width = 6; $marker_width = 6;
$display_width = phutil_console_get_terminal_width(); $display_width = phutil_console_get_terminal_width();
$usable_width = ($display_width - $marker_width - $reserve_width); $usable_width = ($display_width - $marker_width - $reserve_width);
$usable_width = ($usable_width - $indent_width);
// If the terminal is extremely narrow, don't degrade so much that the // If the terminal is extremely narrow, don't degrade so much that the
// output is completely unusable. // output is completely unusable.
@ -75,22 +112,32 @@ final class ArcanistDisplayRef
$display_text = $title; $display_text = $title;
} }
$ref = $this->getRef();
$output = array(); $output = array();
$output[] = tsprintf( $output[] = tsprintf(
"<bg:cyan>** * **</bg> %s\n", "<bg:cyan>** * **</bg> %s%s\n",
$indent_text,
$display_text); $display_text);
$uri = $this->getURI(); $uri = $this->getURI();
if ($uri !== null) { if ($uri !== null) {
$output[] = tsprintf( $output[] = tsprintf(
"<bg:cyan>** :// **</bg> __%s__\n", "<bg:cyan>** :// **</bg> %s__%s__\n",
$indent_text,
$uri); $uri);
} }
foreach ($this->lines as $line) { foreach ($this->lines as $line) {
$output[] = tsprintf(" %s\n", $line); $output[] = tsprintf(
" %s%s\n",
$indent_text,
$line);
}
foreach ($this->getChildren() as $child) {
foreach ($child->newLines($indent + 1) as $line) {
$output[] = $line;
}
} }
return $output; return $output;

View file

@ -1,9 +1,7 @@
<?php <?php
final class ArcanistBuildRef final class ArcanistBuildRef
extends ArcanistRef extends ArcanistRef {
implements
ArcanistDisplayRefInterface {
const HARDPOINT_BUILDPLANREF = 'ref.build.buildplanRef'; const HARDPOINT_BUILDPLANREF = 'ref.build.buildplanRef';
@ -16,7 +14,7 @@ final class ArcanistBuildRef
} }
public function getRefDisplayName() { public function getRefDisplayName() {
return $this->getDisplayRefObjectName(); return pht('Build %d', $this->getID());
} }
public static function newFromConduit(array $parameters) { public static function newFromConduit(array $parameters) {
@ -37,12 +35,10 @@ final class ArcanistBuildRef
return idxv($this->parameters, array('fields', 'name')); return idxv($this->parameters, array('fields', 'name'));
} }
public function getDisplayRefObjectName() { protected function buildRefView(ArcanistRefView $view) {
return pht('Build %d', $this->getID()); $view
} ->setObjectName($this->getRefDisplayName())
->setTitle($this->getName());
public function getDisplayRefTitle() {
return $this->getName();
} }
public function getBuildPlanRef() { public function getBuildPlanRef() {

View file

@ -1,9 +1,7 @@
<?php <?php
final class ArcanistBuildableRef final class ArcanistBuildableRef
extends ArcanistRef extends ArcanistRef {
implements
ArcanistDisplayRefInterface {
const HARDPOINT_BUILDREFS = 'ref.buildable.buildRefs'; const HARDPOINT_BUILDREFS = 'ref.buildable.buildRefs';
@ -44,12 +42,10 @@ final class ArcanistBuildableRef
return 'B'.$this->getID(); return 'B'.$this->getID();
} }
public function getDisplayRefObjectName() { protected function buildRefView(ArcanistRefView $view) {
return $this->getMonogram(); $view
} ->setObjectName($this->getMonogram())
->setTitle($this->getRefDisplayName());
public function getDisplayRefTitle() {
return pht('Buildable %d', $this->getID());
} }
public function getBuildRefs() { public function getBuildRefs() {

View file

@ -1,14 +1,12 @@
<?php <?php
final class ArcanistBuildPlanRef final class ArcanistBuildPlanRef
extends ArcanistRef extends ArcanistRef {
implements
ArcanistDisplayRefInterface {
private $parameters; private $parameters;
public function getRefDisplayName() { public function getRefDisplayName() {
return $this->getDisplayRefObjectName(); return pht('Build Plan %d', $this->getID());
} }
public static function newFromConduit(array $parameters) { public static function newFromConduit(array $parameters) {
@ -29,14 +27,6 @@ final class ArcanistBuildPlanRef
return idxv($this->parameters, array('fields', 'name')); return idxv($this->parameters, array('fields', 'name'));
} }
public function getDisplayRefObjectName() {
return pht('Build Plan %d', $this->getID());
}
public function getDisplayRefTitle() {
return $this->getName();
}
public function getBehavior($behavior_key, $default = null) { public function getBehavior($behavior_key, $default = null) {
return idxv( return idxv(
$this->parameters, $this->parameters,
@ -44,4 +34,10 @@ final class ArcanistBuildPlanRef
$default); $default);
} }
protected function buildRefView(ArcanistRefView $view) {
$view
->setObjectName($this->getRefDisplayName())
->setTitle($this->getName());
}
} }

View file

@ -1,9 +1,7 @@
<?php <?php
final class ArcanistFileRef final class ArcanistFileRef
extends ArcanistRef extends ArcanistRef {
implements
ArcanistDisplayRefInterface {
private $parameters; private $parameters;
@ -51,12 +49,10 @@ final class ArcanistFileRef
return 'F'.$this->getID(); return 'F'.$this->getID();
} }
public function getDisplayRefObjectName() { protected function buildRefView(ArcanistRefView $view) {
return $this->getMonogram(); $view
} ->setObjectName($this->getMonogram())
->setTitle($this->getName());
public function getDisplayRefTitle() {
return $this->getName();
} }
} }

View file

@ -1,9 +1,7 @@
<?php <?php
final class ArcanistPasteRef final class ArcanistPasteRef
extends ArcanistRef extends ArcanistRef {
implements
ArcanistDisplayRefInterface {
private $parameters; private $parameters;
@ -47,12 +45,10 @@ final class ArcanistPasteRef
return 'P'.$this->getID(); return 'P'.$this->getID();
} }
public function getDisplayRefObjectName() { protected function buildRefView(ArcanistRefView $view) {
return $this->getMonogram(); $view
} ->setObjectName($this->getMonogram())
->setTitle($this->getName());
public function getDisplayRefTitle() {
return $this->getTitle();
} }
} }

View file

@ -1,9 +1,7 @@
<?php <?php
final class ArcanistRevisionRef final class ArcanistRevisionRef
extends ArcanistRef extends ArcanistRef {
implements
ArcanistDisplayRefInterface {
const HARDPOINT_COMMITMESSAGE = 'ref.revision.commitmessage'; const HARDPOINT_COMMITMESSAGE = 'ref.revision.commitmessage';
const HARDPOINT_AUTHORREF = 'ref.revision.authorRef'; const HARDPOINT_AUTHORREF = 'ref.revision.authorRef';
@ -167,12 +165,10 @@ final class ArcanistRevisionRef
return $this->getHardpoint(self::HARDPOINT_BUILDABLEREF); return $this->getHardpoint(self::HARDPOINT_BUILDABLEREF);
} }
public function getDisplayRefObjectName() { protected function buildRefView(ArcanistRefView $view) {
return $this->getMonogram(); $view
} ->setObjectName($this->getMonogram())
->setTitle($this->getTitle());
public function getDisplayRefTitle() {
return $this->getName();
} }
} }

View file

@ -1,9 +1,7 @@
<?php <?php
final class ArcanistTaskRef final class ArcanistTaskRef
extends ArcanistRef extends ArcanistRef {
implements
ArcanistDisplayRefInterface {
private $parameters; private $parameters;
@ -33,12 +31,10 @@ final class ArcanistTaskRef
return 'T'.$this->getID(); return 'T'.$this->getID();
} }
public function getDisplayRefObjectName() { protected function buildRefView(ArcanistRefView $view) {
return $this->getMonogram(); $view
} ->setObjectName($this->getMonogram())
->setTitle($this->getName());
public function getDisplayRefTitle() {
return $this->getName();
} }
} }

View file

@ -1,9 +1,7 @@
<?php <?php
final class ArcanistUserRef final class ArcanistUserRef
extends ArcanistRef extends ArcanistRef {
implements
ArcanistDisplayRefInterface {
private $parameters; private $parameters;
@ -49,18 +47,16 @@ final class ArcanistUserRef
return idxv($this->parameters, array('fields', 'realName')); return idxv($this->parameters, array('fields', 'realName'));
} }
public function getDisplayRefObjectName() { protected function buildRefView(ArcanistRefView $view) {
return $this->getMonogram();
}
public function getDisplayRefTitle() {
$real_name = $this->getRealName(); $real_name = $this->getRealName();
if (strlen($real_name)) { if (strlen($real_name)) {
$real_name = sprintf('(%s)', $real_name); $real_name = sprintf('(%s)', $real_name);
} }
return $real_name; $view
->setObjectName($this->getMonogram())
->setTitle($real_name);
} }
} }

View file

@ -1,9 +1,7 @@
<?php <?php
final class ArcanistMarkerRef final class ArcanistMarkerRef
extends ArcanistRef extends ArcanistRef {
implements
ArcanistDisplayRefInterface {
const HARDPOINT_COMMITREF = 'arc.marker.commitRef'; const HARDPOINT_COMMITREF = 'arc.marker.commitRef';
const HARDPOINT_WORKINGCOPYSTATEREF = 'arc.marker.workingCopyStateRef'; const HARDPOINT_WORKINGCOPYSTATEREF = 'arc.marker.workingCopyStateRef';
@ -24,10 +22,6 @@ final class ArcanistMarkerRef
private $isActive = false; private $isActive = false;
public function getRefDisplayName() { public function getRefDisplayName() {
return $this->getDisplayRefObjectName();
}
public function getDisplayRefObjectName() {
switch ($this->getMarkerType()) { switch ($this->getMarkerType()) {
case self::TYPE_BRANCH: case self::TYPE_BRANCH:
return pht('Branch "%s"', $this->getName()); return pht('Branch "%s"', $this->getName());
@ -38,13 +32,6 @@ final class ArcanistMarkerRef
} }
} }
public function getDisplayRefTitle() {
return pht(
'%s %s',
$this->getDisplayHash(),
$this->getSummary());
}
protected function newHardpoints() { protected function newHardpoints() {
return array( return array(
$this->newHardpoint(self::HARDPOINT_COMMITREF), $this->newHardpoint(self::HARDPOINT_COMMITREF),
@ -98,8 +85,6 @@ final class ArcanistMarkerRef
return $this->displayHash; return $this->displayHash;
} }
public function setCommitHash($commit_hash) { public function setCommitHash($commit_hash) {
$this->commitHash = $commit_hash; $this->commitHash = $commit_hash;
return $this; return $this;
@ -177,4 +162,15 @@ final class ArcanistMarkerRef
return $this->getHardpoint(self::HARDPOINT_REMOTEREF); return $this->getHardpoint(self::HARDPOINT_REMOTEREF);
} }
protected function buildRefView(ArcanistRefView $view) {
$title = pht(
'%s %s',
$this->getDisplayHash(),
$this->getSummary());
$view
->setObjectName($this->getRefDisplayName())
->setTitle($title);
}
} }

View file

@ -163,7 +163,7 @@ abstract class ArcanistWorkEngine
$revision_ref->getMonogram())); $revision_ref->getMonogram()));
foreach ($selected as $marker) { foreach ($selected as $marker) {
echo tsprintf('%s', $marker->newDisplayRef()); echo tsprintf('%s', $marker->newRefView());
} }
echo tsprintf("\n"); echo tsprintf("\n");
@ -177,7 +177,7 @@ abstract class ArcanistWorkEngine
pht('REVISION'), pht('REVISION'),
pht('Resuming work on revision:')); pht('Resuming work on revision:'));
echo tsprintf('%s', $revision_ref->newDisplayRef()); echo tsprintf('%s', $revision_ref->newRefView());
echo tsprintf("\n"); echo tsprintf("\n");
return $target; return $target;

View file

@ -108,7 +108,7 @@ EOTEXT
echo tsprintf( echo tsprintf(
"%s\n\n%s\n", "%s\n\n%s\n",
pht('Amending commit message to reflect revision:'), pht('Amending commit message to reflect revision:'),
$revision_ref->newDisplayRef()); $revision_ref->newRefView());
$this->confirmAmendAuthor($revision_ref); $this->confirmAmendAuthor($revision_ref);
$this->confirmAmendNotFound($revision_ref, $state_ref); $this->confirmAmendNotFound($revision_ref, $state_ref);
@ -193,7 +193,7 @@ EOTEXT
"%!\n%W\n\n%B\n", "%!\n%W\n\n%B\n",
pht('MULTIPLE REVISIONS IN WORKING COPY'), pht('MULTIPLE REVISIONS IN WORKING COPY'),
pht('More than one revision was found in the working copy:'), pht('More than one revision was found in the working copy:'),
mpull($revisions, 'newDisplayRef')); mpull($revisions, 'newRefView'));
throw new PhutilArgumentUsageException( throw new PhutilArgumentUsageException(
pht( pht(
@ -233,7 +233,7 @@ EOTEXT
'The author of this revision (%s) is:', 'The author of this revision (%s) is:',
$revision_ref->getMonogram()), $revision_ref->getMonogram()),
), ),
$author_ref->newDisplayRef()); $author_ref->newRefView());
$prompt = pht( $prompt = pht(
'Amend working copy using revision owned by %s?', 'Amend working copy using revision owned by %s?',

View file

@ -159,7 +159,7 @@ EOTEXT
echo tsprintf( echo tsprintf(
'%s', '%s',
$paste_ref->newDisplayRef() $paste_ref->newRefView()
->setURI($uri)); ->setURI($uri));
if ($is_browse) { if ($is_browse) {

View file

@ -119,7 +119,7 @@ EOTEXT
$uri = $this->getAbsoluteURI($uri); $uri = $this->getAbsoluteURI($uri);
echo tsprintf( echo tsprintf(
'%s', '%s',
$ref->newDisplayRef() $ref->newRefView()
->setURI($uri)); ->setURI($uri));
} }
} }