mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-29 18:22:41 +01:00
Speedup arc branch
Summary: This reduces time of `arc branch` from 13s to 7s in my repo which is faster than `git branch --verbose` (10s). The price for this speedup is that we loose the information [ahead 1, behind 21242] but we showed it only in branches with no revision so it's not a big deal. Test Plan: $ arc branch Reviewers: epriestley Reviewed By: epriestley CC: ahupp, aran, Korvin Differential Revision: https://secure.phabricator.com/D3005
This commit is contained in:
parent
9997dd7830
commit
cd2f8edb83
2 changed files with 27 additions and 21 deletions
|
@ -641,7 +641,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
*/
|
*/
|
||||||
public function getAllBranches() {
|
public function getAllBranches() {
|
||||||
list($branch_info) = $this->execxLocal(
|
list($branch_info) = $this->execxLocal(
|
||||||
'branch --verbose --abbrev=40 --no-color');
|
'branch --no-color');
|
||||||
$lines = explode("\n", rtrim($branch_info));
|
$lines = explode("\n", rtrim($branch_info));
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
@ -653,12 +653,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($current, $name, $hash, $desc) = preg_split('/\s+/', $line, 4);
|
list($current, $name) = preg_split('/\s+/', $line, 2);
|
||||||
$result[] = array(
|
$result[] = array(
|
||||||
'current' => !empty($current),
|
'current' => !empty($current),
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'hash' => $hash,
|
|
||||||
'desc' => $desc,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,10 +83,7 @@ EOTEXT
|
||||||
throw new ArcanistUsageException('No branches in this working copy.');
|
throw new ArcanistUsageException('No branches in this working copy.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$commit_map = $this->loadCommitInfo($branches, $repository_api);
|
$branches = $this->loadCommitInfo($branches, $repository_api);
|
||||||
foreach ($branches as $key => $branch) {
|
|
||||||
$branches[$key] += $commit_map[$branch['hash']];
|
|
||||||
}
|
|
||||||
|
|
||||||
$revisions = $this->loadRevisions($branches);
|
$revisions = $this->loadRevisions($branches);
|
||||||
|
|
||||||
|
@ -99,33 +96,44 @@ EOTEXT
|
||||||
array $branches,
|
array $branches,
|
||||||
ArcanistRepositoryAPI $repository_api) {
|
ArcanistRepositoryAPI $repository_api) {
|
||||||
|
|
||||||
// NOTE: "-s" is an option deep in git's diff argument parser that doesn't
|
$futures = array();
|
||||||
// seem to have much documentation and has no long form. It suppresses any
|
foreach ($branches as $branch) {
|
||||||
// diff output.
|
// NOTE: "-s" is an option deep in git's diff argument parser that doesn't
|
||||||
|
// seem to have much documentation and has no long form. It suppresses any
|
||||||
|
// diff output.
|
||||||
|
$futures[$branch['name']] = $repository_api->execFutureLocal(
|
||||||
|
'show -s --format=%C %s',
|
||||||
|
'%H%x01%ct%x01%T%x01%s%x01%b',
|
||||||
|
$branch['name']);
|
||||||
|
}
|
||||||
|
|
||||||
$commits = ipull($branches, 'hash');
|
$branches = ipull($branches, null, 'name');
|
||||||
list($info) = $repository_api->execxLocal(
|
|
||||||
'show -s --format=%C %Ls',
|
|
||||||
'%H%x01%ct%x01%T%x01%s%n%b%x02',
|
|
||||||
$commits);
|
|
||||||
|
|
||||||
$commit_map = array();
|
$commit_map = array();
|
||||||
|
foreach (Futures($futures) as $name => $future) {
|
||||||
|
list($info) = $future->resolvex();
|
||||||
|
list($hash, $epoch, $tree, $desc, $text) = explode("\1", trim($info), 5);
|
||||||
|
|
||||||
|
$branch = $branches[$name];
|
||||||
|
$branch['hash'] = $hash;
|
||||||
|
$branch['desc'] = $desc;
|
||||||
|
|
||||||
$info = array_filter(explode("\2", trim($info)));
|
|
||||||
foreach ($info as $line) {
|
|
||||||
list($hash, $epoch, $tree, $text) = explode("\1", trim($line), 4);
|
|
||||||
try {
|
try {
|
||||||
|
$text = $desc."\n".$text;
|
||||||
$message = ArcanistDifferentialCommitMessage::newFromRawCorpus($text);
|
$message = ArcanistDifferentialCommitMessage::newFromRawCorpus($text);
|
||||||
$id = $message->getRevisionID();
|
$id = $message->getRevisionID();
|
||||||
|
|
||||||
$commit_map[$hash] = array(
|
$branch += array(
|
||||||
'epoch' => (int)$epoch,
|
'epoch' => (int)$epoch,
|
||||||
'tree' => $tree,
|
'tree' => $tree,
|
||||||
'revisionID' => $id,
|
'revisionID' => $id,
|
||||||
);
|
);
|
||||||
} catch (ArcanistUsageException $ex) {
|
} catch (ArcanistUsageException $ex) {
|
||||||
// In case of invalid commit message which fails the parsing, do noting.
|
// In case of invalid commit message which fails the parsing,
|
||||||
|
// do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$commit_map[$hash] = $branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $commit_map;
|
return $commit_map;
|
||||||
|
|
Loading…
Reference in a new issue