Differential D21513 Diff 51215 src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
Show First 20 Lines • Show All 453 Lines • ▼ Show 20 Lines | private function isKnownCommit($identifier) { | ||||
if (isset($this->commitCache[$identifier])) { | if (isset($this->commitCache[$identifier])) { | ||||
return true; | return true; | ||||
} | } | ||||
if (isset($this->workingSet[$identifier])) { | if (isset($this->workingSet[$identifier])) { | ||||
return true; | return true; | ||||
} | } | ||||
if ($this->repairMode) { | |||||
// In repair mode, rediscover the entire repository, ignoring the | |||||
// database state. We can hit the local cache above, but if we miss it | |||||
// stop the script from going to the database cache. | |||||
return false; | |||||
} | |||||
$this->fillCommitCache(array($identifier)); | $this->fillCommitCache(array($identifier)); | ||||
return isset($this->commitCache[$identifier]); | return isset($this->commitCache[$identifier]); | ||||
} | } | ||||
private function fillCommitCache(array $identifiers) { | private function fillCommitCache(array $identifiers) { | ||||
if (!$identifiers) { | if (!$identifiers) { | ||||
return; | return; | ||||
} | } | ||||
if ($this->repairMode) { | |||||
// In repair mode, rediscover the entire repository, ignoring the | |||||
// database state. The engine still maintains a local cache (the | |||||
// "Working Set") but we just give up before looking in the database. | |||||
return; | |||||
} | |||||
$max_size = self::MAX_COMMIT_CACHE_SIZE; | $max_size = self::MAX_COMMIT_CACHE_SIZE; | ||||
// If we're filling more identifiers than would fit in the cache, ignore | // If we're filling more identifiers than would fit in the cache, ignore | ||||
// the ones that don't fit. Because the cache is FIFO, overfilling it can | // the ones that don't fit. Because the cache is FIFO, overfilling it can | ||||
// cause the entire cache to miss. See T12296. | // cause the entire cache to miss. See T12296. | ||||
if (count($identifiers) > $max_size) { | if (count($identifiers) > $max_size) { | ||||
$identifiers = array_slice($identifiers, 0, $max_size); | $identifiers = array_slice($identifiers, 0, $max_size); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 510 Lines • Show Last 20 Lines |