1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Correct the behavior of "bin/repository discover --repair"

Summary:
Ref T13591. Since D8781, this flag does not function correctly in Git and Mercurial repositories, since ref discovery pre-fills the cache.

Move the "don't look at the database" behavior the flag enables into the cache lookup. D8781 should have been slightly more aggressive and done this, it was just overlooked.

Test Plan:
  - Ran `bin/repository discover --help` and read the updated help text.
  - Ran `bin/repository discover --repair` in a fully-discovered Git repository.
    - Before: no effect.
    - After: full rediscovery.

Maniphest Tasks: T13591

Differential Revision: https://secure.phabricator.com/D21513
This commit is contained in:
epriestley 2021-01-22 12:22:50 -08:00
parent e7e8ef7e39
commit 16a14af2bb
2 changed files with 16 additions and 15 deletions

View file

@ -459,13 +459,6 @@ final class PhabricatorRepositoryDiscoveryEngine
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]);
@ -476,6 +469,13 @@ final class PhabricatorRepositoryDiscoveryEngine
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

View file

@ -7,7 +7,7 @@ final class PhabricatorRepositoryManagementDiscoverWorkflow
$this $this
->setName('discover') ->setName('discover')
->setExamples('**discover** [__options__] __repository__ ...') ->setExamples('**discover** [__options__] __repository__ ...')
->setSynopsis(pht('Discover __repository__.')) ->setSynopsis(pht('Discover commits in __repository__.'))
->setArguments( ->setArguments(
array( array(
array( array(
@ -17,7 +17,8 @@ final class PhabricatorRepositoryManagementDiscoverWorkflow
array( array(
'name' => 'repair', 'name' => 'repair',
'help' => pht( 'help' => pht(
'Repair a repository with gaps in commit history.'), 'Discover all commits, even if they are ancestors of known '.
'commits. This can repair gaps in repository history.'),
), ),
array( array(
'name' => 'repos', 'name' => 'repos',