@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Rename "IMPORTED_CLOSEABLE" to "IMPORTED_PERMANENT" to clarify the meaning of the flag

Summary:
Ref T13591. This is an old flag with an old name, and there's an import bug because the outdated concept of "closable" is confusing two different behaviors.

This flag should mean only "is this commit reachable from a permanent ref?". Rename it to "IMPORTED_PERMANENT" to make that more clear.

Rename the "Unpublished" query to "Permanent" to make that more clear, as well.

Test Plan:
- Grepped for all affected symbols.
- Queried for all commmits, permament commits, and impermanent commits.
- Ran repository discovery.
- See also further changes in this change series for more extensive tests.

Maniphest Tasks: T13591

Differential Revision: https://secure.phabricator.com/D21514

+47 -47
+7 -7
src/applications/audit/query/PhabricatorCommitSearchEngine.php
··· 54 54 $query->withUnreachable($map['unreachable']); 55 55 } 56 56 57 - if ($map['unpublished'] !== null) { 58 - $query->withUnpublished($map['unpublished']); 57 + if ($map['permanent'] !== null) { 58 + $query->withPermanent($map['permanent']); 59 59 } 60 60 61 61 if ($map['ancestorsOf']) { ··· 132 132 'Find or exclude unreachable commits which are not ancestors of '. 133 133 'any branch, tag, or ref.')), 134 134 id(new PhabricatorSearchThreeStateField()) 135 - ->setLabel(pht('Unpublished')) 136 - ->setKey('unpublished') 135 + ->setLabel(pht('Permanent')) 136 + ->setKey('permanent') 137 137 ->setOptions( 138 138 pht('(Show All)'), 139 - pht('Show Only Unpublished Commits'), 140 - pht('Hide Unpublished Commits')) 139 + pht('Show Only Permanent Commits'), 140 + pht('Hide Permanent Commits')) 141 141 ->setDescription( 142 142 pht( 143 - 'Find or exclude unpublished commits which are not ancestors of '. 143 + 'Find or exclude permanent commits which are ancestors of '. 144 144 'any permanent branch, tag, or ref.')), 145 145 id(new PhabricatorSearchStringListField()) 146 146 ->setLabel(pht('Ancestors Of'))
+10 -10
src/applications/diffusion/query/DiffusionCommitQuery.php
··· 15 15 private $statuses; 16 16 private $packagePHIDs; 17 17 private $unreachable; 18 - private $unpublished; 18 + private $permanent; 19 19 20 20 private $needAuditRequests; 21 21 private $needAuditAuthority; ··· 154 154 return $this; 155 155 } 156 156 157 - public function withUnpublished($unpublished) { 158 - $this->unpublished = $unpublished; 157 + public function withPermanent($permanent) { 158 + $this->permanent = $permanent; 159 159 return $this; 160 160 } 161 161 ··· 859 859 } 860 860 } 861 861 862 - if ($this->unpublished !== null) { 863 - if ($this->unpublished) { 862 + if ($this->permanent !== null) { 863 + if ($this->permanent) { 864 864 $where[] = qsprintf( 865 865 $conn, 866 - '(commit.importStatus & %d) = 0', 867 - PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE); 866 + '(commit.importStatus & %d) = %d', 867 + PhabricatorRepositoryCommit::IMPORTED_PERMANENT, 868 + PhabricatorRepositoryCommit::IMPORTED_PERMANENT); 868 869 } else { 869 870 $where[] = qsprintf( 870 871 $conn, 871 - '(commit.importStatus & %d) = %d', 872 - PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE, 873 - PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE); 872 + '(commit.importStatus & %d) = 0', 873 + PhabricatorRepositoryCommit::IMPORTED_PERMANENT); 874 874 } 875 875 } 876 876
+5 -5
src/applications/repository/engine/PhabricatorRepositoryCommitRef.php
··· 5 5 private $identifier; 6 6 private $epoch; 7 7 private $branch; 8 - private $canCloseImmediately; 8 + private $isPermanent; 9 9 private $parents = array(); 10 10 11 11 public function setIdentifier($identifier) { ··· 35 35 return $this->branch; 36 36 } 37 37 38 - public function setCanCloseImmediately($can_close_immediately) { 39 - $this->canCloseImmediately = $can_close_immediately; 38 + public function setIsPermanent($is_permanent) { 39 + $this->isPermanent = $is_permanent; 40 40 return $this; 41 41 } 42 42 43 - public function getCanCloseImmediately() { 44 - return $this->canCloseImmediately; 43 + public function getIsPermanent() { 44 + return $this->isPermanent; 45 45 } 46 46 47 47 public function setParents(array $parents) {
+10 -10
src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
··· 101 101 $repository, 102 102 $ref->getIdentifier(), 103 103 $ref->getEpoch(), 104 - $ref->getCanCloseImmediately(), 104 + $ref->getIsPermanent(), 105 105 $ref->getParents(), 106 106 $task_priority); 107 107 ··· 250 250 $refs[$identifier] = id(new PhabricatorRepositoryCommitRef()) 251 251 ->setIdentifier($identifier) 252 252 ->setEpoch($epoch) 253 - ->setCanCloseImmediately(true); 253 + ->setIsPermanent(true); 254 254 255 255 if ($upper_bound === null) { 256 256 $upper_bound = $identifier; ··· 354 354 $branch_refs = $this->discoverStreamAncestry( 355 355 new PhabricatorMercurialGraphStream($repository, $commit), 356 356 $commit, 357 - $close_immediately = true); 357 + $is_permanent = true); 358 358 359 359 $this->didDiscoverRefs($branch_refs); 360 360 ··· 371 371 private function discoverStreamAncestry( 372 372 PhabricatorRepositoryGraphStream $stream, 373 373 $commit, 374 - $close_immediately) { 374 + $is_permanent) { 375 375 376 376 $discover = array($commit); 377 377 $graph = array(); ··· 424 424 $refs[] = id(new PhabricatorRepositoryCommitRef()) 425 425 ->setIdentifier($commit) 426 426 ->setEpoch($epoch) 427 - ->setCanCloseImmediately($close_immediately) 427 + ->setIsPermanent($is_permanent) 428 428 ->setParents($stream->getParents($commit)); 429 429 } 430 430 ··· 507 507 } 508 508 509 509 /** 510 - * Sort branches so we process closeable branches first. This makes the 511 - * whole import process a little cheaper, since we can close these commits 510 + * Sort branches so we process permanent branches first. This makes the 511 + * whole import process a little cheaper, since we can publish these commits 512 512 * the first time through rather than catching them in the refs step. 513 513 * 514 514 * @task internal ··· 538 538 PhabricatorRepository $repository, 539 539 $commit_identifier, 540 540 $epoch, 541 - $close_immediately, 541 + $is_permanent, 542 542 array $parents, 543 543 $task_priority) { 544 544 ··· 570 570 $commit->setRepositoryID($repository->getID()); 571 571 $commit->setCommitIdentifier($commit_identifier); 572 572 $commit->setEpoch($epoch); 573 - if ($close_immediately) { 574 - $commit->setImportStatus(PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE); 573 + if ($is_permanent) { 574 + $commit->setImportStatus(PhabricatorRepositoryCommit::IMPORTED_PERMANENT); 575 575 } 576 576 577 577 $data = new PhabricatorRepositoryCommitData();
+13 -13
src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
··· 9 9 10 10 private $newPositions = array(); 11 11 private $deadPositions = array(); 12 - private $closeCommits = array(); 12 + private $permanentCommits = array(); 13 13 private $rebuild; 14 14 15 15 public function setRebuild($rebuild) { ··· 24 24 public function updateRefs() { 25 25 $this->newPositions = array(); 26 26 $this->deadPositions = array(); 27 - $this->closeCommits = array(); 27 + $this->permanentCommits = array(); 28 28 29 29 $repository = $this->getRepository(); 30 30 $viewer = $this->getViewer(); ··· 96 96 $this->updateCursors($cursor_group, $refs, $type, $all_closing_heads); 97 97 } 98 98 99 - if ($this->closeCommits) { 100 - $this->setCloseFlagOnCommits($this->closeCommits); 99 + if ($this->permanentCommits) { 100 + $this->setPermanentFlagOnCommits($this->permanentCommits); 101 101 } 102 102 103 103 $save_cursors = $this->getCursorsForUpdate($all_cursors); ··· 217 217 return $this; 218 218 } 219 219 220 - private function markCloseCommits(array $identifiers) { 220 + private function markPermanentCommits(array $identifiers) { 221 221 foreach ($identifiers as $identifier) { 222 - $this->closeCommits[$identifier] = $identifier; 222 + $this->permanentCommits[$identifier] = $identifier; 223 223 } 224 224 return $this; 225 225 } ··· 377 377 $identifier, 378 378 $exclude); 379 379 380 - $this->markCloseCommits($new_identifiers); 380 + $this->markPermanentCommits($new_identifiers); 381 381 } 382 382 } 383 383 } ··· 507 507 } 508 508 509 509 /** 510 - * Mark a list of commits as closeable, and queue workers for those commits 510 + * Mark a list of commits as permanent, and queue workers for those commits 511 511 * which don't already have the flag. 512 512 */ 513 - private function setCloseFlagOnCommits(array $identifiers) { 513 + private function setPermanentFlagOnCommits(array $identifiers) { 514 514 $repository = $this->getRepository(); 515 515 $commit_table = new PhabricatorRepositoryCommit(); 516 516 $conn = $commit_table->establishConnection('w'); ··· 552 552 } 553 553 } 554 554 555 - $closeable_flag = PhabricatorRepositoryCommit::IMPORTED_CLOSEABLE; 555 + $permanent_flag = PhabricatorRepositoryCommit::IMPORTED_PERMANENT; 556 556 $published_flag = PhabricatorRepositoryCommit::IMPORTED_PUBLISH; 557 557 558 558 $all_commits = ipull($all_commits, null, 'commitIdentifier'); ··· 568 568 } 569 569 570 570 $import_status = $row['importStatus']; 571 - if (!($import_status & $closeable_flag)) { 572 - // Set the "closeable" flag. 573 - $import_status = ($import_status | $closeable_flag); 571 + if (!($import_status & $permanent_flag)) { 572 + // Set the "permanent" flag. 573 + $import_status = ($import_status | $permanent_flag); 574 574 575 575 // See T13580. Clear the "published" flag, so publishing executes 576 576 // again. We may have previously performed a no-op "publish" on the
+2 -2
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 36 36 const IMPORTED_PUBLISH = 8; 37 37 const IMPORTED_ALL = 11; 38 38 39 - const IMPORTED_CLOSEABLE = 1024; 39 + const IMPORTED_PERMANENT = 1024; 40 40 const IMPORTED_UNREACHABLE = 2048; 41 41 42 42 private $commitData = self::ATTACHABLE; ··· 467 467 } 468 468 469 469 public function isPermanentCommit() { 470 - return (bool)$this->isPartiallyImported(self::IMPORTED_CLOSEABLE); 470 + return (bool)$this->isPartiallyImported(self::IMPORTED_PERMANENT); 471 471 } 472 472 473 473 public function newCommitAuthorView(PhabricatorUser $viewer) {