@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.

Improve consistency in use of "via", "objectPHID", and "containerPHID" parameters in repository workers

Summary:
Ref T13591. Improve how parameters are passed between commit worker tasks:

- Always pass "via", to track where tasks came from.
- Always provide "objectPHID" (with the commit PHID).
- Always provide "containerPHID" (with the repository PHID).

Test Plan:
- Pushed a new commit.
- Ran `bin/repository pull` + `bin/repository discover`, saw commit with all parameters.
- Ran `bin/worker execute ...`, saw a Change worker and then a Publish worker with appropriate parameters.
- Ran `bin/repository reparse ... --background`, saw workers queue with appropriate parameters.

Maniphest Tasks: T13591

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

+47 -24
+1
src/applications/repository/engine/PhabricatorRepositoryEngine.php
··· 119 119 $options = array( 120 120 'priority' => $task_priority, 121 121 'objectPHID' => $commit_phid, 122 + 'containerPHID' => $repository->getPHID(), 122 123 ); 123 124 124 125 PhabricatorWorker::scheduleTask($class, $data, $options);
+3
src/applications/repository/management/PhabricatorRepositoryManagementReparseWorkflow.php
··· 249 249 $spec = array( 250 250 'commitID' => $commit->getID(), 251 251 'only' => !$importing, 252 + 'via' => 'reparse', 252 253 ); 253 254 254 255 foreach ($classes as $class) { ··· 258 259 $spec, 259 260 array( 260 261 'priority' => PhabricatorWorker::PRIORITY_IMPORT, 262 + 'objectPHID' => $commit->getPHID(), 263 + 'containerPHID' => $repository->getPHID(), 261 264 )); 262 265 } catch (PhabricatorWorkerPermanentFailureException $ex) { 263 266 // See T13315. We expect some reparse steps to occasionally raise
+33 -1
src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php
··· 51 51 $this->parseCommit($repository, $this->commit); 52 52 } 53 53 54 - final protected function shouldQueueFollowupTasks() { 54 + private function shouldQueueFollowupTasks() { 55 55 return !idx($this->getTaskData(), 'only'); 56 + } 57 + 58 + final protected function queueCommitTask($task_class) { 59 + if (!$this->shouldQueueFollowupTasks()) { 60 + return; 61 + } 62 + 63 + $commit = $this->loadCommit(); 64 + $repository = $commit->getRepository(); 65 + 66 + $data = array( 67 + 'commitID' => $commit->getID(), 68 + ); 69 + 70 + $task_data = $this->getTaskData(); 71 + if (isset($task_data['via'])) { 72 + $data['via'] = $task_data['via']; 73 + } 74 + 75 + $options = array( 76 + // We queue followup tasks at default priority so that the queue finishes 77 + // work it has started before starting more work. If followups are queued 78 + // at the same priority level, we do all message parses first, then all 79 + // change parses, etc. This makes progress uneven. See T11677 for 80 + // discussion. 81 + 'priority' => parent::PRIORITY_DEFAULT, 82 + 83 + 'objectPHID' => $commit->getPHID(), 84 + 'containerPHID' => $repository->getPHID(), 85 + ); 86 + 87 + $this->queueTask($task_class, $data, $options); 56 88 } 57 89 58 90 protected function getImportStepFlag() {
+8
src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php
··· 396 396 } 397 397 398 398 public function testSubversionParser() { 399 + $this->requireBinaryForTest('svn'); 400 + 399 401 $repository = $this->buildDiscoveredRepository('CHC'); 400 402 $viewer = PhabricatorUser::getOmnipotentUser(); 401 403 ··· 955 957 } 956 958 957 959 public function testSubversionPartialParser() { 960 + $this->requireBinaryForTest('svn'); 961 + 958 962 $repository = $this->buildBareRepository('CHD'); 959 963 $repository->setDetail('svn-subpath', 'trunk/'); 960 964 ··· 1059 1063 } 1060 1064 1061 1065 public function testSubversionValidRootParser() { 1066 + $this->requireBinaryForTest('svn'); 1067 + 1062 1068 // First, automatically configure the root correctly. 1063 1069 $repository = $this->buildBareRepository('CHD'); 1064 1070 id(new PhabricatorRepositoryPullEngine()) ··· 1104 1110 } 1105 1111 1106 1112 public function testSubversionForeignStubsParser() { 1113 + $this->requireBinaryForTest('svn'); 1114 + 1107 1115 $repository = $this->buildBareRepository('CHE'); 1108 1116 $repository->setDetail('svn-subpath', 'branch/'); 1109 1117
+1 -8
src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
··· 99 99 } 100 100 101 101 protected function finishParse() { 102 - $commit = $this->commit; 103 - if ($this->shouldQueueFollowupTasks()) { 104 - $this->queueTask( 105 - 'PhabricatorRepositoryCommitPublishWorker', 106 - array( 107 - 'commitID' => $commit->getID(), 108 - )); 109 - } 102 + $this->queueCommitTask('PhabricatorRepositoryCommitPublishWorker'); 110 103 } 111 104 112 105 private function writeCommitChanges(
+1 -15
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 24 24 $this->updateCommitData($commit, $data); 25 25 } 26 26 27 - if ($this->shouldQueueFollowupTasks()) { 28 - $this->queueTask( 29 - $this->getFollowupTaskClass(), 30 - array( 31 - 'commitID' => $commit->getID(), 32 - ), 33 - array( 34 - // We queue followup tasks at default priority so that the queue 35 - // finishes work it has started before starting more work. If 36 - // followups are queued at the same priority level, we do all 37 - // message parses first, then all change parses, etc. This makes 38 - // progress uneven. See T11677 for discussion. 39 - 'priority' => PhabricatorWorker::PRIORITY_DEFAULT, 40 - )); 41 - } 27 + $this->queueCommitTask($this->getFollowupTaskClass()); 42 28 } 43 29 44 30 final protected function updateCommitData(