mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Performance improvements for linting in an HG repo.
Summary: Run `hg status` as a Future while getting the diff. Add a cache for getRawDiffText(). Test Plan: Run `arc lint --trace` on a HG repo and confirm that `diff` is only called once and `status` is run in the background. Reviewers: epriestley Reviewed By: epriestley CC: yliang, dpepper, aran, Korvin Maniphest Tasks: T2016 Differential Revision: https://secure.phabricator.com/D3913
This commit is contained in:
parent
ac92f9bdfc
commit
0a6444790d
1 changed files with 13 additions and 1 deletions
|
@ -14,6 +14,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
|||
private $workingCopyRevision;
|
||||
private $localCommitInfo;
|
||||
private $includeDirectoryStateInDiffs;
|
||||
private $rawDiffCache = array();
|
||||
|
||||
protected function buildLocalFuture(array $argv) {
|
||||
|
||||
|
@ -278,6 +279,10 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
|||
// there is no way to get file change status across multiple commits, so
|
||||
// just take the entire diff and parse it to figure out what's changed.
|
||||
|
||||
// Execute status in the background
|
||||
$status_future = $this->buildLocalFuture(array('status'));
|
||||
$status_future->start();
|
||||
|
||||
$diff = $this->getFullMercurialDiff();
|
||||
|
||||
if (!$diff) {
|
||||
|
@ -311,7 +316,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
|||
$status_map[$change->getCurrentPath()] = $flags;
|
||||
}
|
||||
|
||||
list($stdout) = $this->execxLocal('status');
|
||||
list($stdout) = $status_future->resolvex();
|
||||
|
||||
$working_status = ArcanistMercurialParser::parseMercurialStatus($stdout);
|
||||
foreach ($working_status as $path => $status) {
|
||||
|
@ -354,12 +359,19 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
|||
$range .= '...';
|
||||
}
|
||||
|
||||
$raw_diff_cache_key = $options.' '.$range.' '.$path;
|
||||
if (idx($this->rawDiffCache, $raw_diff_cache_key)) {
|
||||
return idx($this->rawDiffCache, $raw_diff_cache_key);
|
||||
}
|
||||
|
||||
list($stdout) = $this->execxLocal(
|
||||
'diff %C --rev %s -- %s',
|
||||
$options,
|
||||
$range,
|
||||
$path);
|
||||
|
||||
$this->rawDiffCache[$raw_diff_cache_key] = $stdout;
|
||||
|
||||
return $stdout;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue