Example #1
0
$load = $args->getArg('load-phutil-library');
$argv = $args->getUnconsumedArgumentVector();
$args = array_values($argv);
$working_directory = getcwd();
$console = PhutilConsole::getConsole();
try {
    if ($config_trace_mode) {
        $phutil_location = phutil_get_library_root('phutil');
        $arcanist_location = phutil_get_library_root('arcanist');
        $console->writeErr("libphutil loaded from '{$phutil_location}'.\n");
        $console->writeErr("arcanist loaded from '{$arcanist_location}'.\n");
    }
    if (!$args) {
        throw new ArcanistUsageException("No command provided. Try 'arc help'.");
    }
    $global_config = ArcanistBaseWorkflow::readGlobalArcConfig();
    $system_config = ArcanistBaseWorkflow::readSystemArcConfig();
    $working_copy = ArcanistWorkingCopyIdentity::newFromPath($working_directory);
    // Load additional libraries, which can provide new classes like configuration
    // overrides, linters and lint engines, unit test engines, etc.
    // If the user specified "--load-phutil-library" one or more times from
    // the command line, we load those libraries **instead** of whatever else
    // is configured. This is basically a debugging feature to let you force
    // specific libraries to load regardless of the state of the world.
    if ($load) {
        // Load the flag libraries. These must load, since the user specified them
        // explicitly.
        arcanist_load_libraries($load, $must_load = true, $lib_source = 'a "--load-phutil-library" flag', $working_copy, $config_trace_mode);
    } else {
        // Load libraries in system 'load' config. In contrast to global config, we
        // fail hard here because this file is edited manually, so if 'arc' breaks
 public function resolveBaseCommit()
 {
     $working_copy = $this->getWorkingCopyIdentity();
     $global_config = ArcanistBaseWorkflow::readGlobalArcConfig();
     $system_config = ArcanistBaseWorkflow::readSystemArcConfig();
     $parser = new ArcanistBaseCommitParser($this);
     $commit = $parser->resolveBaseCommit(array('args' => $this->getBaseCommitArgumentRules(), 'local' => $working_copy->getLocalConfig('base', ''), 'project' => $working_copy->getConfig('base', ''), 'global' => idx($global_config, 'base', ''), 'system' => idx($system_config, 'base', '')));
     return $commit;
 }
 /**
  * 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)
 {
     // try local config first
     $pval = $this->getLocalConfig($key);
     // then per-project config
     if ($pval === null) {
         $pval = $this->getConfig($key);
     }
     // Test for older names in the per-project config only, since
     // they've only been used there
     static $deprecated_names = array('lint.engine' => 'lint_engine', 'unit.engine' => 'unit_engine');
     if ($pval === null && isset($deprecated_names[$key])) {
         $pval = $this->getConfig($deprecated_names[$key]);
     }
     // lastly, try global (i.e. user-level) config
     if ($pval === null) {
         $global_config = ArcanistBaseWorkflow::readGlobalArcConfig();
         $pval = idx($global_config, $key);
     }
     if ($pval === null) {
         $system_config = ArcanistBaseWorkflow::readSystemArcConfig();
         $pval = idx($system_config, $key);
     }
     if ($pval === null) {
         $pval = $default;
     }
     return $pval;
 }
 /**
  * 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;
 }