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

Remove some obsolete lint and unit support

Summary:
Ref T8096.

Long ago, support for "postponed" lint and unit tests got hacked in. `arc` would publish a bunch of ghost results, and then something else would fill the results in later.

This was always a hack. It is not nearly as powerful or flexible as having a real build system, and is obsolete with Harbormaster, which supports these operations in a more reasonable and straightforward way.

This was used (only? almost only?) at Facebook.

- Remove `differential.finishpostponedlinters`. This only served to update postponed linters.
- Remove lint magic in `differential.setdiffproperty`. This magic only made sense in the context of postponed linters.
- Remove `differential.updateunitresults`. The only made sense for postponed unit tests.

And one minor change: when a diff contains >100 affected files, we hide the content by default, but show content for files with inline comments. Previously, we'd do this for lint inlines, too. I don't tink this is too useful, and it's much simpler to just remove it. We could add it back at some point, but I think large changes often trigger a lot of lint and no one actually cares. The behavior for actual human inlines is retained.

Test Plan: `grep`

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8096

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

-346
-4
src/__phutil_library_map__.php
··· 378 378 'DifferentialFieldParseException' => 'applications/differential/exception/DifferentialFieldParseException.php', 379 379 'DifferentialFieldValidationException' => 'applications/differential/exception/DifferentialFieldValidationException.php', 380 380 'DifferentialFindConduitAPIMethod' => 'applications/differential/conduit/DifferentialFindConduitAPIMethod.php', 381 - 'DifferentialFinishPostponedLintersConduitAPIMethod' => 'applications/differential/conduit/DifferentialFinishPostponedLintersConduitAPIMethod.php', 382 381 'DifferentialGetAllDiffsConduitAPIMethod' => 'applications/differential/conduit/DifferentialGetAllDiffsConduitAPIMethod.php', 383 382 'DifferentialGetCommitMessageConduitAPIMethod' => 'applications/differential/conduit/DifferentialGetCommitMessageConduitAPIMethod.php', 384 383 'DifferentialGetCommitPathsConduitAPIMethod' => 'applications/differential/conduit/DifferentialGetCommitPathsConduitAPIMethod.php', ··· 495 494 'DifferentialUnitStatus' => 'applications/differential/constants/DifferentialUnitStatus.php', 496 495 'DifferentialUnitTestResult' => 'applications/differential/constants/DifferentialUnitTestResult.php', 497 496 'DifferentialUpdateRevisionConduitAPIMethod' => 'applications/differential/conduit/DifferentialUpdateRevisionConduitAPIMethod.php', 498 - 'DifferentialUpdateUnitResultsConduitAPIMethod' => 'applications/differential/conduit/DifferentialUpdateUnitResultsConduitAPIMethod.php', 499 497 'DifferentialViewPolicyField' => 'applications/differential/customfield/DifferentialViewPolicyField.php', 500 498 'DiffusionAuditorDatasource' => 'applications/diffusion/typeahead/DiffusionAuditorDatasource.php', 501 499 'DiffusionAuditorsAddAuditorsHeraldAction' => 'applications/diffusion/herald/DiffusionAuditorsAddAuditorsHeraldAction.php', ··· 3999 3997 'DifferentialFieldParseException' => 'Exception', 4000 3998 'DifferentialFieldValidationException' => 'Exception', 4001 3999 'DifferentialFindConduitAPIMethod' => 'DifferentialConduitAPIMethod', 4002 - 'DifferentialFinishPostponedLintersConduitAPIMethod' => 'DifferentialConduitAPIMethod', 4003 4000 'DifferentialGetAllDiffsConduitAPIMethod' => 'DifferentialConduitAPIMethod', 4004 4001 'DifferentialGetCommitMessageConduitAPIMethod' => 'DifferentialConduitAPIMethod', 4005 4002 'DifferentialGetCommitPathsConduitAPIMethod' => 'DifferentialConduitAPIMethod', ··· 4136 4133 'DifferentialUnitStatus' => 'Phobject', 4137 4134 'DifferentialUnitTestResult' => 'Phobject', 4138 4135 'DifferentialUpdateRevisionConduitAPIMethod' => 'DifferentialConduitAPIMethod', 4139 - 'DifferentialUpdateUnitResultsConduitAPIMethod' => 'DifferentialConduitAPIMethod', 4140 4136 'DifferentialViewPolicyField' => 'DifferentialCoreCustomField', 4141 4137 'DiffusionAuditorDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 4142 4138 'DiffusionAuditorsAddAuditorsHeraldAction' => 'DiffusionAuditorsHeraldAction',
-118
src/applications/differential/conduit/DifferentialFinishPostponedLintersConduitAPIMethod.php
··· 1 - <?php 2 - 3 - final class DifferentialFinishPostponedLintersConduitAPIMethod 4 - extends DifferentialConduitAPIMethod { 5 - 6 - public function getAPIMethodName() { 7 - return 'differential.finishpostponedlinters'; 8 - } 9 - 10 - public function getMethodDescription() { 11 - return pht( 12 - 'Update diff with new lint messages and mark postponed '. 13 - 'linters as finished.'); 14 - } 15 - 16 - protected function defineParamTypes() { 17 - return array( 18 - 'diffID' => 'required diffID', 19 - 'linters' => 'required dict', 20 - ); 21 - } 22 - 23 - protected function defineReturnType() { 24 - return 'void'; 25 - } 26 - 27 - protected function defineErrorTypes() { 28 - return array( 29 - 'ERR-BAD-DIFF' => pht('Bad diff ID.'), 30 - 'ERR-BAD-LINTER' => pht('No postponed linter by the given name.'), 31 - 'ERR-NO-LINT' => pht('No postponed lint field available in diff.'), 32 - ); 33 - } 34 - 35 - protected function execute(ConduitAPIRequest $request) { 36 - $diff_id = $request->getValue('diffID'); 37 - $linter_map = $request->getValue('linters'); 38 - 39 - $diff = id(new DifferentialDiffQuery()) 40 - ->setViewer($request->getUser()) 41 - ->withIDs(array($diff_id)) 42 - ->executeOne(); 43 - if (!$diff) { 44 - throw new ConduitException('ERR-BAD-DIFF'); 45 - } 46 - 47 - // Extract the finished linters and messages from the linter map. 48 - $finished_linters = array_keys($linter_map); 49 - $new_messages = array(); 50 - foreach ($linter_map as $linter => $messages) { 51 - $new_messages = array_merge($new_messages, $messages); 52 - } 53 - 54 - // Load the postponed linters attached to this diff. 55 - $postponed_linters_property = id( 56 - new DifferentialDiffProperty())->loadOneWhere( 57 - 'diffID = %d AND name = %s', 58 - $diff_id, 59 - 'arc:lint-postponed'); 60 - if ($postponed_linters_property) { 61 - $postponed_linters = $postponed_linters_property->getData(); 62 - } else { 63 - $postponed_linters = array(); 64 - } 65 - 66 - foreach ($finished_linters as $linter) { 67 - if (!in_array($linter, $postponed_linters)) { 68 - throw new ConduitException('ERR-BAD-LINTER'); 69 - } 70 - } 71 - 72 - foreach ($postponed_linters as $idx => $linter) { 73 - if (in_array($linter, $finished_linters)) { 74 - unset($postponed_linters[$idx]); 75 - } 76 - } 77 - 78 - // Load the lint messages currenty attached to the diff. If this 79 - // diff property doesn't exist, create it. 80 - $messages_property = id(new DifferentialDiffProperty())->loadOneWhere( 81 - 'diffID = %d AND name = %s', 82 - $diff_id, 83 - 'arc:lint'); 84 - if ($messages_property) { 85 - $messages = $messages_property->getData(); 86 - } else { 87 - $messages = array(); 88 - } 89 - 90 - // Add new lint messages, removing duplicates. 91 - foreach ($new_messages as $new_message) { 92 - if (!in_array($new_message, $messages)) { 93 - $messages[] = $new_message; 94 - } 95 - } 96 - 97 - // Use setdiffproperty to update the postponed linters and messages, 98 - // as these will also update the lint status correctly. 99 - $call = new ConduitCall( 100 - 'differential.setdiffproperty', 101 - array( 102 - 'diff_id' => $diff_id, 103 - 'name' => 'arc:lint', 104 - 'data' => json_encode($messages), 105 - )); 106 - $call->setUser($request->getUser()); 107 - $call->execute(); 108 - $call = new ConduitCall( 109 - 'differential.setdiffproperty', 110 - array( 111 - 'diff_id' => $diff_id, 112 - 'name' => 'arc:lint-postponed', 113 - 'data' => json_encode($postponed_linters), 114 - )); 115 - $call->setUser($request->getUser()); 116 - $call->execute(); 117 - } 118 - }
-60
src/applications/differential/conduit/DifferentialSetDiffPropertyConduitAPIMethod.php
··· 29 29 ); 30 30 } 31 31 32 - private static function updateLintStatus($diff_id) { 33 - 34 - $diff = id(new DifferentialDiff())->load($diff_id); 35 - if (!$diff) { 36 - throw new ConduitException('ERR_NOT_FOUND'); 37 - } 38 - 39 - // Load the postponed linters attached to this diff. 40 - $postponed_linters_property = id( 41 - new DifferentialDiffProperty())->loadOneWhere( 42 - 'diffID = %d AND name = %s', 43 - $diff_id, 44 - 'arc:lint-postponed'); 45 - if ($postponed_linters_property) { 46 - $postponed_linters = $postponed_linters_property->getData(); 47 - } else { 48 - $postponed_linters = array(); 49 - } 50 - 51 - // Load the lint messages currenty attached to the diff 52 - $messages_property = id(new DifferentialDiffProperty())->loadOneWhere( 53 - 'diffID = %d AND name = %s', 54 - $diff_id, 55 - 'arc:lint'); 56 - if ($messages_property) { 57 - $results = $messages_property->getData(); 58 - } else { 59 - $results = array(); 60 - } 61 - 62 - $has_error = false; 63 - $has_warning = false; 64 - foreach ($results as $result) { 65 - if ($result['severity'] === ArcanistLintSeverity::SEVERITY_ERROR) { 66 - $has_error = true; 67 - break; 68 - } else if ($result['severity'] === 69 - ArcanistLintSeverity::SEVERITY_WARNING) { 70 - $has_warning = true; 71 - } 72 - } 73 - 74 - if ($has_error) { 75 - $diff->setLintStatus(DifferentialLintStatus::LINT_FAIL); 76 - } else if ($has_warning) { 77 - $diff->setLintStatus(DifferentialLintStatus::LINT_WARN); 78 - } else if (!empty($postponed_linters)) { 79 - $diff->setLintStatus(DifferentialLintStatus::LINT_POSTPONED); 80 - } else if ($diff->getLintStatus() != DifferentialLintStatus::LINT_SKIP) { 81 - $diff->setLintStatus(DifferentialLintStatus::LINT_OKAY); 82 - } 83 - $diff->save(); 84 - } 85 - 86 32 protected function execute(ConduitAPIRequest $request) { 87 33 $diff_id = $request->getValue('diff_id'); 88 34 $name = $request->getValue('name'); 89 35 $data = json_decode($request->getValue('data'), true); 90 36 91 37 self::updateDiffProperty($diff_id, $name, $data); 92 - 93 - if ($name === 'arc:lint' || $name == 'arc:lint-postponed') { 94 - self::updateLintStatus($diff_id); 95 - } 96 - 97 - return; 98 38 } 99 39 100 40 private static function updateDiffProperty($diff_id, $name, $data) {
-154
src/applications/differential/conduit/DifferentialUpdateUnitResultsConduitAPIMethod.php
··· 1 - <?php 2 - 3 - final class DifferentialUpdateUnitResultsConduitAPIMethod 4 - extends DifferentialConduitAPIMethod { 5 - 6 - public function getAPIMethodName() { 7 - return 'differential.updateunitresults'; 8 - } 9 - 10 - public function getMethodDescription() { 11 - return pht('Update arc unit results for a postponed test.'); 12 - } 13 - 14 - protected function defineParamTypes() { 15 - return array( 16 - 'diff_id' => 'required diff_id', 17 - 'file' => 'required string', 18 - 'name' => 'required string', 19 - 'link' => 'optional string', 20 - 'result' => 'required string', 21 - 'message' => 'required string', 22 - 'coverage' => 'optional map<string, string>', 23 - ); 24 - } 25 - 26 - protected function defineReturnType() { 27 - return 'void'; 28 - } 29 - 30 - protected function defineErrorTypes() { 31 - return array( 32 - 'ERR_BAD_DIFF' => pht('Bad diff ID.'), 33 - 'ERR_NO_RESULTS' => pht('Could not find the postponed test'), 34 - ); 35 - } 36 - 37 - protected function execute(ConduitAPIRequest $request) { 38 - $diff_id = $request->getValue('diff_id'); 39 - if (!$diff_id) { 40 - throw new ConduitException('ERR_BAD_DIFF'); 41 - } 42 - 43 - $file = $request->getValue('file'); 44 - $name = $request->getValue('name'); 45 - $link = $request->getValue('link'); 46 - $message = $request->getValue('message'); 47 - $result = $request->getValue('result'); 48 - $coverage = $request->getValue('coverage', array()); 49 - 50 - $diff_property = id(new DifferentialDiffProperty())->loadOneWhere( 51 - 'diffID = %d AND name = %s', 52 - $diff_id, 53 - 'arc:unit'); 54 - 55 - if (!$diff_property) { 56 - throw new ConduitException('ERR_NO_RESULTS'); 57 - } 58 - 59 - $diff = id(new DifferentialDiffQuery()) 60 - ->setViewer($request->getUser()) 61 - ->withIDs(array($diff_id)) 62 - ->executeOne(); 63 - 64 - $unit_results = $diff_property->getData(); 65 - $postponed_count = 0; 66 - $unit_status = null; 67 - 68 - // If the test result already exists, then update it with 69 - // the new info. 70 - foreach ($unit_results as &$unit_result) { 71 - if ($unit_result['name'] === $name || 72 - $unit_result['name'] === $file || 73 - $unit_result['name'] === $diff->getSourcePath().$file) { 74 - $unit_result['name'] = $name; 75 - $unit_result['link'] = $link; 76 - $unit_result['file'] = $file; 77 - $unit_result['result'] = $result; 78 - $unit_result['userdata'] = $message; 79 - $unit_result['coverage'] = $coverage; 80 - $unit_status = $result; 81 - break; 82 - } 83 - } 84 - unset($unit_result); 85 - 86 - // If the test result doesn't exist, just add it. 87 - if (!$unit_status) { 88 - $unit_result = array(); 89 - $unit_result['file'] = $file; 90 - $unit_result['name'] = $name; 91 - $unit_result['link'] = $link; 92 - $unit_result['result'] = $result; 93 - $unit_result['userdata'] = $message; 94 - $unit_result['coverage'] = $coverage; 95 - $unit_status = $result; 96 - $unit_results[] = $unit_result; 97 - } 98 - unset($unit_result); 99 - 100 - $diff_property->setData($unit_results); 101 - $diff_property->save(); 102 - 103 - // Map external unit test status to internal overall diff status 104 - $status_codes = 105 - array( 106 - DifferentialUnitTestResult::RESULT_PASS => 107 - DifferentialUnitStatus::UNIT_OKAY, 108 - DifferentialUnitTestResult::RESULT_UNSOUND => 109 - DifferentialUnitStatus::UNIT_WARN, 110 - DifferentialUnitTestResult::RESULT_FAIL => 111 - DifferentialUnitStatus::UNIT_FAIL, 112 - DifferentialUnitTestResult::RESULT_BROKEN => 113 - DifferentialUnitStatus::UNIT_FAIL, 114 - DifferentialUnitTestResult::RESULT_SKIP => 115 - DifferentialUnitStatus::UNIT_OKAY, 116 - DifferentialUnitTestResult::RESULT_POSTPONED => 117 - DifferentialUnitStatus::UNIT_POSTPONED, 118 - ); 119 - 120 - // These are the relative priorities for the unit test results 121 - $status_codes_priority = 122 - array( 123 - DifferentialUnitStatus::UNIT_OKAY => 1, 124 - DifferentialUnitStatus::UNIT_WARN => 2, 125 - DifferentialUnitStatus::UNIT_POSTPONED => 3, 126 - DifferentialUnitStatus::UNIT_FAIL => 4, 127 - ); 128 - 129 - // Walk the now-current list of status codes to find the overall diff 130 - // status 131 - $final_diff_status = DifferentialUnitStatus::UNIT_NONE; 132 - foreach ($unit_results as $unit_result) { 133 - // Convert the text result into a diff unit status value 134 - $status_code = idx($status_codes, 135 - $unit_result['result'], 136 - DifferentialUnitStatus::UNIT_NONE); 137 - 138 - // Convert the unit status into a relative value 139 - $diff_status_priority = idx($status_codes_priority, $status_code, 0); 140 - 141 - // If the relative value of this result is "more bad" than previous 142 - // results, use it as the new final diff status 143 - if ($diff_status_priority > idx($status_codes_priority, 144 - $final_diff_status, 0)) { 145 - $final_diff_status = $status_code; 146 - } 147 - } 148 - 149 - // Update our unit test result status with the final value 150 - $diff->setUnitStatus($final_diff_status); 151 - $diff->save(); 152 - } 153 - 154 - }
-10
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 191 191 $visible_changesets[$changeset_id] = $changesets[$changeset_id]; 192 192 } 193 193 } 194 - 195 - if (!empty($props['arc:lint'])) { 196 - $changeset_paths = mpull($changesets, null, 'getFilename'); 197 - foreach ($props['arc:lint'] as $lint) { 198 - $changeset = idx($changeset_paths, $lint['path']); 199 - if ($changeset) { 200 - $visible_changesets[$changeset->getID()] = $changeset; 201 - } 202 - } 203 - } 204 194 } else { 205 195 $warning = null; 206 196 $visible_changesets = $changesets;