diff --git a/src/browse/workflow/ArcanistBrowseWorkflow.php b/src/browse/workflow/ArcanistBrowseWorkflow.php index 7346ed14..85143353 100644 --- a/src/browse/workflow/ArcanistBrowseWorkflow.php +++ b/src/browse/workflow/ArcanistBrowseWorkflow.php @@ -233,7 +233,24 @@ EOTEXT } $ref_uri = head($ref_uris); - $uris[] = $ref_uri->getURI(); + + // TODO: "ArcanistRevisionRef", at least, may return a relative URI. + // If we get a relative URI, guess the correct absolute URI based on + // the Conduit URI. This might not be correct for Conduit over SSH. + + $raw_uri = $ref_uri->getURI(); + + $raw_uri = new PhutilURI($raw_uri); + if (!strlen($raw_uri->getDomain())) { + $base_uri = $this->getConduitEngine() + ->getConduitURI(); + + $raw_uri = id(new PhutilURI($base_uri)) + ->setPath($raw_uri->getPath()); + } + $raw_uri = phutil_string_cast($raw_uri); + + $uris[] = $raw_uri; } $this->openURIsInBrowser($uris); diff --git a/src/query/ArcanistGitWorkingCopyRevisionHardpointQuery.php b/src/query/ArcanistGitWorkingCopyRevisionHardpointQuery.php index 065e8d57..044843d7 100644 --- a/src/query/ArcanistGitWorkingCopyRevisionHardpointQuery.php +++ b/src/query/ArcanistGitWorkingCopyRevisionHardpointQuery.php @@ -60,7 +60,7 @@ final class ArcanistGitWorkingCopyRevisionHardpointQuery continue; } - $revision_ref = ArcanistRevisionRef::newFromConduit($dict); + $revision_ref = ArcanistRevisionRef::newFromConduitQuery($dict); foreach ($revision_hashes as $revision_hash) { $hash_key = $this->getHashKey($revision_hash); $state_refs = idx($map, $hash_key, array()); diff --git a/src/query/ArcanistMessageRevisionHardpointQuery.php b/src/query/ArcanistMessageRevisionHardpointQuery.php index 284558ee..d2076ed3 100644 --- a/src/query/ArcanistMessageRevisionHardpointQuery.php +++ b/src/query/ArcanistMessageRevisionHardpointQuery.php @@ -53,8 +53,8 @@ final class ArcanistMessageRevisionHardpointQuery $results = array(); if ($map) { - $revisions = (yield $this->yieldConduit( - 'differential.query', + $revisions = (yield $this->yieldConduitSearch( + 'differential.revision.search', array( 'ids' => array_keys($map), ))); diff --git a/src/ref/revision/ArcanistRevisionRef.php b/src/ref/revision/ArcanistRevisionRef.php index 07618bbc..96b05d45 100644 --- a/src/ref/revision/ArcanistRevisionRef.php +++ b/src/ref/revision/ArcanistRevisionRef.php @@ -26,28 +26,59 @@ final class ArcanistRevisionRef return $ref; } + public static function newFromConduitQuery(array $dict) { + // Mangle an older "differential.query" result to look like a modern + // "differential.revision.search" result. + + $status_name = idx($dict, 'statusName'); + + switch ($status_name) { + case 'Abandoned': + case 'Closed': + $is_closed = true; + break; + default: + $is_closed = false; + break; + } + + $dict['fields'] = array( + 'uri' => idx($dict, 'uri'), + 'title' => idx($dict, 'title'), + 'authorPHID' => idx($dict, 'authorPHID'), + 'status' => array( + 'name' => $status_name, + 'closed' => $is_closed, + ), + ); + + return self::newFromConduit($dict); + } + public function getMonogram() { return 'D'.$this->getID(); } public function getStatusDisplayName() { - return idx($this->parameters, 'statusName'); + return idxv($this->parameters, array('fields', 'status', 'name')); } public function isClosed() { - // TODO: This should use sensible constants, not English language - // display text. - switch ($this->getStatusDisplayName()) { - case 'Abandoned': - case 'Closed': - return true; - } - - return false; + return idxv($this->parameters, array('fields', 'status', 'closed')); } public function getURI() { - return idx($this->parameters, 'uri'); + $uri = idxv($this->parameters, array('fields', 'uri')); + + if ($uri === null) { + // TODO: The "uri" field was added at the same time as this callsite, + // so we may not have it yet if the server is running an older version + // of Phabricator. Fake our way through. + + $uri = '/'.$this->getMonogram(); + } + + return $uri; } public function getFullName() { @@ -63,11 +94,11 @@ final class ArcanistRevisionRef } public function getName() { - return idx($this->parameters, 'title'); + return idxv($this->parameters, array('fields', 'title')); } public function getAuthorPHID() { - return idx($this->parameters, 'authorPHID'); + return idxv($this->parameters, array('fields', 'authorPHID')); } public function addSource(ArcanistRevisionRefSource $source) { diff --git a/src/ref/revision/ArcanistRevisionSymbolHardpointQuery.php b/src/ref/revision/ArcanistRevisionSymbolHardpointQuery.php index e722b710..34942a1f 100644 --- a/src/ref/revision/ArcanistRevisionSymbolHardpointQuery.php +++ b/src/ref/revision/ArcanistRevisionSymbolHardpointQuery.php @@ -17,10 +17,10 @@ final class ArcanistRevisionSymbolHardpointQuery $id_map = mpull($refs, 'getSymbol'); $id_set = array_fuse($id_map); - $revisions = (yield $this->yieldConduit( - 'differential.query', + $revisions = (yield $this->yieldConduitSearch( + 'differential.revision.search', array( - 'ids' => $id_set, + 'ids' => array_values($id_set), ))); $refs = array(); diff --git a/src/workflow/ArcanistLiberateWorkflow.php b/src/workflow/ArcanistLiberateWorkflow.php index 9a18caef..c8aa224f 100644 --- a/src/workflow/ArcanistLiberateWorkflow.php +++ b/src/workflow/ArcanistLiberateWorkflow.php @@ -33,6 +33,16 @@ EOTEXT ); } + protected function newPrompts() { + return array( + $this->newPrompt('arc.liberate.create') + ->setDescription( + pht( + 'Confirms creation of a new library.')), + ); + } + + public function runWorkflow() { $log = $this->getLogEngine(); @@ -154,10 +164,18 @@ EOTEXT return; } - echo pht("The directory '%s' does not exist.", $path); - if (!phutil_console_confirm(pht('Do you want to create it?'))) { - throw new ArcanistUsageException(pht('Cancelled.')); - } + echo tsprintf( + "%!\n%W\n", + pht('NEW LIBRARY'), + pht( + 'The directory "%s" does not exist. Do you want to create it?', + $path)); + + $query = pht('Create new library?'); + + $this->getPrompt('arc.liberate.create') + ->setQuery($query) + ->execute(); execx('mkdir -p %R', $path); } diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php index 271c4c1f..6e7dec14 100644 --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -2140,7 +2140,7 @@ abstract class ArcanistWorkflow extends Phobject { 'Failed to open URI "%s" in browser ("%s"). '. 'Check your "browser" config option.', $uri, - $browser)); + implode(' ', $browser))); } } }