Page MenuHomePhabricator

D21718.diff
No OneTemporary

D21718.diff

diff --git a/src/moduleutils/PhutilLibraryMapBuilder.php b/src/moduleutils/PhutilLibraryMapBuilder.php
--- a/src/moduleutils/PhutilLibraryMapBuilder.php
+++ b/src/moduleutils/PhutilLibraryMapBuilder.php
@@ -12,7 +12,6 @@
final class PhutilLibraryMapBuilder extends Phobject {
private $root;
- private $quiet = true;
private $subprocessLimit = 8;
private $fileSymbolMap;
@@ -38,19 +37,6 @@
$this->root = $root;
}
- /**
- * Control status output. Use `--quiet` to set this.
- *
- * @param bool If true, don't show status output.
- * @return this
- *
- * @task map
- */
- public function setQuiet($quiet) {
- $this->quiet = $quiet;
- return $this;
- }
-
/**
* Control subprocess parallelism limit. Use `--limit` to set this.
*
@@ -108,25 +94,9 @@
public function buildAndWriteMap() {
$library_map = $this->buildMap();
- $this->log(pht('Writing map...'));
$this->writeLibraryMap($library_map);
}
- /**
- * Write a status message to the user, if not running in quiet mode.
- *
- * @param string Message to write.
- * @return this
- *
- * @task map
- */
- private function log($message) {
- if (!$this->quiet) {
- @fwrite(STDERR, "%s\n", $message);
- }
- return $this;
- }
-
/* -( Path Management )---------------------------------------------------- */
@@ -236,11 +206,7 @@
}
$json = json_encode($cache);
- try {
- Filesystem::writeFile($cache_file, $json);
- } catch (FilesystemException $ex) {
- $this->log(pht('Unable to save the cache!'));
- }
+ Filesystem::writeFile($cache_file, $json);
}
/**
@@ -251,7 +217,6 @@
* @task symbol
*/
public function dropSymbolCache() {
- $this->log(pht('Dropping symbol cache...'));
Filesystem::remove($this->getPathForSymbolCache());
}
@@ -451,14 +416,10 @@
*/
private function analyzeLibrary() {
// Identify all the ".php" source files in the library.
- $this->log(pht('Finding source files...'));
$source_map = $this->loadSourceFileMap();
- $this->log(
- pht('Found %s files.', new PhutilNumber(count($source_map))));
// Load the symbol cache with existing parsed symbols. This allows us
// to remap libraries quickly by analyzing only changed files.
- $this->log(pht('Loading symbol cache...'));
$symbol_cache = $this->loadSymbolCache();
// If the XHPAST binary is not up-to-date, build it now. Otherwise,
@@ -481,23 +442,12 @@
}
$futures[$file] = $this->buildSymbolAnalysisFuture($file);
}
- $this->log(
- pht('Found %s files in cache.', new PhutilNumber(count($symbol_map))));
// Run the analyzer on any files which need analysis.
if ($futures) {
$limit = $this->subprocessLimit;
- $this->log(
- pht(
- 'Analyzing %s file(s) with %s subprocess(es)...',
- phutil_count($futures),
- new PhutilNumber($limit)));
-
$progress = new PhutilConsoleProgressBar();
- if ($this->quiet) {
- $progress->setQuiet(true);
- }
$progress->setTotal(count($futures));
$futures = id(new FutureIterator($futures))
@@ -525,8 +475,6 @@
$this->writeSymbolCache($symbol_map, $source_map);
// Our map is up to date, so either show it on stdout or write it to disk.
- $this->log(pht('Building library map...'));
-
$this->librarySymbolMap = $this->buildLibraryMap($symbol_map);
}
diff --git a/src/workflow/ArcanistLiberateWorkflow.php b/src/workflow/ArcanistLiberateWorkflow.php
--- a/src/workflow/ArcanistLiberateWorkflow.php
+++ b/src/workflow/ArcanistLiberateWorkflow.php
@@ -79,22 +79,35 @@
);
}
+ $any_errors = false;
foreach ($paths as $path) {
$log->writeStatus(
pht('WORK'),
pht(
'Updating library: %s',
Filesystem::readablePath($path).DIRECTORY_SEPARATOR));
- $this->liberatePath($path);
+ $exit_code = $this->liberatePath($path);
+ if ($exit_code !== 0) {
+ $any_errors = true;
+ $log->writeError(
+ pht('ERROR'),
+ pht('Failed to update library: %s', $path));
+ }
}
- $log->writeSuccess(
- pht('DONE'),
- pht('Updated %s librarie(s).', phutil_count($paths)));
+ if (!$any_errors) {
+ $log->writeSuccess(
+ pht('DONE'),
+ pht('Updated %s librarie(s).', phutil_count($paths)));
+ }
return 0;
}
+ /**
+ * @return int The exit code of running the rebuild-map.php script, which
+ * will be 0 to indicate success or non-zero for failure.
+ */
private function liberatePath($path) {
if (!Filesystem::pathExists($path.'/__phutil_library_init__.php')) {
echo tsprintf(
@@ -103,8 +116,7 @@
'No library currently exists at the path "%s"...',
$path));
$this->liberateCreateDirectory($path);
- $this->liberateCreateLibrary($path);
- return;
+ return $this->liberateCreateLibrary($path);
}
$version = $this->getLibraryFormatVersion($path);
@@ -119,8 +131,6 @@
throw new ArcanistUsageException(
pht("Unknown library version '%s'!", $version));
}
-
- echo tsprintf("%s\n", pht('Done.'));
}
private function getLibraryFormatVersion($path) {
@@ -140,6 +150,10 @@
return 1;
}
+ /**
+ * @return int The exit code of running the rebuild-map.php script, which
+ * will be 0 to indicate success or non-zero for failure.
+ */
private function liberateVersion2($path) {
$bin = $this->getScriptPath('support/lib/rebuild-map.php');
@@ -181,10 +195,14 @@
execx('mkdir -p %R', $path);
}
+ /**
+ * @return int The exit code of running the rebuild-map.php script, which
+ * will be 0 to indicate success or non-zero for failure.
+ */
private function liberateCreateLibrary($path) {
$init_path = $path.'/__phutil_library_init__.php';
if (Filesystem::pathExists($init_path)) {
- return;
+ return 0;
}
echo pht("Creating new libphutil library in '%s'.", $path)."\n";
@@ -213,7 +231,7 @@
'__phutil_library_init__.php',
$path);
Filesystem::writeFile($init_path, $template);
- $this->liberateVersion2($path);
+ return $this->liberateVersion2($path);
}
diff --git a/support/lib/rebuild-map.php b/support/lib/rebuild-map.php
--- a/support/lib/rebuild-map.php
+++ b/support/lib/rebuild-map.php
@@ -16,10 +16,6 @@
$args->parseStandardArguments();
$args->parse(
array(
- array(
- 'name' => 'quiet',
- 'help' => pht('Do not write status messages to stderr.'),
- ),
array(
'name' => 'drop-cache',
'help' => pht(
@@ -56,7 +52,6 @@
$root = Filesystem::resolvePath(head($root));
$builder = new PhutilLibraryMapBuilder($root);
-$builder->setQuiet($args->getArg('quiet'));
$builder->setSubprocessLimit($args->getArg('limit'));
if ($args->getArg('drop-cache')) {

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 22, 9:57 AM (9 h, 21 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7029461
Default Alt Text
D21718.diff (6 KB)

Event Timeline