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

Correct some issues around IMPORTED_PERMANENT in RefEngine

Summary: Ref T13591. Fixes a few issues with the recent updates here discovered in more thorough testing.

Test Plan:
- Stopped the daemons.
- Created a new copy of Phabricator in Diffusion.
- Pulled it with `bin/repository pull ...`.
  - Got 17,278 commits on disk with `git log --all --format=%H`.
- Set permanent refs to "master".
- Discovered it with `bin/repository discover ...`.
  - This took 31.5s and inserted 17,278 tasks.
  - Verified that all tasks have priority 4,000 (PRIORITY_IMPORT).
  - Observed that 16,799 commits have IMPORTED_PERMANENT and 479 commits do not.
    - This matches `git log master --format=%H` exactly.
- Ran `bin/repository refs ...`. Expected no changes and saw no changes.
- Ran `bin/worker execute --active` for a minute or two. It processed all the impermanent changes first (since `bin/worker` is LIFO and these are supposed to process last).
  - Ran `bin/repository refs`. Expected no changes and saw no changes.
  - Marked all refs as permanent.
  - Starting state: 16,009 message tasks, all at priority 4000.
  - Ran `bin/repository refs`, expecting 479 new tasks at priority 4000.
  - Saw count rise to 16,488 as expected.
  - Saw all the new tasks have priority 4000 and all commits now have the IMPORTED_PERMANENT flag.

Maniphest Tasks: T13591

Differential Revision: https://secure.phabricator.com/D21518
This commit is contained in:
epriestley 2021-01-22 16:36:46 -08:00
parent 15e022d648
commit 1da94dcf49

View file

@ -344,8 +344,7 @@ final class PhabricatorRepositoryRefEngine
$this->markPositionNew($new_position);
}
$diffusion_ref = head($refs)->newDiffusionRepositoryRef();
if ($publisher->isPermanentRef($diffusion_ref)) {
if ($publisher->isPermanentRef(head($refs))) {
// See T13284. If this cursor was already marked as permanent, we
// only need to publish the newly created ref positions. However, if
@ -613,13 +612,17 @@ final class PhabricatorRepositoryRefEngine
$ref_type,
$ref_name) {
$is_permanent = $this->isPermanentRef($ref_type, $ref_name);
$cursor = id(new PhabricatorRepositoryRefCursor())
->setRepositoryPHID($repository->getPHID())
->setRefType($ref_type)
->setRefName($ref_name)
->setIsPermanent((int)$is_permanent);
->setRefName($ref_name);
$publisher = $repository->newPublisher();
$diffusion_ref = $cursor->newDiffusionRepositoryRef();
$is_permanent = $publisher->isPermanentRef($diffusion_ref);
$cursor->setIsPermanent((int)$is_permanent);
try {
return $cursor->save();