mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-22 21:40:54 +01:00
Upgrade (most) Differential API callsites to "differential.revision.search"
Summary: Ref T13490. The "RevisionRef" is currently based on "differential.query" data, but all calls other than the hash-based lookup can move to "differential.revision.search". Test Plan: Ran revision workflows like `arc inspect` and `arc browse`. Maniphest Tasks: T13490 Differential Revision: https://secure.phabricator.com/D21099
This commit is contained in:
parent
ab589ab31d
commit
4719341c27
7 changed files with 91 additions and 25 deletions
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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),
|
||||
)));
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue