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

Clean up various pieces of dead/obsolete Differential code

Summary:
Ref T2222.

- Removes `DifferentialTasksAttacher`, which has had no callsites for a very long time.
- Moves `differential.getrevisioncomments` off `DifferentialCommentQuery`.
- Moves Releeph churn field off `DifferentialCommentQuery`.
- Removes dead code in `DifferentialRevisionViewController`.
- Removes `DifferentialException` (no references).
- Removes `DifferentialRevision->loadComments()` (no callsites).
- Removes `DifferentialRevision->loadReviewedBy()` (all callsites updated).
- Removes `DifferentialCommentQuery` (all callsites updated).

Test Plan: Mostly a lot of `grep`.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2222

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

+68 -155
+6 -11
src/__phutil_library_map__.php
··· 345 345 'DifferentialChangesetViewController' => 'applications/differential/controller/DifferentialChangesetViewController.php', 346 346 'DifferentialComment' => 'applications/differential/storage/DifferentialComment.php', 347 347 'DifferentialCommentPreviewController' => 'applications/differential/controller/DifferentialCommentPreviewController.php', 348 - 'DifferentialCommentQuery' => 'applications/differential/query/DifferentialCommentQuery.php', 349 348 'DifferentialCommentSaveController' => 'applications/differential/controller/DifferentialCommentSaveController.php', 350 349 'DifferentialCommitMessageParser' => 'applications/differential/parser/DifferentialCommitMessageParser.php', 351 350 'DifferentialCommitMessageParserTestCase' => 'applications/differential/parser/__tests__/DifferentialCommitMessageParserTestCase.php', ··· 354 353 'DifferentialController' => 'applications/differential/controller/DifferentialController.php', 355 354 'DifferentialCoreCustomField' => 'applications/differential/customfield/DifferentialCoreCustomField.php', 356 355 'DifferentialCustomField' => 'applications/differential/customfield/DifferentialCustomField.php', 357 - 'DifferentialCustomFieldDependsOnParser' => 'applications/differential/field/parser/DifferentialCustomFieldDependsOnParser.php', 358 - 'DifferentialCustomFieldDependsOnParserTestCase' => 'applications/differential/field/parser/__tests__/DifferentialCustomFieldDependsOnParserTestCase.php', 356 + 'DifferentialCustomFieldDependsOnParser' => 'applications/differential/parser/DifferentialCustomFieldDependsOnParser.php', 357 + 'DifferentialCustomFieldDependsOnParserTestCase' => 'applications/differential/parser/__tests__/DifferentialCustomFieldDependsOnParserTestCase.php', 359 358 'DifferentialCustomFieldNumericIndex' => 'applications/differential/storage/DifferentialCustomFieldNumericIndex.php', 360 - 'DifferentialCustomFieldRevertsParser' => 'applications/differential/field/parser/DifferentialCustomFieldRevertsParser.php', 361 - 'DifferentialCustomFieldRevertsParserTestCase' => 'applications/differential/field/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php', 359 + 'DifferentialCustomFieldRevertsParser' => 'applications/differential/parser/DifferentialCustomFieldRevertsParser.php', 360 + 'DifferentialCustomFieldRevertsParserTestCase' => 'applications/differential/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php', 362 361 'DifferentialCustomFieldStorage' => 'applications/differential/storage/DifferentialCustomFieldStorage.php', 363 362 'DifferentialCustomFieldStringIndex' => 'applications/differential/storage/DifferentialCustomFieldStringIndex.php', 364 363 'DifferentialDAO' => 'applications/differential/storage/DifferentialDAO.php', ··· 374 373 'DifferentialDoorkeeperRevisionFeedStoryPublisher' => 'applications/differential/doorkeeper/DifferentialDoorkeeperRevisionFeedStoryPublisher.php', 375 374 'DifferentialDraft' => 'applications/differential/storage/DifferentialDraft.php', 376 375 'DifferentialEditPolicyField' => 'applications/differential/customfield/DifferentialEditPolicyField.php', 377 - 'DifferentialException' => 'applications/differential/exception/DifferentialException.php', 378 376 'DifferentialExceptionMail' => 'applications/differential/mail/DifferentialExceptionMail.php', 379 - 'DifferentialFieldParseException' => 'applications/differential/field/exception/DifferentialFieldParseException.php', 380 - 'DifferentialFieldValidationException' => 'applications/differential/field/exception/DifferentialFieldValidationException.php', 377 + 'DifferentialFieldParseException' => 'applications/differential/exception/DifferentialFieldParseException.php', 378 + 'DifferentialFieldValidationException' => 'applications/differential/exception/DifferentialFieldValidationException.php', 381 379 'DifferentialGetWorkingCopy' => 'applications/differential/DifferentialGetWorkingCopy.php', 382 380 'DifferentialGitSVNIDField' => 'applications/differential/customfield/DifferentialGitSVNIDField.php', 383 381 'DifferentialHostField' => 'applications/differential/customfield/DifferentialHostField.php', ··· 442 440 'DifferentialStoredCustomField' => 'applications/differential/customfield/DifferentialStoredCustomField.php', 443 441 'DifferentialSubscribersField' => 'applications/differential/customfield/DifferentialSubscribersField.php', 444 442 'DifferentialSummaryField' => 'applications/differential/customfield/DifferentialSummaryField.php', 445 - 'DifferentialTasksAttacher' => 'applications/differential/DifferentialTasksAttacher.php', 446 443 'DifferentialTestPlanField' => 'applications/differential/customfield/DifferentialTestPlanField.php', 447 444 'DifferentialTitleField' => 'applications/differential/customfield/DifferentialTitleField.php', 448 445 'DifferentialTransaction' => 'applications/differential/storage/DifferentialTransaction.php', ··· 2869 2866 'DifferentialChangesetViewController' => 'DifferentialController', 2870 2867 'DifferentialComment' => 'PhabricatorMarkupInterface', 2871 2868 'DifferentialCommentPreviewController' => 'DifferentialController', 2872 - 'DifferentialCommentQuery' => 'PhabricatorOffsetPagedQuery', 2873 2869 'DifferentialCommentSaveController' => 'DifferentialController', 2874 2870 'DifferentialCommitMessageParserTestCase' => 'PhabricatorTestCase', 2875 2871 'DifferentialCommitsField' => 'DifferentialCustomField', ··· 2902 2898 'DifferentialDoorkeeperRevisionFeedStoryPublisher' => 'DoorkeeperFeedStoryPublisher', 2903 2899 'DifferentialDraft' => 'DifferentialDAO', 2904 2900 'DifferentialEditPolicyField' => 'DifferentialCoreCustomField', 2905 - 'DifferentialException' => 'Exception', 2906 2901 'DifferentialExceptionMail' => 'DifferentialMail', 2907 2902 'DifferentialFieldParseException' => 'Exception', 2908 2903 'DifferentialFieldValidationException' => 'Exception',
-24
src/applications/differential/DifferentialTasksAttacher.php
··· 1 - <?php 2 - 3 - abstract class DifferentialTasksAttacher { 4 - /** 5 - * Implementation of this function should attach given tasks to 6 - * the given revision. The function is called when 'arc' has task 7 - * ids defined in the commit message. 8 - */ 9 - abstract public function attachTasksToRevision( 10 - $user_phid, 11 - DifferentialRevision $revision, 12 - array $task_ids); 13 - 14 - /** 15 - * This method will be called with a task and its original and new 16 - * associated revisions. Implementation of this method should update 17 - * the affected revisions to maintain the new associations. 18 - */ 19 - abstract public function updateTaskRevisionAssoc( 20 - $task_phid, 21 - array $orig_rev_phids, 22 - array $new_rev_phids); 23 - 24 - }
+22 -9
src/applications/differential/conduit/ConduitAPI_differential_getrevisioncomments_Method.php
··· 32 32 } 33 33 34 34 protected function execute(ConduitAPIRequest $request) { 35 + $viewer = $request->getUser(); 35 36 $results = array(); 36 37 $revision_ids = $request->getValue('ids'); 37 38 ··· 40 41 } 41 42 42 43 $revisions = id(new DifferentialRevisionQuery()) 43 - ->setViewer($request->getUser()) 44 + ->setViewer($viewer) 44 45 ->withIDs($revision_ids) 45 46 ->execute(); 46 47 ··· 48 49 return $results; 49 50 } 50 51 51 - $comments = id(new DifferentialCommentQuery()) 52 - ->withRevisionPHIDs(mpull($revisions, 'getPHID')) 52 + $xactions = id(new DifferentialTransactionQuery()) 53 + ->setViewer($viewer) 54 + ->withObjectPHIDs(mpull($revisions, 'getPHID')) 53 55 ->execute(); 54 56 55 57 $revisions = mpull($revisions, null, 'getPHID'); 56 58 57 - foreach ($comments as $comment) { 58 - $revision = idx($revisions, $comment->getRevisionPHID()); 59 + foreach ($xactions as $xaction) { 60 + $revision = idx($revisions, $xaction->getObjectPHID()); 59 61 if (!$revision) { 60 62 continue; 61 63 } 62 64 65 + $type = $xaction->getTransactionType(); 66 + if ($type == DifferentialTransaction::TYPE_ACTION) { 67 + $action = $xaction->getNewValue(); 68 + } else if ($type == PhabricatorTransactions::TYPE_COMMENT) { 69 + $action = 'comment'; 70 + } else { 71 + $action = 'none'; 72 + } 73 + 63 74 $result = array( 64 75 'revisionID' => $revision->getID(), 65 - 'action' => $comment->getAction(), 66 - 'authorPHID' => $comment->getAuthorPHID(), 67 - 'dateCreated' => $comment->getDateCreated(), 68 - 'content' => $comment->getContent(), 76 + 'action' => $action, 77 + 'authorPHID' => $xaction->getAuthorPHID(), 78 + 'dateCreated' => $xaction->getDateCreated(), 79 + 'content' => ($xaction->hasComment() 80 + ? $xaction->getComment()->getContent() 81 + : null), 69 82 ); 70 83 71 84 $results[$revision->getID()][] = $result;
+1 -10
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 84 84 $target_manual->getID()); 85 85 $props = mpull($props, 'getData', 'getName'); 86 86 87 - $comments = $revision->loadComments(); 88 - 89 87 $all_changesets = $changesets; 90 88 $inlines = $this->loadInlineComments( 91 89 $revision, ··· 98 96 array( 99 97 $revision->getAuthorPHID(), 100 98 $user->getPHID(), 101 - ), 102 - mpull($comments, 'getAuthorPHID')); 103 - 104 - foreach ($comments as $comment) { 105 - foreach ($comment->getRequiredHandlePHIDs() as $phid) { 106 - $object_phids[] = $phid; 107 - } 108 - } 99 + )); 109 100 110 101 foreach ($revision->getAttached() as $type => $phids) { 111 102 foreach ($phids as $phid => $info) {
-5
src/applications/differential/exception/DifferentialException.php
··· 1 - <?php 2 - 3 - abstract class DifferentialException extends Exception { 4 - 5 - }
src/applications/differential/field/exception/DifferentialFieldParseException.php src/applications/differential/exception/DifferentialFieldParseException.php
src/applications/differential/field/exception/DifferentialFieldValidationException.php src/applications/differential/exception/DifferentialFieldValidationException.php
src/applications/differential/field/parser/DifferentialCustomFieldDependsOnParser.php src/applications/differential/parser/DifferentialCustomFieldDependsOnParser.php
src/applications/differential/field/parser/DifferentialCustomFieldRevertsParser.php src/applications/differential/parser/DifferentialCustomFieldRevertsParser.php
src/applications/differential/field/parser/__tests__/DifferentialCustomFieldDependsOnParserTestCase.php src/applications/differential/parser/__tests__/DifferentialCustomFieldDependsOnParserTestCase.php
src/applications/differential/field/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php src/applications/differential/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php
-34
src/applications/differential/query/DifferentialCommentQuery.php
··· 1 - <?php 2 - 3 - /** 4 - * Temporary wrapper for transitioning Differential to ApplicationTransactions. 5 - */ 6 - final class DifferentialCommentQuery 7 - extends PhabricatorOffsetPagedQuery { 8 - 9 - private $revisionPHIDs; 10 - 11 - public function withRevisionPHIDs(array $phids) { 12 - $this->revisionPHIDs = $phids; 13 - return $this; 14 - } 15 - 16 - public function execute() { 17 - // TODO: We're getting rid of this, it is the bads. 18 - $viewer = PhabricatorUser::getOmnipotentUser(); 19 - 20 - $xactions = id(new DifferentialTransactionQuery()) 21 - ->setViewer($viewer) 22 - ->withObjectPHIDs($this->revisionPHIDs) 23 - ->needComments(true) 24 - ->execute(); 25 - 26 - $results = array(); 27 - foreach ($xactions as $xaction) { 28 - $results[] = DifferentialComment::newFromModernTransaction($xaction); 29 - } 30 - 31 - return $results; 32 - } 33 - 34 - }
-37
src/applications/differential/storage/DifferentialRevision.php
··· 160 160 DifferentialPHIDTypeRevision::TYPECONST); 161 161 } 162 162 163 - public function loadComments() { 164 - if (!$this->getID()) { 165 - return array(); 166 - } 167 - return id(new DifferentialCommentQuery()) 168 - ->withRevisionPHIDs(array($this->getPHID())) 169 - ->execute(); 170 - } 171 - 172 163 public function loadActiveDiff() { 173 164 return id(new DifferentialDiff())->loadOneWhere( 174 165 'revisionID = %d ORDER BY id DESC LIMIT 1', ··· 199 190 'DELETE FROM %T WHERE revisionID = %d', 200 191 self::TABLE_COMMIT, 201 192 $this->getID()); 202 - 203 - $comments = id(new DifferentialCommentQuery()) 204 - ->withRevisionPHIDs(array($this->getPHID())) 205 - ->execute(); 206 - foreach ($comments as $comment) { 207 - $comment->delete(); 208 - } 209 193 210 194 $inlines = id(new DifferentialInlineCommentQuery()) 211 195 ->withRevisionIDs(array($this->getID())) ··· 293 277 return head($this->getReviewers()); 294 278 } 295 279 return $last; 296 - } 297 - 298 - public function loadReviewedBy() { 299 - $reviewer = null; 300 - 301 - if ($this->status == ArcanistDifferentialRevisionStatus::ACCEPTED || 302 - $this->status == ArcanistDifferentialRevisionStatus::CLOSED) { 303 - $comments = $this->loadComments(); 304 - foreach ($comments as $comment) { 305 - $action = $comment->getAction(); 306 - if ($action == DifferentialAction::ACTION_ACCEPT) { 307 - $reviewer = $comment->getAuthorPHID(); 308 - } else if ($action == DifferentialAction::ACTION_REJECT || 309 - $action == DifferentialAction::ACTION_ABANDON || 310 - $action == DifferentialAction::ACTION_RETHINK) { 311 - $reviewer = null; 312 - } 313 - } 314 - } 315 - 316 - return $reviewer; 317 280 } 318 281 319 282 public function getHashes() {
+7 -7
src/applications/herald/adapter/HeraldCommitAdapter.php
··· 442 442 if (!$revision) { 443 443 return null; 444 444 } 445 - // after a revision is accepted, it can be closed (say via arc land) 446 - // so use this function to figure out if it was accepted at one point 447 - // *and* not later rejected... what a function! 448 - $reviewed_by = $revision->loadReviewedBy(); 449 - if (!$reviewed_by) { 450 - return null; 445 + 446 + switch ($revision->getStatus()) { 447 + case ArcanistDifferentialRevisionStatus::ACCEPTED: 448 + case ArcanistDifferentialRevisionStatus::CLOSED: 449 + return $revision->getPHID(); 451 450 } 452 - return $revision->getPHID(); 451 + 452 + return null; 453 453 case self::FIELD_DIFFERENTIAL_REVIEWERS: 454 454 $revision = $this->loadDifferentialRevision(); 455 455 if (!$revision) {
+22 -13
src/applications/releeph/field/specification/ReleephDiffChurnFieldSpecification.php
··· 23 23 } 24 24 25 25 $diff_rev = $this->getReleephRequest()->loadDifferentialRevision(); 26 - $comments = id(new DifferentialCommentQuery()) 27 - ->withRevisionPHIDs(array($diff_rev->getPHID())) 26 + 27 + $xactions = id(new DifferentialTransactionQuery()) 28 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 29 + ->withObjectPHIDs(array($diff_rev->getPHID())) 28 30 ->execute(); 29 31 30 - $counts = array(); 31 - foreach ($comments as $comment) { 32 - $action = $comment->getAction(); 33 - if (!isset($counts[$action])) { 34 - $counts[$action] = 0; 32 + $rejections = 0; 33 + $comments = 0; 34 + $updates = 0; 35 + foreach ($xactions as $xaction) { 36 + switch ($xaction->getTransactionType()) { 37 + case PhabricatorTransactions::TYPE_COMMENT: 38 + $comments++; 39 + break; 40 + case DifferentialTransaction::TYPE_UPDATE: 41 + $updates++; 42 + break; 43 + case DifferentialTransaction::TYPE_ACTION: 44 + switch ($xaction->getNewValue()) { 45 + case DifferentialAction::ACTION_REJECT: 46 + $rejections++; 47 + break; 48 + } 49 + break; 35 50 } 36 - $counts[$action] += 1; 37 51 } 38 - 39 - // 'none' action just means a plain comment 40 - $comments = idx($counts, 'none', 0); 41 - $rejections = idx($counts, 'reject', 0); 42 - $updates = idx($counts, 'update', 0); 43 52 44 53 $points = 45 54 self::REJECTIONS_WEIGHT * $rejections +
-5
src/applications/repository/worker/PhabricatorRepositoryCommitOwnersWorker.php
··· 100 100 $revision = id(new DifferentialRevision())->load($revision_id); 101 101 if ($revision) { 102 102 $revision_author_phid = $revision->getAuthorPHID(); 103 - $revision_reviewedby_phid = $revision->loadReviewedBy(); 104 103 $commit_reviewedby_phid = $data->getCommitDetail('reviewerPHID'); 105 104 if ($revision_author_phid !== $commit_author_phid) { 106 105 $reasons[] = "Author Not Matching with Revision"; 107 106 } 108 - if ($revision_reviewedby_phid !== $commit_reviewedby_phid) { 109 - $reasons[] = "ReviewedBy Not Matching with Revision"; 110 - } 111 - 112 107 } else { 113 108 $reasons[] = "Revision Not Found"; 114 109 }
+10
src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
··· 186 186 return phutil_utf8ize($string); 187 187 } 188 188 189 + public function delete() { 190 + 191 + // TODO: We should make some reasonable effort to destroy related 192 + // infrastructure objects here, like edges, transactions, custom field 193 + // storage, flags, Phrequent tracking, tokens, etc. This doesn't need to 194 + // be exhaustive, but we can get a lot of it pretty easily. 195 + 196 + return parent::delete(); 197 + } 198 + 189 199 }