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

Separate "Revision" and "Diff" fields in Differential

Summary:
Fixes T5138. Some of the "revision" properties are really "diff" properties, but we only show the properties for the most recent / current diff.

- Immediately, this makes it hard or impossible to review, e.g., lint/unit results for older diffs.
- Longer-term, these limits will become more problematic with more data on diffs after Harbormaster.

Instead, separate "revision" from "diff" properties.

(In the long term, it might make sense to show more diffs in this panel -- e.g., tabs for the 8 most recent updates or something -- but I went with the simplest approach for now since I don't have a clean way to deal with 100-update revisions offhand.)

Test Plan: {F500480}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: cburroughs, epriestley

Maniphest Tasks: T5138

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

+224 -60
+2 -2
src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
··· 34 34 new DifferentialReviewedByField(), 35 35 new DifferentialSubscribersField(), 36 36 new DifferentialRepositoryField(), 37 - new DifferentialLintField(), 38 37 new DifferentialProjectsField(), 39 - new DifferentialUnitField(), 40 38 new DifferentialViewPolicyField(), 41 39 new DifferentialEditPolicyField(), 42 40 ··· 54 52 new DifferentialBlameRevisionField(), 55 53 new DifferentialPathField(), 56 54 new DifferentialHostField(), 55 + new DifferentialLintField(), 56 + new DifferentialUnitField(), 57 57 new DifferentialRevertPlanField(), 58 58 59 59 new DifferentialApplyPatchField(),
+87 -21
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 206 206 $visible_changesets = $changesets; 207 207 } 208 208 209 - 210 - // TODO: This should be in a DiffQuery or similar. 211 - $need_props = array(); 212 - foreach ($field_list->getFields() as $field) { 213 - foreach ($field->getRequiredDiffPropertiesForRevisionView() as $prop) { 214 - $need_props[$prop] = $prop; 215 - } 216 - } 217 - 218 - if ($need_props) { 219 - $prop_diff = $revision->getActiveDiff(); 220 - $load_props = id(new DifferentialDiffProperty())->loadAllWhere( 221 - 'diffID = %d AND name IN (%Ls)', 222 - $prop_diff->getID(), 223 - $need_props); 224 - $load_props = mpull($load_props, 'getData', 'getName'); 225 - foreach ($need_props as $need) { 226 - $prop_diff->attachProperty($need, idx($load_props, $need)); 227 - } 228 - } 229 - 230 209 $commit_hashes = mpull($diffs, 'getSourceControlBaseRevision'); 231 210 $local_commits = idx($props, 'local:commits', array()); 232 211 foreach ($local_commits as $local_commit) { ··· 285 264 ->setErrors($revision_warnings); 286 265 $revision_detail_box->setInfoView($revision_warnings); 287 266 } 267 + 268 + $diff_detail_box = $this->buildDiffDetailView( 269 + array_select_keys($diffs, array($diff_vs, $target->getID())), 270 + $revision, 271 + $field_list); 288 272 289 273 $comment_view = $this->buildTransactions( 290 274 $revision, ··· 486 470 487 471 $content = array( 488 472 $revision_detail_box, 473 + $diff_detail_box, 489 474 $page_pane, 490 475 ); 491 476 ··· 973 958 974 959 return $warnings; 975 960 } 961 + 962 + private function buildDiffDetailView( 963 + array $diffs, 964 + DifferentialRevision $revision, 965 + PhabricatorCustomFieldList $field_list) { 966 + $viewer = $this->getViewer(); 967 + 968 + $fields = array(); 969 + foreach ($field_list->getFields() as $field) { 970 + if ($field->shouldAppearInDiffPropertyView()) { 971 + $fields[] = $field; 972 + } 973 + } 974 + 975 + if (!$fields) { 976 + return null; 977 + } 978 + 979 + // Make sure we're only going to render unique diffs. 980 + $diffs = mpull($diffs, null, 'getID'); 981 + $labels = array(pht('Left'), pht('Right')); 982 + 983 + $property_lists = array(); 984 + foreach ($diffs as $diff) { 985 + if (count($diffs) == 2) { 986 + $label = array_shift($labels); 987 + $label = pht('%s (Diff %d)', $label, $diff->getID()); 988 + } else { 989 + $label = pht('Diff %d', $diff->getID()); 990 + } 991 + 992 + $property_lists[] = array( 993 + $label, 994 + $this->buildDiffPropertyList($diff, $revision, $fields), 995 + ); 996 + } 997 + 998 + $box = id(new PHUIObjectBoxView()) 999 + ->setHeaderText(pht('Diff Detail')) 1000 + ->setUser($viewer); 1001 + 1002 + $last_tab = null; 1003 + foreach ($property_lists as $key => $property_list) { 1004 + list($tab_name, $list_view) = $property_list; 1005 + 1006 + $tab = id(new PHUIListItemView()) 1007 + ->setKey($key) 1008 + ->setName($tab_name); 1009 + 1010 + $box->addPropertyList($list_view, $tab); 1011 + $last_tab = $tab; 1012 + } 1013 + 1014 + if ($last_tab) { 1015 + $last_tab->setSelected(true); 1016 + } 1017 + 1018 + return $box; 1019 + } 1020 + 1021 + private function buildDiffPropertyList( 1022 + DifferentialDiff $diff, 1023 + DifferentialRevision $revision, 1024 + array $fields) { 1025 + $viewer = $this->getViewer(); 1026 + 1027 + $view = id(new PHUIPropertyListView()) 1028 + ->setUser($viewer) 1029 + ->setObject($diff); 1030 + 1031 + foreach ($fields as $field) { 1032 + $label = $field->renderDiffPropertyViewLabel($diff); 1033 + $value = $field->renderDiffPropertyViewValue($diff); 1034 + if ($value !== null) { 1035 + $view->addProperty($label, $value); 1036 + } 1037 + } 1038 + 1039 + return $view; 1040 + } 1041 + 976 1042 977 1043 }
+11 -3
src/applications/differential/customfield/DifferentialBranchField.php
··· 19 19 return true; 20 20 } 21 21 22 - public function renderPropertyViewLabel() { 22 + public function renderPropertyViewValue(array $handles) { 23 + return null; 24 + } 25 + 26 + public function shouldAppearInDiffPropertyView() { 27 + return true; 28 + } 29 + 30 + public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { 23 31 return $this->getFieldName(); 24 32 } 25 33 26 - public function renderPropertyViewValue(array $handles) { 27 - return $this->getBranchDescription($this->getObject()->getActiveDiff()); 34 + public function renderDiffPropertyViewValue(DifferentialDiff $diff) { 35 + return $this->getBranchDescription($diff); 28 36 } 29 37 30 38 private function getBranchDescription(DifferentialDiff $diff) {
+38 -7
src/applications/differential/customfield/DifferentialCustomField.php
··· 2 2 3 3 /** 4 4 * @task commitmessage Integration with Commit Messages 5 + * @task diff Integration with Diff Properties 5 6 */ 6 7 abstract class DifferentialCustomField 7 8 extends PhabricatorCustomField { ··· 29 30 } 30 31 31 32 return parent::shouldEnableForRole($role); 32 - } 33 - 34 - public function getRequiredDiffPropertiesForRevisionView() { 35 - if ($this->getProxy()) { 36 - return $this->getProxy()->getRequiredDiffPropertiesForRevisionView(); 37 - } 38 - return array(); 39 33 } 40 34 41 35 protected function parseObjectList( ··· 81 75 public function getWarningsForRevisionHeader(array $handles) { 82 76 return array(); 83 77 } 78 + 84 79 85 80 /* -( Integration with Commit Messages )----------------------------------- */ 86 81 ··· 215 210 return $this->getProxy()->validateCommitMessageValue($value); 216 211 } 217 212 return; 213 + } 214 + 215 + 216 + /* -( Integration with Diff Properties )----------------------------------- */ 217 + 218 + 219 + /** 220 + * @task diff 221 + */ 222 + public function shouldAppearInDiffPropertyView() { 223 + if ($this->getProxy()) { 224 + return $this->getProxy()->shouldAppearInDiffPropertyView(); 225 + } 226 + return false; 227 + } 228 + 229 + 230 + /** 231 + * @task diff 232 + */ 233 + public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { 234 + if ($this->proxy) { 235 + return $this->proxy->renderDiffPropertyViewLabel($diff); 236 + } 237 + return $this->getFieldName(); 238 + } 239 + 240 + 241 + /** 242 + * @task diff 243 + */ 244 + public function renderDiffPropertyViewValue(DifferentialDiff $diff) { 245 + if ($this->proxy) { 246 + return $this->proxy->renderDiffPropertyViewValue($diff); 247 + } 248 + throw new PhabricatorCustomFieldImplementationIncompleteException($this); 218 249 } 219 250 220 251 }
+11 -3
src/applications/differential/customfield/DifferentialHostField.php
··· 23 23 return true; 24 24 } 25 25 26 - public function renderPropertyViewLabel() { 26 + public function renderPropertyViewValue(array $handles) { 27 + return null; 28 + } 29 + 30 + public function shouldAppearInDiffPropertyView() { 31 + return true; 32 + } 33 + 34 + public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { 27 35 return $this->getFieldName(); 28 36 } 29 37 30 - public function renderPropertyViewValue(array $handles) { 31 - $host = $this->getObject()->getActiveDiff()->getSourceMachine(); 38 + public function renderDiffPropertyViewValue(DifferentialDiff $diff) { 39 + $host = $diff->getSourceMachine(); 32 40 if (!$host) { 33 41 return null; 34 42 }
+23 -6
src/applications/differential/customfield/DifferentialLintField.php
··· 19 19 return true; 20 20 } 21 21 22 - public function renderPropertyViewLabel() { 22 + public function renderPropertyViewValue(array $handles) { 23 + return null; 24 + } 25 + 26 + public function shouldAppearInDiffPropertyView() { 27 + return true; 28 + } 29 + 30 + public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { 23 31 return $this->getFieldName(); 24 32 } 25 33 26 - public function getRequiredDiffPropertiesForRevisionView() { 27 - return array( 34 + public function renderDiffPropertyViewValue(DifferentialDiff $diff) { 35 + // TODO: This load is slightly inefficient, but most of this is moving 36 + // to Harbormaster and this simplifies the transition. Eat 1-2 extra 37 + // queries for now. 38 + $keys = array( 28 39 'arc:lint', 29 40 'arc:lint-excuse', 30 41 'arc:lint-postponed', 31 42 ); 32 - } 33 43 34 - public function renderPropertyViewValue(array $handles) { 35 - $diff = $this->getObject()->getActiveDiff(); 44 + $properties = id(new DifferentialDiffProperty())->loadAllWhere( 45 + 'diffID = %d AND name IN (%Ls)', 46 + $diff->getID(), 47 + $keys); 48 + $properties = mpull($properties, 'getData', 'getName'); 49 + 50 + foreach ($keys as $key) { 51 + $diff->attachProperty($key, idx($properties, $key)); 52 + } 36 53 37 54 $path_changesets = mpull($diff->loadChangesets(), 'getID', 'getFilename'); 38 55
+11 -3
src/applications/differential/customfield/DifferentialPathField.php
··· 23 23 return true; 24 24 } 25 25 26 - public function renderPropertyViewLabel() { 26 + public function renderPropertyViewValue(array $handles) { 27 + return null; 28 + } 29 + 30 + public function shouldAppearInDiffPropertyView() { 31 + return true; 32 + } 33 + 34 + public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { 27 35 return $this->getFieldName(); 28 36 } 29 37 30 - public function renderPropertyViewValue(array $handles) { 31 - $path = $this->getObject()->getActiveDiff()->getSourcePath(); 38 + public function renderDiffPropertyViewValue(DifferentialDiff $diff) { 39 + $path = $diff->getSourcePath(); 32 40 if (!$path) { 33 41 return null; 34 42 }
+13 -9
src/applications/differential/customfield/DifferentialRepositoryField.php
··· 125 125 return true; 126 126 } 127 127 128 - public function renderPropertyViewLabel() { 128 + public function renderPropertyViewValue(array $handles) { 129 + return null; 130 + } 131 + 132 + public function shouldAppearInDiffPropertyView() { 133 + return true; 134 + } 135 + 136 + public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { 129 137 return $this->getFieldName(); 130 138 } 131 139 132 - public function getRequiredHandlePHIDsForPropertyView() { 133 - $repository_phid = $this->getObject()->getRepositoryPHID(); 134 - if ($repository_phid) { 135 - return array($repository_phid); 140 + public function renderDiffPropertyViewValue(DifferentialDiff $diff) { 141 + if (!$diff->getRepositoryPHID()) { 142 + return null; 136 143 } 137 - return array(); 138 - } 139 144 140 - public function renderPropertyViewValue(array $handles) { 141 - return $this->renderHandleList($handles); 145 + return $this->getViewer()->renderHandle($diff->getRepositoryPHID()); 142 146 } 143 147 144 148 public function shouldAppearInTransactionMail() {
+21 -6
src/applications/differential/customfield/DifferentialUnitField.php
··· 19 19 return true; 20 20 } 21 21 22 - public function renderPropertyViewLabel() { 22 + public function renderPropertyViewValue(array $handles) { 23 + return null; 24 + } 25 + 26 + public function shouldAppearInDiffPropertyView() { 27 + return true; 28 + } 29 + 30 + public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { 23 31 return $this->getFieldName(); 24 32 } 25 33 26 - public function getRequiredDiffPropertiesForRevisionView() { 27 - return array( 34 + public function renderDiffPropertyViewValue(DifferentialDiff $diff) { 35 + // TODO: See DifferentialLintField. 36 + $keys = array( 28 37 'arc:unit', 29 38 'arc:unit-excuse', 30 39 ); 31 - } 40 + 41 + $properties = id(new DifferentialDiffProperty())->loadAllWhere( 42 + 'diffID = %d AND name IN (%Ls)', 43 + $diff->getID(), 44 + $keys); 45 + $properties = mpull($properties, 'getData', 'getName'); 32 46 33 - public function renderPropertyViewValue(array $handles) { 34 - $diff = $this->getObject()->getActiveDiff(); 47 + foreach ($keys as $key) { 48 + $diff->attachProperty($key, idx($properties, $key)); 49 + } 35 50 36 51 $ustar = DifferentialRevisionUpdateHistoryView::renderDiffUnitStar($diff); 37 52 $umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff);
+7
src/applications/harbormaster/event/HarbormasterUIEventListener.php
··· 31 31 return; 32 32 } 33 33 34 + if ($object instanceof DifferentialRevision) { 35 + // TODO: This is a bit hacky and we could probably find a cleaner fix 36 + // eventually, but we show build status on each diff, immediately below 37 + // this property list, so it's redundant to show it on the revision view. 38 + return; 39 + } 40 + 34 41 if (!($object instanceof HarbormasterBuildableInterface)) { 35 42 return; 36 43 }