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

Differential - modernize "Local Commits" table

Summary: ...also link to commits we know about in "Local Commits" and "Revision Update History" tables. Fixes T4585.

Test Plan: made a repo. made a diff (foo) and committed it (bar). made a new diff that was comprised of two local commits. noted links to (bar) in various commit hashes as expected

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin, chad

Maniphest Tasks: T4585

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

+118 -98
+2 -5
resources/celerity/map.php
··· 10 10 'core.pkg.css' => 'fb144113', 11 11 'core.pkg.js' => 'd3fecc57', 12 12 'darkconsole.pkg.js' => 'ca8671ce', 13 - 'differential.pkg.css' => 'cb97e095', 13 + 'differential.pkg.css' => '3ad9692c', 14 14 'differential.pkg.js' => '11a5b750', 15 15 'diffusion.pkg.css' => '3783278d', 16 16 'diffusion.pkg.js' => '5b4010f4', ··· 57 57 'rsrc/css/application/differential/add-comment.css' => 'c478bcaa', 58 58 'rsrc/css/application/differential/changeset-view.css' => 'e710a360', 59 59 'rsrc/css/application/differential/core.css' => '7ac3cabc', 60 - 'rsrc/css/application/differential/local-commits-view.css' => '19649019', 61 60 'rsrc/css/application/differential/results-table.css' => '239924f9', 62 61 'rsrc/css/application/differential/revision-comment.css' => '48186045', 63 62 'rsrc/css/application/differential/revision-history.css' => '0e8eb855', ··· 509 508 'differential-changeset-view-css' => 'e710a360', 510 509 'differential-core-view-css' => '7ac3cabc', 511 510 'differential-inline-comment-editor' => 'f2441746', 512 - 'differential-local-commits-view-css' => '19649019', 513 511 'differential-results-table-css' => '239924f9', 514 512 'differential-revision-add-comment-css' => 'c478bcaa', 515 513 'differential-revision-comment-css' => '48186045', ··· 2121 2119 7 => 'differential-revision-add-comment-css', 2122 2120 8 => 'phabricator-object-selector-css', 2123 2121 9 => 'phabricator-content-source-view-css', 2124 - 10 => 'differential-local-commits-view-css', 2125 - 11 => 'inline-comment-summary-css', 2122 + 10 => 'inline-comment-summary-css', 2126 2123 ), 2127 2124 'differential.pkg.js' => 2128 2125 array(
-1
resources/celerity/packages.php
··· 126 126 'differential-revision-add-comment-css', 127 127 'phabricator-object-selector-css', 128 128 'phabricator-content-source-view-css', 129 - 'differential-local-commits-view-css', 130 129 'inline-comment-summary-css', 131 130 ), 132 131 'differential.pkg.js' => array(
+23 -9
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 186 186 } 187 187 } 188 188 189 + $commit_hashes = mpull($diffs, 'getSourceControlBaseRevision'); 190 + $local_commits = idx($props, 'local:commits', array()); 191 + foreach ($local_commits as $local_commit) { 192 + $commit_hashes[] = idx($local_commit, 'tree'); 193 + $commit_hashes[] = idx($local_commit, 'local'); 194 + } 195 + $commit_hashes = array_unique(array_filter($commit_hashes)); 196 + $commits_for_links = id(new DiffusionCommitQuery()) 197 + ->setViewer($user) 198 + ->withIdentifiers($commit_hashes) 199 + ->execute(); 200 + $commits_for_links = mpull($commits_for_links, null, 'getCommitIdentifier'); 189 201 190 202 $revision_detail = id(new DifferentialRevisionDetailView()) 191 203 ->setUser($user) ··· 267 279 $changeset_view->setSymbolIndexes($symbol_indexes); 268 280 $changeset_view->setTitle('Diff '.$target->getID()); 269 281 270 - $diff_history = new DifferentialRevisionUpdateHistoryView(); 271 - $diff_history->setDiffs($diffs); 272 - $diff_history->setSelectedVersusDiffID($diff_vs); 273 - $diff_history->setSelectedDiffID($target->getID()); 274 - $diff_history->setSelectedWhitespace($whitespace); 275 - $diff_history->setUser($user); 282 + $diff_history = id(new DifferentialRevisionUpdateHistoryView()) 283 + ->setUser($user) 284 + ->setDiffs($diffs) 285 + ->setSelectedVersusDiffID($diff_vs) 286 + ->setSelectedDiffID($target->getID()) 287 + ->setSelectedWhitespace($whitespace) 288 + ->setCommitsForLinks($commits_for_links); 276 289 277 - $local_view = new DifferentialLocalCommitsView(); 278 - $local_view->setUser($user); 279 - $local_view->setLocalCommits(idx($props, 'local:commits')); 290 + $local_view = id(new DifferentialLocalCommitsView()) 291 + ->setUser($user) 292 + ->setLocalCommits(idx($props, 'local:commits')) 293 + ->setCommitsForLinks($commits_for_links); 280 294 281 295 if ($repository) { 282 296 $other_revisions = $this->loadOtherRevisions(
+56 -48
src/applications/differential/view/DifferentialLocalCommitsView.php
··· 3 3 final class DifferentialLocalCommitsView extends AphrontView { 4 4 5 5 private $localCommits; 6 + private $commitsForLinks = array(); 6 7 7 8 public function setLocalCommits($local_commits) { 8 9 $this->localCommits = $local_commits; 10 + return $this; 11 + } 12 + 13 + public function setCommitsForLinks(array $commits) { 14 + assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 15 + $this->commitsForLinks = $commits; 9 16 return $this; 10 17 } 11 18 ··· 20 27 return null; 21 28 } 22 29 23 - $this->requireResource('differential-local-commits-view-css'); 24 - 25 30 $has_tree = false; 26 31 $has_local = false; 27 32 ··· 35 40 } 36 41 37 42 $rows = array(); 38 - $highlight = true; 39 43 foreach ($local as $commit) { 40 - if ($highlight) { 41 - $class = 'alt'; 42 - $highlight = false; 43 - } else { 44 - $class = ''; 45 - $highlight = true; 46 - } 47 - 48 - 49 44 $row = array(); 50 45 if (idx($commit, 'commit')) { 51 - $commit_hash = self::formatCommit($commit['commit']); 46 + $commit_link = $this->buildCommitLink($commit['commit']); 52 47 } else if (isset($commit['rev'])) { 53 - $commit_hash = self::formatCommit($commit['rev']); 48 + $commit_link = $this->buildCommitLink($commit['rev']); 54 49 } else { 55 - $commit_hash = null; 50 + $commit_link = null; 56 51 } 57 - $row[] = phutil_tag('td', array(), $commit_hash); 52 + $row[] = $commit_link; 58 53 59 54 if ($has_tree) { 60 - $tree = idx($commit, 'tree'); 61 - $tree = self::formatCommit($tree); 62 - $row[] = phutil_tag('td', array(), $tree); 55 + $row[] = $this->buildCommitLink($commit['tree']); 63 56 } 64 57 65 58 if ($has_local) { 66 - $local_rev = idx($commit, 'local', null); 67 - $row[] = phutil_tag('td', array(), $local_rev); 59 + $row[] = $this->buildCommitLink($commit['local']); 68 60 } 69 61 70 62 $parents = idx($commit, 'parents', array()); ··· 72 64 if (is_array($parent)) { 73 65 $parent = idx($parent, 'rev'); 74 66 } 75 - $parents[$k] = self::formatCommit($parent); 67 + $parents[$k] = $this->buildCommitLink($parent); 76 68 } 77 69 $parents = phutil_implode_html(phutil_tag('br'), $parents); 78 - $row[] = phutil_tag('td', array(), $parents); 70 + $row[] = $parents; 79 71 80 72 $author = nonempty( 81 73 idx($commit, 'user'), 82 74 idx($commit, 'author')); 83 - $row[] = phutil_tag('td', array(), $author); 75 + $row[] = $author; 84 76 85 77 $message = idx($commit, 'message'); 86 78 ··· 94 86 $view->setMore(phutil_escape_html_newlines($message)); 95 87 } 96 88 97 - $row[] = phutil_tag( 98 - 'td', 99 - array( 100 - 'class' => 'summary', 101 - ), 102 - $view->render()); 89 + $row[] = $view->render(); 103 90 104 91 $date = nonempty( 105 92 idx($commit, 'date'), ··· 107 94 if ($date) { 108 95 $date = phabricator_datetime($date, $user); 109 96 } 110 - $row[] = phutil_tag('td', array(), $date); 97 + $row[] = $date; 111 98 112 - $rows[] = phutil_tag('tr', array('class' => $class), $row); 99 + $rows[] = $row; 113 100 } 114 101 115 - 102 + $column_classes = array(''); 103 + if ($has_tree) { 104 + $column_classes[] = ''; 105 + } 106 + if ($has_local) { 107 + $column_classes[] = ''; 108 + } 109 + $column_classes[] = ''; 110 + $column_classes[] = ''; 111 + $column_classes[] = 'wide'; 112 + $column_classes[] = 'date'; 113 + $table = id(new AphrontTableView($rows)) 114 + ->setColumnClasses($column_classes); 116 115 $headers = array(); 117 - $headers[] = phutil_tag('th', array(), pht('Commit')); 116 + $headers[] = pht('Commit'); 118 117 if ($has_tree) { 119 - $headers[] = phutil_tag('th', array(), pht('Tree')); 118 + $headers[] = pht('Tree'); 120 119 } 121 120 if ($has_local) { 122 - $headers[] = phutil_tag('th', array(), pht('Local')); 121 + $headers[] = pht('Local'); 123 122 } 124 - $headers[] = phutil_tag('th', array(), pht('Parents')); 125 - $headers[] = phutil_tag('th', array(), pht('Author')); 126 - $headers[] = phutil_tag('th', array(), pht('Summary')); 127 - $headers[] = phutil_tag('th', array(), pht('Date')); 128 - 129 - $headers = phutil_tag('tr', array(), $headers); 130 - 131 - $content = phutil_tag_div('differential-panel', phutil_tag( 132 - 'table', 133 - array('class' => 'differential-local-commits-table'), 134 - array($headers, phutil_implode_html("\n", $rows)))); 123 + $headers[] = pht('Parents'); 124 + $headers[] = pht('Author'); 125 + $headers[] = pht('Summary'); 126 + $headers[] = pht('Date'); 127 + $table->setHeaders($headers); 135 128 136 129 return id(new PHUIObjectBoxView()) 137 130 ->setHeaderText(pht('Local Commits')) 138 - ->appendChild($content); 131 + ->appendChild($table); 139 132 } 140 133 141 134 private static function formatCommit($commit) { 142 135 return substr($commit, 0, 12); 136 + } 137 + 138 + private function buildCommitLink($hash) { 139 + $commit_for_link = idx($this->commitsForLinks, $hash); 140 + $commit_hash = self::formatCommit($hash); 141 + if ($commit_for_link) { 142 + $link = phutil_tag( 143 + 'a', 144 + array( 145 + 'href' => $commit_for_link->getURI()), 146 + $commit_hash); 147 + } else { 148 + $link = $commit_hash; 149 + } 150 + return $link; 143 151 } 144 152 145 153 }
+29 -4
src/applications/differential/view/DifferentialRevisionUpdateHistoryView.php
··· 6 6 private $selectedVersusDiffID; 7 7 private $selectedDiffID; 8 8 private $selectedWhitespace; 9 + private $commitsForLinks = array(); 9 10 10 11 public function setDiffs(array $diffs) { 11 12 assert_instances_of($diffs, 'DifferentialDiff'); ··· 25 26 26 27 public function setSelectedWhitespace($whitespace) { 27 28 $this->selectedWhitespace = $whitespace; 29 + return $this; 30 + } 31 + 32 + public function setCommitsForLinks(array $commits) { 33 + assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 34 + $this->commitsForLinks = $commits; 28 35 return $this; 29 36 } 30 37 ··· 378 385 case 'git': 379 386 $base = $diff->getSourceControlBaseRevision(); 380 387 if (strpos($base, '@') === false) { 381 - return substr($base, 0, 7); 388 + $label = substr($base, 0, 7); 382 389 } else { 383 390 // The diff is from git-svn 384 391 $base = explode('@', $base); 385 392 $base = last($base); 386 - return $base; 393 + $label = $base; 387 394 } 395 + break; 388 396 case 'svn': 389 397 $base = $diff->getSourceControlBaseRevision(); 390 398 $base = explode('@', $base); 391 399 $base = last($base); 392 - return $base; 400 + $label = $base; 401 + break; 393 402 default: 394 - return null; 403 + $label = null; 404 + break; 395 405 } 406 + $link = null; 407 + if ($label) { 408 + $commit_for_link = idx( 409 + $this->commitsForLinks, 410 + $diff->getSourceControlBaseRevision()); 411 + if ($commit_for_link) { 412 + $link = phutil_tag( 413 + 'a', 414 + array('href' => $commit_for_link->getURI()), 415 + $label); 416 + } else { 417 + $link = $label; 418 + } 419 + } 420 + return $link; 396 421 } 397 422 }
+1 -2
src/applications/repository/phid/PhabricatorRepositoryPHIDTypeCommit.php
··· 32 32 foreach ($handles as $phid => $handle) { 33 33 $commit = $objects[$phid]; 34 34 $repository = $commit->getRepository(); 35 - $callsign = $repository->getCallsign(); 36 35 $commit_identifier = $commit->getCommitIdentifier(); 37 36 38 37 $name = $repository->formatCommitName($commit_identifier); ··· 45 44 46 45 $handle->setName($name); 47 46 $handle->setFullName($full_name); 48 - $handle->setURI('/r'.$callsign.$commit_identifier); 47 + $handle->setURI($commit->getURI()); 49 48 $handle->setTimestamp($commit->getEpoch()); 50 49 } 51 50 }
+7
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 130 130 return $this->getEpoch(); 131 131 } 132 132 133 + public function getURI() { 134 + $repository = $this->getRepository(); 135 + $callsign = $repository->getCallsign(); 136 + $commit_identifier = $this->getCommitIdentifier(); 137 + return '/r'.$callsign.$commit_identifier; 138 + } 139 + 133 140 /** 134 141 * Synchronize a commit's overall audit status with the individual audit 135 142 * triggers.
-29
webroot/rsrc/css/application/differential/local-commits-view.css
··· 1 - /** 2 - * @provides differential-local-commits-view-css 3 - */ 4 - 5 - .differential-local-commits-table { 6 - width: 100%; 7 - border-collapse: separate; 8 - border-spacing: 1px 2px; 9 - } 10 - 11 - .differential-local-commits-table th { 12 - color: {$darkbluetext}; 13 - padding: 4px 6px; 14 - } 15 - 16 - .differential-local-commits-table tr.alt td { 17 - background: {$lightgreybackground}; 18 - } 19 - 20 - .differential-local-commits-table td { 21 - padding: 4px 6px; 22 - white-space: nowrap; 23 - vertical-align: top; 24 - } 25 - 26 - .differential-local-commits-table td.summary { 27 - white-space: normal; 28 - width: 100%; 29 - }