public static function newAPIFromConfigurationManager(ArcanistConfigurationManager $configuration_manager) { $working_copy = $configuration_manager->getWorkingCopyIdentity(); if (!$working_copy) { throw new Exception(pht('Trying to create a %s without a working copy!', __CLASS__)); } $root = $working_copy->getProjectRoot(); switch ($working_copy->getVCSType()) { case 'svn': $api = new ArcanistSubversionAPI($root); break; case 'hg': $api = new ArcanistMercurialAPI($root); break; case 'git': $api = new ArcanistGitAPI($root); break; default: throw new Exception(pht('The current working directory is not part of a working copy for ' . 'a supported version control system (Git, Subversion or ' . 'Mercurial).')); } $api->configurationManager = $configuration_manager; return $api; }