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

Support blame on blame for svn

Summary:
add the column for the blame on blame for svn. We will support
git once we have the 'parent' info of the commits saved in the database
for git.

Test Plan:
in svn it should work. In git is doesn't break things.

Reviewed By: epriestley
Reviewers: epriestley
CC: epriestley
Differential Revision: 95

+89 -13
+71 -13
src/applications/diffusion/controller/file/DiffusionBrowseFileController.php
··· 26 26 'jpeg'=> 'image/jpeg' 27 27 ); 28 28 29 + 29 30 public function processRequest() { 30 31 31 32 // Build the view selection form. ··· 90 91 } 91 92 92 93 94 + /* 95 + * Returns a content-type corrsponding to an image file extension 96 + * 97 + * @param string $path File path 98 + * @return mixed A content-type string or NULL if path doesn't end with a 99 + * recognized image extension 100 + */ 101 + public function getImageType($path) { 102 + $ext = pathinfo($path); 103 + $ext = $ext['extension']; 104 + return idx($this->imageTypes, $ext); 105 + } 106 + 107 + 93 108 private function buildCorpus($selected) { 94 109 $needs_blame = ($selected == 'blame' || $selected == 'plainblame'); 95 110 ··· 166 181 implode("\n", $text_list))); 167 182 168 183 $rows = $this->buildDisplayRows($text_list, $rev_list, $blame_dict, 169 - $needs_blame, $drequest); 184 + $needs_blame, $drequest, $file_query, $selected); 170 185 171 186 $corpus_table = phutil_render_tag( 172 187 'table', ··· 189 204 190 205 191 206 private static function buildDisplayRows($text_list, $rev_list, $blame_dict, 192 - $needs_blame, DiffusionRequest $drequest) { 207 + $needs_blame, DiffusionRequest $drequest, $file_query, $selected) { 193 208 $last_rev = null; 194 209 $color = null; 195 210 $rows = array(); ··· 208 223 $rev = $rev_list[$k]; 209 224 if ($last_rev == $rev) { 210 225 $blame_info = 226 + ($file_query->getSupportsBlameOnBlame() ? 227 + '<th style="background: '.$color.'; width: 2em;"></th>' : ''). 211 228 '<th style="background: '.$color.'; width: 9em;"></th>'. 212 229 '<th style="background: '.$color.'"></th>'; 213 230 } else { ··· 220 237 $drequest, 221 238 substr($rev, 0, 7)); 222 239 240 + if (!$file_query->getSupportsBlameOnBlame()) { 241 + $prev_link = ''; 242 + } else { 243 + $prev_rev = $file_query->getPrevRev($rev); 244 + $path = $drequest->getPath(); 245 + $prev_link = self::renderBrowse( 246 + $drequest, 247 + $path, 248 + "\xC2\xAB", 249 + $prev_rev, 250 + $n, 251 + $selected); 252 + $prev_link = '<th style="background: ' . $color . 253 + '; width: 2em;">' . $prev_link . '</th>'; 254 + } 255 + 223 256 $author_link = $blame_dict[$rev]['author']; 224 257 $blame_info = 258 + $prev_link . 225 259 '<th style="background: '.$color. 226 260 '; width: 9em;">'.$revision_link.'</th>'. 227 261 '<th style="background: '.$color. ··· 278 312 } 279 313 280 314 281 - /** 282 - * Returns a content-type corrsponding to an image file extension 283 - * 284 - * @param string $path File path 285 - * @return mixed A content-type string or NULL if path doesn't end with a 286 - * recognized image extension 287 - */ 288 - public function getImageType($path) { 289 - $ext = pathinfo($path); 290 - $ext = $ext['extension']; 291 - return idx($this->imageTypes, $ext); 315 + private static function renderBrowse( 316 + DiffusionRequest $drequest, 317 + $path, 318 + $name = null, 319 + $rev = null, 320 + $line = null, 321 + $view = null) { 322 + 323 + $callsign = $drequest->getCallsign(); 324 + 325 + if ($name === null) { 326 + $name = $path; 327 + } 328 + 329 + $at = null; 330 + if ($rev) { 331 + $at = ';'.$rev; 332 + } 333 + 334 + if ($view) { 335 + $view = '?view='.$view; 336 + } 337 + 338 + if ($line) { 339 + $line = '$'.$line; 340 + } 341 + 342 + return phutil_render_tag( 343 + 'a', 344 + array( 345 + 'href' => "/diffusion/{$callsign}/browse/{$path}{$at}{$line}{$view}", 346 + ), 347 + $name 348 + ); 292 349 } 350 + 293 351 294 352 }
+10
src/applications/diffusion/query/filecontent/base/DiffusionFileContentQuery.php
··· 50 50 return $query; 51 51 } 52 52 53 + public function getSupportsBlameOnBlame() { 54 + return false; 55 + } 56 + 57 + public function getPrevRev($rev) { 58 + // TODO: support git once the 'parent' info of a commit is saved 59 + // to the database. 60 + throw new Exception("Unsupported VCS!"); 61 + } 62 + 53 63 final protected function getRequest() { 54 64 return $this->request; 55 65 }
+8
src/applications/diffusion/query/filecontent/svn/DiffusionSvnFileContentQuery.php
··· 18 18 19 19 final class DiffusionSvnFileContentQuery extends DiffusionFileContentQuery { 20 20 21 + public function getSupportsBlameOnBlame() { 22 + return true; 23 + } 24 + 25 + public function getPrevRev($rev) { 26 + return max($rev - 1, 0); 27 + } 28 + 21 29 protected function executeQuery() { 22 30 $drequest = $this->getRequest(); 23 31