From 721bdf424bf33692ffe338b67e38072b742c92bb Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 30 Dec 2014 23:14:32 +1100 Subject: [PATCH] Use `new FutureIterator` instead of `Futures` Summary: Ref T6829. Deprecate the `Futures()` function. Test Plan: N/A Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: aurelijus, Korvin, epriestley Maniphest Tasks: T6829 Differential Revision: https://secure.phabricator.com/D11079 --- src/lint/linter/ArcanistCSharpLinter.php | 4 +++- src/lint/linter/ArcanistFutureLinter.php | 2 +- .../linter/ArcanistScriptAndRegexLinter.php | 4 +++- src/repository/api/ArcanistGitAPI.php | 2 +- src/repository/api/ArcanistMercurialAPI.php | 4 +++- src/unit/engine/NoseTestEngine.php | 4 +++- src/unit/engine/PhpunitTestEngine.php | 4 +++- src/unit/engine/XUnitTestEngine.php | 6 ++++-- src/workflow/ArcanistDiffWorkflow.php | 17 ++++++++++++----- src/workflow/ArcanistFeatureWorkflow.php | 6 ++++-- .../ArcanistGitHookPreReceiveWorkflow.php | 3 ++- 11 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/lint/linter/ArcanistCSharpLinter.php b/src/lint/linter/ArcanistCSharpLinter.php index 6f0206cd..c43bde4b 100644 --- a/src/lint/linter/ArcanistCSharpLinter.php +++ b/src/lint/linter/ArcanistCSharpLinter.php @@ -184,7 +184,9 @@ final class ArcanistCSharpLinter extends ArcanistLinter { public function didRunLinters() { if ($this->futures) { - foreach (Futures($this->futures)->limit(8) as $future) { + $futures = id(new FutureIterator($this->futures)) + ->limit(8); + foreach ($futures as $future) { $this->resolveFuture($future); } } diff --git a/src/lint/linter/ArcanistFutureLinter.php b/src/lint/linter/ArcanistFutureLinter.php index 30105c70..1adeb43f 100644 --- a/src/lint/linter/ArcanistFutureLinter.php +++ b/src/lint/linter/ArcanistFutureLinter.php @@ -13,7 +13,7 @@ abstract class ArcanistFutureLinter extends ArcanistLinter { final public function willLintPaths(array $paths) { $limit = $this->getFuturesLimit(); - $this->futures = Futures(array())->limit($limit); + $this->futures = id(new FutureIterator(array()))->limit($limit); foreach ($this->buildFutures($paths) as $path => $future) { $this->futures->addFuture($future, $path); } diff --git a/src/lint/linter/ArcanistScriptAndRegexLinter.php b/src/lint/linter/ArcanistScriptAndRegexLinter.php index d048cfd4..f2df82ec 100644 --- a/src/lint/linter/ArcanistScriptAndRegexLinter.php +++ b/src/lint/linter/ArcanistScriptAndRegexLinter.php @@ -187,7 +187,9 @@ final class ArcanistScriptAndRegexLinter extends ArcanistLinter { $futures[$path] = $future; } - foreach (Futures($futures)->limit(4) as $path => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(4); + foreach ($futures as $path => $future) { list($stdout) = $future->resolvex(); $this->output[$path] = $stdout; } diff --git a/src/repository/api/ArcanistGitAPI.php b/src/repository/api/ArcanistGitAPI.php index 11a36742..15850c6b 100644 --- a/src/repository/api/ArcanistGitAPI.php +++ b/src/repository/api/ArcanistGitAPI.php @@ -609,7 +609,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI { // After the other commands exit, we can start the `diff-files` command. ); - Futures($futures)->resolveAll(); + id(new FutureIterator($futures))->resolveAll(); // We're clear to start the `git diff-files` now. $unstaged_future->start(); diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index 0bd6e60d..a186513b 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -284,7 +284,9 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { $last_node = $node; } - foreach (Futures($futures)->limit(4) as $node => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(4); + foreach ($futures as $node => $future) { list($parents) = $future->resolvex(); $parents = array_filter(explode("\n", $parents)); $commits[$node]['parents'] = $parents; diff --git a/src/unit/engine/NoseTestEngine.php b/src/unit/engine/NoseTestEngine.php index db87deee..c5c95e3e 100644 --- a/src/unit/engine/NoseTestEngine.php +++ b/src/unit/engine/NoseTestEngine.php @@ -59,7 +59,9 @@ final class NoseTestEngine extends ArcanistUnitTestEngine { } $results = array(); - foreach (Futures($futures)->limit(4) as $test_path => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(4); + foreach ($futures as $test_path => $future) { try { list($stdout, $stderr) = $future->resolvex(); } catch(CommandException $exc) { diff --git a/src/unit/engine/PhpunitTestEngine.php b/src/unit/engine/PhpunitTestEngine.php index 82438631..ca541783 100644 --- a/src/unit/engine/PhpunitTestEngine.php +++ b/src/unit/engine/PhpunitTestEngine.php @@ -73,7 +73,9 @@ final class PhpunitTestEngine extends ArcanistUnitTestEngine { } $results = array(); - foreach (Futures($futures)->limit(4) as $test => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(4); + foreach ($futures as $test => $future) { list($err, $stdout, $stderr) = $future->resolve(); diff --git a/src/unit/engine/XUnitTestEngine.php b/src/unit/engine/XUnitTestEngine.php index 947a0dad..1824b5b8 100644 --- a/src/unit/engine/XUnitTestEngine.php +++ b/src/unit/engine/XUnitTestEngine.php @@ -277,7 +277,7 @@ class XUnitTestEngine extends ArcanistUnitTestEngine { dirname($test_assembly['project']))); $build_futures[$test_assembly['project']] = $build_future; } - $iterator = Futures($build_futures)->limit(1); + $iterator = id(new FutureIterator($build_futures))->limit(1); foreach ($iterator as $test_assembly => $future) { $result = new ArcanistUnitTestResult(); $result->setName('(build) '.$test_assembly); @@ -353,7 +353,9 @@ class XUnitTestEngine extends ArcanistUnitTestEngine { } // Run all of the tests. - foreach (Futures($futures)->limit(8) as $test_assembly => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(8); + foreach ($futures as $test_assembly => $future) { list($err, $stdout, $stderr) = $future->resolve(); if (file_exists($outputs[$test_assembly])) { diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index b2dd8ffc..0ca5944c 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -1135,7 +1135,9 @@ EOTEXT $targets[] = array('command' => 'info', 'path' => $path); } - foreach (Futures($futures)->limit(8) as $key => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(8); + foreach ($futures as $key => $future) { $target = $targets[$key]; if ($target['command'] == 'diff') { $repository_api->primeSVNDiffResult( @@ -1774,7 +1776,7 @@ EOTEXT )); } - foreach (Futures($futures) as $key => $future) { + foreach (new FutureIterator($futures) as $key => $future) { $result = $future->resolve(); switch ($key) { case 'revision': @@ -2393,7 +2395,8 @@ EOTEXT * @task diffprop */ private function resolveDiffPropertyUpdates() { - Futures($this->diffPropertyFutures)->resolveAll(); + id(new FutureIterator($this->diffPropertyFutures)) + ->resolveAll(); $this->diffPropertyFutures = array(); } @@ -2522,7 +2525,9 @@ EOTEXT )); } - foreach (Futures($hash_futures)->limit(8) as $key => $future) { + $futures = id(new FutureIterator($hash_futures)) + ->limit(8); + foreach ($futures as $key => $future) { $type = $need_upload[$key]['type']; $change = $need_upload[$key]['change']; $name = $need_upload[$key]['name']; @@ -2553,7 +2558,9 @@ EOTEXT )); } - foreach (Futures($upload_futures)->limit(4) as $key => $future) { + $futures = id(new FutureIterator($upload_futures)) + ->limit(4); + foreach ($futures as $key => $future) { $type = $need_upload[$key]['type']; $change = $need_upload[$key]['change']; $name = $need_upload[$key]['name']; diff --git a/src/workflow/ArcanistFeatureWorkflow.php b/src/workflow/ArcanistFeatureWorkflow.php index 4ffb4662..e8d501f4 100644 --- a/src/workflow/ArcanistFeatureWorkflow.php +++ b/src/workflow/ArcanistFeatureWorkflow.php @@ -191,7 +191,9 @@ EOTEXT $branches = ipull($branches, null, 'name'); - foreach (Futures($futures)->limit(16) as $name => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(16); + foreach ($futures as $name => $future) { list($info) = $future->resolvex(); list($hash, $epoch, $tree, $desc, $text) = explode("\1", trim($info), 5); @@ -250,7 +252,7 @@ EOTEXT } $results = array(); - foreach (Futures($calls) as $call) { + foreach (new FutureIterator($calls) as $call) { $results[] = $call->resolve(); } diff --git a/src/workflow/ArcanistGitHookPreReceiveWorkflow.php b/src/workflow/ArcanistGitHookPreReceiveWorkflow.php index ba9d706c..d1d4f78f 100644 --- a/src/workflow/ArcanistGitHookPreReceiveWorkflow.php +++ b/src/workflow/ArcanistGitHookPreReceiveWorkflow.php @@ -113,7 +113,8 @@ EOTEXT )); } - Futures($futures)->resolveAll(); + id(new FutureIterator($futures)) + ->resolveAll(); return 0; }