Page MenuHomePhabricator

D21025.diff
No OneTemporary

D21025.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -346,7 +346,6 @@
'ArcanistParseStrUseXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistParseStrUseXHPASTLinterRuleTestCase.php',
'ArcanistPasteWorkflow' => 'workflow/ArcanistPasteWorkflow.php',
'ArcanistPatchWorkflow' => 'workflow/ArcanistPatchWorkflow.php',
- 'ArcanistPhageToolset' => 'toolset/ArcanistPhageToolset.php',
'ArcanistPhpLinter' => 'lint/linter/ArcanistPhpLinter.php',
'ArcanistPhpLinterTestCase' => 'lint/linter/__tests__/ArcanistPhpLinterTestCase.php',
'ArcanistPhpcsLinter' => 'lint/linter/ArcanistPhpcsLinter.php',
@@ -544,6 +543,7 @@
'PhagePHPAgent' => 'phage/agent/PhagePHPAgent.php',
'PhagePHPAgentBootloader' => 'phage/bootloader/PhagePHPAgentBootloader.php',
'PhagePlanAction' => 'phage/action/PhagePlanAction.php',
+ 'PhageToolset' => 'phage/toolset/PhageToolset.php',
'PhageWorkflow' => 'phage/workflow/PhageWorkflow.php',
'Phobject' => 'object/Phobject.php',
'PhobjectTestCase' => 'object/__tests__/PhobjectTestCase.php',
@@ -1288,7 +1288,6 @@
'ArcanistParseStrUseXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistPasteWorkflow' => 'ArcanistWorkflow',
'ArcanistPatchWorkflow' => 'ArcanistWorkflow',
- 'ArcanistPhageToolset' => 'ArcanistToolset',
'ArcanistPhpLinter' => 'ArcanistExternalLinter',
'ArcanistPhpLinterTestCase' => 'ArcanistExternalLinterTestCase',
'ArcanistPhpcsLinter' => 'ArcanistExternalLinter',
@@ -1491,7 +1490,8 @@
'PhagePHPAgent' => 'Phobject',
'PhagePHPAgentBootloader' => 'PhageAgentBootloader',
'PhagePlanAction' => 'PhageAction',
- 'PhageWorkflow' => 'PhutilArgumentWorkflow',
+ 'PhageToolset' => 'ArcanistToolset',
+ 'PhageWorkflow' => 'ArcanistWorkflow',
'Phobject' => 'Iterator',
'PhobjectTestCase' => 'PhutilTestCase',
'PhpunitTestEngine' => 'ArcanistUnitTestEngine',
diff --git a/src/phage/toolset/PhageToolset.php b/src/phage/toolset/PhageToolset.php
new file mode 100644
--- /dev/null
+++ b/src/phage/toolset/PhageToolset.php
@@ -0,0 +1,7 @@
+<?php
+
+final class PhageToolset extends ArcanistToolset {
+
+ const TOOLSETKEY = 'phage';
+
+}
diff --git a/src/phage/workflow/PhageWorkflow.php b/src/phage/workflow/PhageWorkflow.php
--- a/src/phage/workflow/PhageWorkflow.php
+++ b/src/phage/workflow/PhageWorkflow.php
@@ -1,10 +1,11 @@
<?php
abstract class PhageWorkflow
- extends PhutilArgumentWorkflow {
+ extends ArcanistWorkflow {
- public function isExecutable() {
- return true;
+ public function supportsToolset(ArcanistToolset $toolset) {
+ $key = $toolset->getToolsetKey();
+ return ($key === PhageToolset::TOOLSETKEY);
}
}
diff --git a/src/runtime/ArcanistRuntime.php b/src/runtime/ArcanistRuntime.php
--- a/src/runtime/ArcanistRuntime.php
+++ b/src/runtime/ArcanistRuntime.php
@@ -92,7 +92,7 @@
$config_engine = $this->loadConfiguration($args);
$config = $config_engine->newConfigurationSourceList();
- $this->loadLibraries($args, $config);
+ $this->loadLibraries($config_engine, $config, $args);
// Now that we've loaded libraries, we can validate configuration.
// Do this before continuing since configuration can impact other
@@ -300,91 +300,70 @@
}
private function loadLibraries(
- PhutilArgumentParser $args,
- ArcanistConfigurationSourceList $config) {
+ ArcanistConfigurationEngine $engine,
+ ArcanistConfigurationSourceList $config,
+ PhutilArgumentParser $args) {
- // TOOLSETS: Make this work again -- or replace it entirely with package
- // management?
- return;
-
- $is_trace = $args->getArg('trace');
-
- $load = array();
- $working_copy = $this->getWorkingCopy();
+ $sources = array();
$cli_libraries = $args->getArg('library');
if ($cli_libraries) {
- $load[] = array(
- '--library',
- $cli_libraries,
- );
- } else {
- $system_config = $config->readSystemArcConfig();
- $load[] = array(
- $config->getSystemArcConfigLocation(),
- idx($system_config, 'load', array()),
- );
-
- $global_config = $config->readUserArcConfig();
- $load[] = array(
- $config->getUserConfigurationFileLocation(),
- idx($global_config, 'load', array()),
- );
-
- $load[] = array(
- '.arcconfig',
- $working_copy->getProjectConfig('load'),
- );
-
- $load[] = array(
- // TODO: We could explain exactly where this is coming from more
- // clearly.
- './.../arc/config',
- $working_copy->getLocalConfig('load'),
- );
-
- $load[] = array(
- '--config load=...',
- $config->getRuntimeConfig('load', array()),
- );
- }
-
- foreach ($load as $spec) {
- list($source, $libraries) = $spec;
- if ($is_trace) {
- $this->logTrace(
- pht('LOAD'),
- pht(
- 'Loading libraries from "%s"...',
- $source));
+ $sources = array();
+ foreach ($cli_libraries as $cli_library) {
+ $sources[] = array(
+ 'type' => 'flag',
+ 'library-source' => $cli_library,
+ );
}
-
- if (!$libraries) {
- if ($is_trace) {
- $this->logTrace(pht('NONE'), pht('Nothing to load.'));
+ } else {
+ $items = $config->getStorageValueList('load');
+ foreach ($items as $item) {
+ foreach ($item->getValue() as $library_path) {
+ $sources[] = array(
+ 'type' => 'config',
+ 'config-source' => $item->getConfigurationSource(),
+ 'library-source' => $library_path,
+ );
}
- continue;
}
+ }
- if (!is_array($libraries)) {
- throw new PhutilArgumentUsageException(
- pht(
- 'Libraries specified by "%s" are not formatted correctly. '.
- 'Expected a list of paths. Check your configuration.',
- $source));
- }
+ foreach ($sources as $spec) {
+ $library_source = $spec['library-source'];
- foreach ($libraries as $library) {
- $this->loadLibrary($source, $library, $working_copy, $is_trace);
+ switch ($spec['type']) {
+ case 'flag':
+ $description = pht('runtime --library flag');
+ break;
+ case 'config':
+ $config_source = $spec['config-source'];
+ $description = pht(
+ 'Configuration (%s)',
+ $config_source->getSourceDisplayName());
+ break;
}
+
+ $this->loadLibrary($engine, $library_source, $description);
}
}
private function loadLibrary(
- $source,
+ ArcanistConfigurationEngine $engine,
$location,
- ArcanistWorkingCopyIdentity $working_copy,
- $is_trace) {
+ $description) {
+
+ // TODO: This is a legacy system that should be replaced with package
+ // management.
+
+ $log = $this->getLogEngine();
+ $working_copy = $engine->getWorkingCopy();
+ if ($working_copy) {
+ $working_copy_root = $working_copy->getPath();
+ $working_directory = $working_copy->getWorkingDirectory();
+ } else {
+ $working_copy_root = null;
+ $working_directory = getcwd();
+ }
// Try to resolve the library location. We look in several places, in
// order:
@@ -406,30 +385,44 @@
// Check inside the working copy. This also checks absolute paths, since
// they'll resolve absolute and just ignore the project root.
- $resolved_location = Filesystem::resolvePath(
- $location,
- $working_copy->getProjectRoot());
- if (Filesystem::pathExists($resolved_location)) {
- $location = $resolved_location;
- $resolved = true;
+ if ($working_copy_root !== null) {
+ $resolved_location = Filesystem::resolvePath(
+ $location,
+ $working_copy_root);
+ if (Filesystem::pathExists($resolved_location)) {
+ $location = $resolved_location;
+ $resolved = true;
+ }
+
+ // If we didn't find anything, check alongside the working copy.
+ if (!$resolved) {
+ $resolved_location = Filesystem::resolvePath(
+ $location,
+ dirname($working_copy_root));
+ if (Filesystem::pathExists($resolved_location)) {
+ $location = $resolved_location;
+ $resolved = true;
+ }
+ }
}
- // If we didn't find anything, check alongside the working copy.
+ // Look beside "arcanist/". This is rule (3) above.
+
if (!$resolved) {
+ $arcanist_root = phutil_get_library_root('arcanist');
+ $arcanist_root = dirname($arcanist_root);
$resolved_location = Filesystem::resolvePath(
$location,
- dirname($working_copy->getProjectRoot()));
+ $arcanist_root);
if (Filesystem::pathExists($resolved_location)) {
$location = $resolved_location;
$resolved = true;
}
}
- if ($is_trace) {
- $this->logTrace(
- pht('LOAD'),
- pht('Loading phutil library from "%s"...', $location));
- }
+ $log->writeTrace(
+ pht('LOAD'),
+ pht('Loading library from "%s"...', $location));
$error = null;
try {
@@ -445,7 +438,7 @@
'is specified by "%s". Check that the setting is correct and '.
'the library is located in the right place.',
$location,
- $source)));
+ $description)));
$prompt = pht('Continue without loading library?');
if (!phutil_console_confirm($prompt)) {
diff --git a/src/toolset/ArcanistPhageToolset.php b/src/toolset/ArcanistPhageToolset.php
deleted file mode 100644
--- a/src/toolset/ArcanistPhageToolset.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-
-final class ArcanistPhageToolset extends ArcanistToolset {
-
- const TOOLSETKEY = 'phage';
-
-
-}

File Metadata

Mime Type
text/plain
Expires
Aug 28 2025, 10:20 PM (6 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
8758212
Default Alt Text
D21025.diff (9 KB)

Event Timeline