@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 the revision list view a bit.

+179 -11
+1 -1
src/__celerity_resource_map__.php
··· 118 118 ), 119 119 'differential-revision-comment-css' => 120 120 array( 121 - 'uri' => '/res/21572195/rsrc/css/application/differential/revision-comment.css', 121 + 'uri' => '/res/bf6369c6/rsrc/css/application/differential/revision-comment.css', 122 122 'type' => 'css', 123 123 'requires' => 124 124 array(
+3
src/__phutil_library_map__.php
··· 176 176 'celerity_generate_unique_node_id' => 'infratructure/celerity/api', 177 177 'celerity_register_resource_map' => 'infratructure/celerity/map', 178 178 'javelin_render_tag' => 'infratructure/javelin/markup', 179 + 'phabricator_format_relative_time' => 'view/utils', 180 + 'phabricator_format_timestamp' => 'view/utils', 181 + 'phabricator_format_units_generic' => 'view/utils', 179 182 'qsprintf' => 'storage/qsprintf', 180 183 'queryfx' => 'storage/queryfx', 181 184 'queryfx_all' => 'storage/queryfx',
+75 -9
src/applications/differential/controller/revisionlist/DifferentialRevisionListController.php
··· 113 113 phutil_escape_html($filter_desc['name']))); 114 114 } 115 115 116 + $phids = array(); 117 + $rev_ids = array(); 118 + foreach ($queries as $key => $query) { 119 + $revisions = $query['object']->loadRevisions(); 120 + foreach ($revisions as $revision) { 121 + $phids[$revision->getAuthorPHID()] = true; 122 + $rev_ids[$revision->getID()] = true; 123 + } 124 + $queries[$key]['revisions'] = $revisions; 125 + } 126 + 127 + $rev = new DifferentialRevision(); 128 + if ($rev_ids) { 129 + $rev_ids = array_keys($rev_ids); 130 + $reviewers = queryfx_all( 131 + $rev->establishConnection('r'), 132 + 'SELECT revisionID, objectPHID FROM %T revision JOIN %T relationship 133 + ON revision.id = relationship.revisionID 134 + WHERE revision.id IN (%Ld) 135 + AND relationship.relation = %s 136 + AND relationship.forbidden = 0 137 + ORDER BY sequence', 138 + $rev->getTableName(), 139 + DifferentialRevision::RELATIONSHIP_TABLE, 140 + $rev_ids, 141 + DifferentialRevision::RELATION_REVIEWER); 142 + 143 + $reviewer_map = array(); 144 + foreach ($reviewers as $reviewer) { 145 + $reviewer_map[$reviewer['revisionID']][] = $reviewer['objectPHID']; 146 + } 147 + foreach ($reviewer_map as $revision_id => $reviewer_ids) { 148 + $phids[reset($reviewer_ids)] = true; 149 + } 150 + } else { 151 + $reviewer_map = array(); 152 + } 153 + 154 + if ($phids) { 155 + $phids = array_keys($phids); 156 + $handles = id(new PhabricatorObjectHandleData($phids)) 157 + ->loadHandles(); 158 + } else { 159 + $handles = array(); 160 + } 161 + 116 162 foreach ($queries as $query) { 117 163 $table = $this->renderRevisionTable( 118 - $query['object']->loadRevisions(), 164 + $query['revisions'], 119 165 $query['header'], 120 - idx($query, 'nodata')); 166 + idx($query, 'nodata'), 167 + $handles, 168 + $reviewer_map); 121 169 $side_nav->appendChild($table); 122 170 } 123 171 ··· 128 176 )); 129 177 } 130 178 131 - private function renderRevisionTable(array $revisions, $header, $nodata) { 179 + private function renderRevisionTable( 180 + array $revisions, 181 + $header, 182 + $nodata, 183 + array $handles, 184 + array $reviewer_map) { 132 185 133 186 $rows = array(); 134 187 foreach ($revisions as $revision) { 135 188 $status = DifferentialRevisionStatus::getNameForRevisionStatus( 136 189 $revision->getStatus()); 137 190 191 + $reviewers = idx($reviewer_map, $revision->getID(), array()); 192 + if ($reviewers) { 193 + $first = reset($reviewers); 194 + if (count($reviewers) > 1) { 195 + $suffix = ' (+'.(count($reviewers) - 1).')'; 196 + } else { 197 + $suffix = null; 198 + } 199 + $reviewers = $handles[$first]->renderLink().$suffix; 200 + } else { 201 + $reviewers = '<em>None</em>'; 202 + } 203 + 138 204 $rows[] = array( 139 205 'D'.$revision->getID(), 140 - phutil_render_tag( 206 + '<strong>'.phutil_render_tag( 141 207 'a', 142 208 array( 143 209 'href' => '/D'.$revision->getID(), 144 210 ), 145 - phutil_escape_html($revision->getTitle())), 211 + phutil_escape_html($revision->getTitle())).'</strong>', 146 212 phutil_escape_html($status), 147 213 number_format($revision->getLineCount()), 148 - $revision->getAuthorPHID(), 149 - 'TODO', 150 - $revision->getDateModified(), 151 - $revision->getDateCreated(), 214 + $handles[$revision->getAuthorPHID()]->renderLink(), 215 + $reviewers, 216 + phabricator_format_timestamp($revision->getDateModified()), 217 + phabricator_format_timestamp($revision->getDateCreated()), 152 218 ); 153 219 } 154 220
+4
src/applications/differential/controller/revisionlist/__init__.php
··· 9 9 phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus'); 10 10 phutil_require_module('phabricator', 'applications/differential/controller/base'); 11 11 phutil_require_module('phabricator', 'applications/differential/data/revisionlist'); 12 + phutil_require_module('phabricator', 'applications/differential/storage/revision'); 13 + phutil_require_module('phabricator', 'applications/phid/handle/data'); 14 + phutil_require_module('phabricator', 'storage/queryfx'); 12 15 phutil_require_module('phabricator', 'view/control/table'); 13 16 phutil_require_module('phabricator', 'view/layout/panel'); 14 17 phutil_require_module('phabricator', 'view/layout/sidenav'); 18 + phutil_require_module('phabricator', 'view/utils'); 15 19 16 20 phutil_require_module('phutil', 'markup'); 17 21 phutil_require_module('phutil', 'utils');
+1 -1
src/applications/differential/data/revisionlist/DifferentialRevisionListData.php
··· 229 229 230 230 $data = vqueryfx_all( 231 231 $rev->establishConnection('r'), 232 - 'SELECT * FROM %T revision WHERE '.$pattern, 232 + 'SELECT * FROM %T revision WHERE '.$pattern.' '.$this->getOrderClause(), 233 233 $argv); 234 234 235 235 return $rev->loadAllFromArray($data);
+10
src/view/utils/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + 10 + phutil_require_source('viewutils.php');
+85
src/view/utils/viewutils.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + function phabricator_format_relative_time($duration) { 20 + return phabricator_format_units_generic( 21 + $duration, 22 + array(60, 60, 24, 7), 23 + array('s', 'm', 'h', 'd', 'w'), 24 + $precision = 0); 25 + } 26 + 27 + function phabricator_format_timestamp($epoch) { 28 + $difference = (time() - $epoch); 29 + 30 + if ($difference < 60 * 60) { 31 + return phabricator_format_relative_time($difference).' ago'; 32 + } else if (date('Y') == date('Y', $epoch)) { 33 + return date('M jS, g:i A', $epoch); 34 + } else { 35 + return date('F jS, Y', $epoch); 36 + } 37 + } 38 + 39 + function phabricator_format_units_generic( 40 + $n, 41 + array $scales, 42 + array $labels, 43 + $precision = 0, 44 + &$remainder = null) { 45 + 46 + $is_negative = false; 47 + if ($n < 0) { 48 + $is_negative = true; 49 + $n = abs($n); 50 + } 51 + 52 + $remainder = 0; 53 + $accum = 1; 54 + 55 + $scale = array_shift($scales); 56 + $label = array_shift($labels); 57 + while ($n > $scale && count($labels)) { 58 + $remainder += ($n % $scale) * $accum; 59 + $n /= $scale; 60 + $accum *= $scale; 61 + $label = array_shift($labels); 62 + if (!count($scales)) { 63 + break; 64 + } 65 + $scale = array_shift($scales); 66 + } 67 + 68 + if ($is_negative) { 69 + $n = -$n; 70 + $remainder = -$remainder; 71 + } 72 + 73 + if ($precision) { 74 + $num_string = number_format($n, $precision); 75 + } else { 76 + $num_string = (int)floor($n); 77 + } 78 + 79 + if ($label) { 80 + $num_string .= ' '.$label; 81 + } 82 + 83 + return $num_string; 84 + } 85 +