]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Remove call to "arcanist.projectinfo" from ArcanistWorkflow
authorJoshua Spence <josh@joshuaspence.com>
Mon, 25 May 2015 12:04:50 +0000 (22:04 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Mon, 25 May 2015 12:04:50 +0000 (22:04 +1000)
Summary: Ref T7604. Remove call to the `arcanist.projectinfo` #conduit endpoint from `ArcanistWorkflow`. Depends on D12992.

Test Plan: Ran `arc which` and verified that repository information was present.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley

Maniphest Tasks: T7604

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

src/workflow/ArcanistWorkflow.php

index ed05b743ce602542c6bcc824cda32ffd92d17ee3..3873e4f462386a29ee12cec65c1d29be84618a64 100644 (file)
@@ -1527,58 +1527,14 @@ abstract class ArcanistWorkflow extends Phobject {
   }
 
   final protected function getRepositoryEncoding() {
-    $default = 'UTF-8';
-    return nonempty(idx($this->getProjectInfo(), 'encoding'), $default);
-  }
-
-  final protected function getProjectInfo() {
-    if ($this->projectInfo === null) {
-      $project_id = $this->getWorkingCopy()->getProjectID();
-      if (!$project_id) {
-        $this->projectInfo = array();
-      } else {
-        try {
-          $this->projectInfo = $this->getConduit()->callMethodSynchronous(
-            'arcanist.projectinfo',
-            array(
-              'name' => $project_id,
-            ));
-        } catch (ConduitClientException $ex) {
-          if ($ex->getErrorCode() != 'ERR-BAD-ARCANIST-PROJECT') {
-            throw $ex;
-          }
-
-          // TODO: Implement a proper query method that doesn't throw on
-          // project not found. We just swallow this because some pathways,
-          // like Git with uncommitted changes in a repository with a new
-          // project ID, may attempt to access project information before
-          // the project is created. See T2153.
-          return array();
-        }
-      }
-    }
-
-    return $this->projectInfo;
+    return nonempty(
+      idx($this->loadProjectRepository(), 'encoding'),
+      'UTF-8');
   }
 
   final protected function loadProjectRepository() {
-    $project = $this->getProjectInfo();
-    if (isset($project['repository'])) {
-      return $project['repository'];
-    }
-    // NOTE: The rest of the code is here for backwards compatibility.
-
-    $repository_phid = idx($project, 'repositoryPHID');
-    if (!$repository_phid) {
-      return array();
-    }
-
-    $repositories = $this->getConduit()->callMethodSynchronous(
-      'repository.query',
-      array());
-    $repositories = ipull($repositories, null, 'phid');
-
-    return idx($repositories, $repository_phid, array());
+    list($info, $reasons) = $this->loadRepositoryInformation();
+    return $info;
   }
 
   final protected function newInteractiveEditor($text) {
@@ -1812,40 +1768,6 @@ abstract class ArcanistWorkflow extends Phobject {
         'repository.callsign');
     }
 
-    $project_info = $this->getProjectInfo();
-    $project_name = $this->getWorkingCopy()->getProjectID();
-    if ($this->getProjectInfo()) {
-      if (!empty($project_info['repository']['callsign'])) {
-        $callsign = $project_info['repository']['callsign'];
-        $query = array(
-          'callsigns' => array($callsign),
-        );
-        $reasons[] = pht(
-          'Configuration value "%s" is set to "%s"; this project '.
-          'is associated with the "%s" repository.',
-          'project.name',
-          $project_name,
-          $callsign);
-        return array($query, $reasons);
-      } else {
-        $reasons[] = pht(
-          'Configuration value "%s" is set to "%s", but this '.
-          'project is not associated with a repository.',
-          'project.name',
-          $project_name);
-      }
-    } else if (strlen($project_name)) {
-      $reasons[] = pht(
-        'Configuration value "%s" is set to "%s", but that '.
-        'project does not exist.',
-        'project.name',
-        $project_name);
-    } else {
-      $reasons[] = pht(
-        'Configuration value "%s" is empty.',
-        'project.name');
-    }
-
     $uuid = $this->getRepositoryAPI()->getRepositoryUUID();
     if ($uuid !== null) {
       $query = array(