Page MenuHomePhabricator

D8781.id20858.diff
No OneTemporary

D8781.id20858.diff

diff --git a/src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php b/src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
--- a/src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
@@ -102,6 +102,8 @@
'Discovering commits in repository %s.',
$repository->getCallsign()));
+ $this->fillCommitCache(array_values($branches));
+
$refs = array();
foreach ($branches as $name => $commit) {
$this->log(pht('Examining branch "%s", at "%s".', $name, $commit));
@@ -354,6 +356,8 @@
->setRepository($repository)
->execute();
+ $this->fillCommitCache(mpull($branches, 'getCommitIdentifier'));
+
$refs = array();
foreach ($branches as $branch) {
// NOTE: Mercurial branches may have multiple heads, so the names may
@@ -473,24 +477,30 @@
return false;
}
- $commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
- 'repositoryID = %d AND commitIdentifier = %s',
+ $this->fillCommitCache(array($identifier));
+
+ return isset($this->commitCache[$identifier]);
+ }
+
+ private function fillCommitCache(array $identifiers) {
+ if (!$identifiers) {
+ return;
+ }
+
+ $commits = id(new PhabricatorRepositoryCommit())->loadAllWhere(
+ 'repositoryID = %d AND commitIdentifier IN (%Ls)',
$this->getRepository()->getID(),
- $identifier);
+ $identifiers);
- if (!$commit) {
- return false;
+ foreach ($commits as $commit) {
+ $this->commitCache[$commit->getCommitIdentifier()] = true;
}
- $this->commitCache[$identifier] = true;
while (count($this->commitCache) > self::MAX_COMMIT_CACHE_SIZE) {
array_shift($this->commitCache);
}
-
- return true;
}
-
/**
* Sort branches so we process closeable branches first. This makes the
* whole import process a little cheaper, since we can close these commits

File Metadata

Mime Type
text/plain
Expires
Oct 16 2024, 8:39 AM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6716778
Default Alt Text
D8781.id20858.diff (1 KB)

Event Timeline