コード例 #1
0
 /**
  * For the advanced case where you want customized configuration handling.
  *
  * Reads the configuration from all available sources, returning a map (array)
  * of results, with the source as key. Missing values will not be in the map,
  * so an empty array will be returned if no results are found.
  *
  * The map is ordered by the canonical sources precedence, which is:
  * runtime > local > project > user > system
  *
  * @param key   Key to read
  * @return array Mapping of source => value read. Sources with no value are
  *               not in the array.
  *
  * @task config
  */
 public function getConfigFromAllSources($key)
 {
     $results = array();
     $settings = new ArcanistSettings();
     $pval = idx($this->runtimeConfig, $key);
     if ($pval !== null) {
         $results[self::CONFIG_SOURCE_RUNTIME] = $settings->willReadValue($key, $pval);
     }
     $pval = $this->getLocalConfig($key);
     if ($pval !== null) {
         $results[self::CONFIG_SOURCE_LOCAL] = $settings->willReadValue($key, $pval);
     }
     $pval = $this->getProjectConfig($key);
     if ($pval !== null) {
         $results[self::CONFIG_SOURCE_PROJECT] = $settings->willReadValue($key, $pval);
     }
     $user_config = $this->readUserArcConfig();
     $pval = idx($user_config, $key);
     if ($pval !== null) {
         $results[self::CONFIG_SOURCE_USER] = $settings->willReadValue($key, $pval);
     }
     $system_config = $this->readSystemArcConfig();
     $pval = idx($system_config, $key);
     if ($pval !== null) {
         $results[self::CONFIG_SOURCE_SYSTEM] = $settings->willReadValue($key, $pval);
     }
     $default_config = $this->readDefaultConfig();
     if (array_key_exists($key, $default_config)) {
         $results[self::CONFIG_SOURCE_DEFAULT] = $default_config[$key];
     }
     return $results;
 }
コード例 #2
0
 /**
  * For the advanced case where you want customized configuration handling.
  *
  * Reads the configuration from all available sources, returning a map (array)
  * of results, with the source as key. Missing values will not be in the map,
  * so an empty array will be returned if no results are found.
  *
  * The map is ordered by the canonical sources precedence, which is:
  * runtime > local > project > user > system
  *
  * @param key   Key to read
  * @return array Mapping of source => value read. Sources with no value are
  *               not in the array.
  *
  * @task config
  */
 public function getConfigFromAllSources($key)
 {
     $results = array();
     $settings = new ArcanistSettings();
     $pval = idx($this->runtimeConfig, $key);
     if ($pval !== null) {
         $results[self::CONFIG_SOURCE_RUNTIME] = $settings->willReadValue($key, $pval);
     }
     $pval = $this->getLocalConfig($key);
     if ($pval !== null) {
         $results[self::CONFIG_SOURCE_LOCAL] = $settings->willReadValue($key, $pval);
     }
     $pval = $this->getProjectConfig($key);
     if ($pval !== null) {
         $results[self::CONFIG_SOURCE_PROJECT] = $settings->willReadValue($key, $pval);
     }
     $user_config = $this->readUserArcConfig();
     // For "aliases" coming from the user config file specifically, read the
     // top level "aliases" key instead of the "aliases" key inside the "config"
     // setting. Aliases were originally user-specific but later became standard
     // configuration, which is why this works oddly.
     if ($key === 'aliases') {
         $pval = idx($this->readUserConfigurationFile(), $key);
     } else {
         $pval = idx($user_config, $key);
     }
     if ($pval !== null) {
         $results[self::CONFIG_SOURCE_USER] = $settings->willReadValue($key, $pval);
     }
     $system_config = $this->readSystemArcConfig();
     $pval = idx($system_config, $key);
     if ($pval !== null) {
         $results[self::CONFIG_SOURCE_SYSTEM] = $settings->willReadValue($key, $pval);
     }
     $default_config = $this->readDefaultConfig();
     if (array_key_exists($key, $default_config)) {
         $results[self::CONFIG_SOURCE_DEFAULT] = $default_config[$key];
     }
     return $results;
 }
コード例 #3
0
 /**
  * Read a configuration directive from project configuration. This reads ONLY
  * permanent project configuration (i.e., ".arcconfig"), not other
  * configuration sources. See @{method:getConfigFromAnySource} to read from
  * user configuration.
  *
  * @param key   Key to read.
  * @param wild  Default value if key is not found.
  * @return wild Value, or default value if not found.
  *
  * @task config
  */
 public function getProjectConfig($key, $default = null)
 {
     $settings = new ArcanistSettings();
     $pval = idx($this->projectConfig, $key);
     // Test for older names in the per-project config only, since
     // they've only been used there.
     if ($pval === null) {
         $legacy = $settings->getLegacyName($key);
         if ($legacy) {
             $pval = $this->getProjectConfig($legacy);
         }
     }
     if ($pval === null) {
         $pval = $default;
     } else {
         $pval = $settings->willReadValue($key, $pval);
     }
     return $pval;
 }
コード例 #4
0
 /**
  * Read a configuration directive from any available configuration source.
  * In contrast to @{method:getConfig}, this will look for the directive in
  * local and user configuration in addition to project configuration.
  * The precedence is local > project > user
  *
  * @param key   Key to read.
  * @param wild  Default value if key is not found.
  * @return wild Value, or default value if not found.
  *
  * @task config
  */
 public function getConfigFromAnySource($key, $default = null)
 {
     $settings = new ArcanistSettings();
     // try runtime config first
     $pval = idx($this->runtimeConfig, $key);
     // try local config
     if ($pval === null) {
         $pval = $this->getLocalConfig($key);
     }
     // then per-project config
     if ($pval === null) {
         $pval = $this->getConfig($key);
     }
     // now try global (i.e. user-level) config
     if ($pval === null) {
         $global_config = ArcanistBaseWorkflow::readGlobalArcConfig();
         $pval = idx($global_config, $key);
     }
     // Finally, try system-level config.
     if ($pval === null) {
         $system_config = ArcanistBaseWorkflow::readSystemArcConfig();
         $pval = idx($system_config, $key);
     }
     if ($pval === null) {
         $pval = $default;
     } else {
         $pval = $settings->willReadValue($key, $pval);
     }
     return $pval;
 }