Changeset View
Changeset View
Standalone View
Standalone View
src/repository/api/ArcanistMercurialAPI.php
Show First 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | if ($this->localCommitInfo === null) { | ||||
$futures = array(); | $futures = array(); | ||||
$commits = array(); | $commits = array(); | ||||
foreach ($logs as $log) { | foreach ($logs as $log) { | ||||
list($node, $rev, $full_author, $date, $branch, $tag, | list($node, $rev, $full_author, $date, $branch, $tag, | ||||
$parents, $desc) = explode("\1", $log, 9); | $parents, $desc) = explode("\1", $log, 9); | ||||
list($author, $author_email) = $this->parseFullAuthor($full_author); | list($author, $author_email) = $this->parseFullAuthor($full_author); | ||||
$co_authors = array(); | |||||
// NOTE: If a commit has only one parent, {parents} returns empty. | // NOTE: If a commit has only one parent, {parents} returns empty. | ||||
// If it has two parents, {parents} returns revs and short hashes, not | // If it has two parents, {parents} returns revs and short hashes, not | ||||
// full hashes. Try to avoid making calls to "hg parents" because it's | // full hashes. Try to avoid making calls to "hg parents" because it's | ||||
// relatively expensive. | // relatively expensive. | ||||
$commit_parents = null; | $commit_parents = null; | ||||
if (!$parents) { | if (!$parents) { | ||||
if ($last_node) { | if ($last_node) { | ||||
$commit_parents = array($last_node); | $commit_parents = array($last_node); | ||||
} | } | ||||
} | } | ||||
if (!$commit_parents) { | if (!$commit_parents) { | ||||
// We didn't get a cheap hit on previous commit, so do the full-cost | // We didn't get a cheap hit on previous commit, so do the full-cost | ||||
// "hg parents" call. We can run these in parallel, at least. | // "hg parents" call. We can run these in parallel, at least. | ||||
$futures[$node] = $this->execFutureLocal( | $futures[$node] = $this->execFutureLocal( | ||||
'parents --template %s --rev %s', | 'parents --template %s --rev %s', | ||||
'{node}\n', | '{node}\n', | ||||
$node); | $node); | ||||
} | } | ||||
foreach (explode("\n", $desc) as $line) { | |||||
if (strncasecmp($line, 'Co-authored-by:', 15) !== 0) { | |||||
continue; | |||||
} | |||||
$matches = array(); | |||||
$status = preg_match( | |||||
'/^co-authored-by:\s*(.*)<(.*)>/i', | |||||
$line, | |||||
$matches); | |||||
if ($status !== 1) { | |||||
continue; | |||||
} | |||||
$co_authors[] = array( | |||||
'name' => $matches[1], | |||||
'email' => $matches[2], | |||||
); | |||||
} | |||||
$commits[$node] = array( | $commits[$node] = array( | ||||
'author' => $author, | 'author' => $author, | ||||
'time' => strtotime($date), | 'time' => strtotime($date), | ||||
'branch' => $branch, | 'branch' => $branch, | ||||
'tag' => $tag, | 'tag' => $tag, | ||||
'commit' => $node, | 'commit' => $node, | ||||
'rev' => $node, // TODO: Remove eventually. | 'rev' => $node, // TODO: Remove eventually. | ||||
'local' => $rev, | 'local' => $rev, | ||||
'parents' => $commit_parents, | 'parents' => $commit_parents, | ||||
'summary' => head(explode("\n", $desc)), | 'summary' => head(explode("\n", $desc)), | ||||
'message' => $desc, | 'message' => $desc, | ||||
'authorEmail' => $author_email, | 'authorEmail' => $author_email, | ||||
'coAuthors' => $co_authors, | |||||
); | ); | ||||
$last_node = $node; | $last_node = $node; | ||||
} | } | ||||
$futures = id(new FutureIterator($futures)) | $futures = id(new FutureIterator($futures)) | ||||
->limit(4); | ->limit(4); | ||||
foreach ($futures as $node => $future) { | foreach ($futures as $node => $future) { | ||||
▲ Show 20 Lines • Show All 816 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0