]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Arcanist / Conduit - stop using deprecated diffusion.getcommits
authorBob Trahan <btrahan@phacility.com>
Tue, 3 Feb 2015 22:33:06 +0000 (14:33 -0800)
committerBob Trahan <btrahan@phacility.com>
Tue, 3 Feb 2015 22:33:06 +0000 (14:33 -0800)
Summary: Fixes T7113. This one was a bit trickier than others as the API output changed a bit. In particular, there is no "errors" emitted so much as the result set just doesn't include the answer if things are garbage. Ergo, check the "identifier map" to either check for diff existence or to lookup the phid to grab the actual diff data from the "data" part of the result.

Test Plan: called `arc backout D11665` and got some working output...!

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7113

Differential Revision: https://secure.phabricator.com/D11667

src/workflow/ArcanistBackoutWorkflow.php
src/workflow/ArcanistWorkflow.php

index 57e3c22211cabea96716999dc5c0e2488489311c..f4667a352ce853eb52febb3c6edbb0e06a733924 100644 (file)
@@ -88,15 +88,16 @@ EOTEXT
    */
   private function getDiffusionCommit($commit_id) {
     $result = $this->getConduit()->callMethodSynchronous(
-      'diffusion.getcommits',
+      'diffusion.querycommits',
       array(
-        'commits' => array($commit_id),
+        'names' => array($commit_id),
       ));
-    $commit = $result[$commit_id];
+    $phid = idx($result['identifierMap'], $commit_id);
     // This commit was not found in Diffusion
-    if (array_key_exists('error', $commit)) {
+    if (!$phid) {
       return null;
     }
+    $commit = $result['data'][$phid];
     return $commit;
   }
 
@@ -157,7 +158,7 @@ EOTEXT
       $revision_id = $matches[1];
       $commit_id = $this->getCommitIDFromRevisionID($revision_id);
       $commit = $this->getDiffusionCommit($commit_id);
-      $commit_hash = $commit['commitIdentifier'];
+      $commit_hash = $commit['identifier'];
       // Convert commit hash from SVN to Git/HG (for FB case)
       if ($is_git_svn || $is_hg_svn) {
         $commit_hash = $repository_api->
index 5aedab7d9fb60a5f553b86cc9b7cd3c213c1a3e1..4944d7028e86a1b9877027b5be2cbf17b2da0bf4 100644 (file)
@@ -1008,10 +1008,12 @@ abstract class ArcanistWorkflow extends Phobject {
     $repository = $this->loadProjectRepository();
     if ($repository) {
       $callsign = $repository['callsign'];
-      $known_commits = $this->getConduit()->callMethodSynchronous(
-        'diffusion.getcommits',
-        array('commits' => array('r'.$callsign.$commit['commit'])));
-      if (ifilter($known_commits, 'error', $negate = true)) {
+      $commit_name = 'r'.$callsign.$commit['commit'];
+      $result = $this->getConduit()->callMethodSynchronous(
+        'diffusion.querycommits',
+        array('names' => array($commit_name)));
+      $known_commit = idx($result['identifierMap'], $commit_name);
+      if (!$known_commit) {
         return false;
       }
     }