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

Prevent "Differential Revision: ..." from counting as a mention in commit messages

Summary:
Ref T13290. Ref T13291. Now that a full URI is a "mention", the full URI in "Differential Revision: ..." also triggers a mention.

Stop it from doing that, since these mentions are silly/redundant/unintended.

The API here is also slightly odd; simplify it a little bit to get rid of doing "append" with "get + append + set".

Test Plan: Used `bin/repository reparse --publish` to republish commits with "Differential Revision: ..." and verified that the revision PHID was properly dropped from the mention list.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13291, T13290

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

+28 -20
+2 -4
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 239 239 $object); 240 240 if ($request) { 241 241 $xactions[] = $request; 242 - $this->setUnmentionablePHIDMap($request->getNewValue()); 242 + $this->addUnmentionablePHIDs($request->getNewValue()); 243 243 } 244 244 break; 245 245 default: ··· 360 360 $flat_blocks = mpull($changes, 'getNewValue'); 361 361 $huge_block = implode("\n\n", $flat_blocks); 362 362 $phid_map = array(); 363 - $phid_map[] = $this->getUnmentionablePHIDMap(); 364 363 $monograms = array(); 365 364 366 365 $task_refs = id(new ManiphestCustomFieldStatusParser()) ··· 384 383 ->withNames($monograms) 385 384 ->execute(); 386 385 $phid_map[] = mpull($objects, 'getPHID', 'getPHID'); 387 - 388 386 389 387 $reverts_refs = id(new DifferentialCustomFieldRevertsParser()) 390 388 ->parseCorpus($huge_block); ··· 408 406 } 409 407 410 408 $phid_map = array_mergev($phid_map); 411 - $this->setUnmentionablePHIDMap($phid_map); 409 + $this->addUnmentionablePHIDs($phid_map); 412 410 413 411 return $result; 414 412 }
+3 -7
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 846 846 $revert_phids = array(); 847 847 } 848 848 849 - // See PHI574. Respect any unmentionable PHIDs which were set on the 850 - // Editor by the caller. 851 - $unmentionable_map = $this->getUnmentionablePHIDMap(); 852 - $unmentionable_map += $task_phids; 853 - $unmentionable_map += $rev_phids; 854 - $unmentionable_map += $revert_phids; 855 - $this->setUnmentionablePHIDMap($unmentionable_map); 849 + $this->addUnmentionablePHIDs($task_phids); 850 + $this->addUnmentionablePHIDs($rev_phids); 851 + $this->addUnmentionablePHIDs($revert_phids); 856 852 857 853 $result = array(); 858 854 foreach ($edges as $type => $specs) {
+1 -4
src/applications/diffusion/worker/DiffusionUpdateObjectAfterCommitWorker.php
··· 139 139 ->setContentSource($content_source) 140 140 ->setContinueOnNoEffect(true) 141 141 ->setContinueOnMissingFields(true) 142 - ->setUnmentionablePHIDMap( 143 - array( 144 - $commit_phid => $commit_phid, 145 - )); 142 + ->addUnmentionablePHIDs(array($commit_phid)); 146 143 147 144 $editor->applyTransactions($task, $xactions); 148 145 }
+14 -1
src/applications/repository/worker/PhabricatorRepositoryCommitPublishWorker.php
··· 62 62 $acting_phid = $this->getPublishAsPHID($commit); 63 63 $content_source = $this->newContentSource(); 64 64 65 + $revision = DiffusionCommitRevisionQuery::loadRevisionForCommit( 66 + $viewer, 67 + $commit); 68 + 69 + // Prevent the commit from generating a mention of the associated 70 + // revision, if one exists, so we don't double up because of the URI 71 + // in the commit message. 72 + $unmentionable_phids = array(); 73 + if ($revision) { 74 + $unmentionable_phids[] = $revision->getPHID(); 75 + } 76 + 65 77 $editor = $commit->getApplicationTransactionEditor() 66 78 ->setActor($viewer) 67 79 ->setActingAsPHID($acting_phid) 68 80 ->setContinueOnNoEffect(true) 69 81 ->setContinueOnMissingFields(true) 70 - ->setContentSource($content_source); 82 + ->setContentSource($content_source) 83 + ->addUnmentionablePHIDs($unmentionable_phids); 71 84 72 85 try { 73 86 $raw_patch = $this->loadRawPatchText($repository, $commit);
+8 -4
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 260 260 return $this->isHeraldEditor; 261 261 } 262 262 263 - public function setUnmentionablePHIDMap(array $map) { 264 - $this->unmentionablePHIDMap = $map; 263 + public function addUnmentionablePHIDs(array $phids) { 264 + foreach ($phids as $phid) { 265 + $this->unmentionablePHIDMap[$phid] = true; 266 + } 265 267 return $this; 266 268 } 267 269 268 - public function getUnmentionablePHIDMap() { 270 + private function getUnmentionablePHIDMap() { 269 271 return $this->unmentionablePHIDMap; 270 272 } 271 273 ··· 2090 2092 ->withPHIDs($mentioned_phids) 2091 2093 ->execute(); 2092 2094 2095 + $unmentionable_map = $this->getUnmentionablePHIDMap(); 2096 + 2093 2097 $mentionable_phids = array(); 2094 2098 if ($this->shouldEnableMentions($object, $xactions)) { 2095 2099 foreach ($mentioned_objects as $mentioned_object) { 2096 2100 if ($mentioned_object instanceof PhabricatorMentionableInterface) { 2097 2101 $mentioned_phid = $mentioned_object->getPHID(); 2098 - if (idx($this->getUnmentionablePHIDMap(), $mentioned_phid)) { 2102 + if (isset($unmentionable_map[$mentioned_phid])) { 2099 2103 continue; 2100 2104 } 2101 2105 // don't let objects mention themselves