Skip to content

Commit 8ab1789

Browse files
author
vrana
committed
Improve displaying of very large commits
Summary: Behave like Differential. Also save one path ID query. Test Plan: Displayed very large commit, clicked in ToC, clicked on Load. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3176
1 parent e8401e6 commit 8ab1789

File tree

5 files changed

+82
-48
lines changed

5 files changed

+82
-48
lines changed

src/__celerity_resource_map__.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@
11381138
),
11391139
'javelin-behavior-differential-populate' =>
11401140
array(
1141-
'uri' => '/res/cf4691f5/rsrc/js/application/differential/behavior-populate.js',
1141+
'uri' => '/res/781dd9a5/rsrc/js/application/differential/behavior-populate.js',
11421142
'type' => 'js',
11431143
'requires' =>
11441144
array(
@@ -2885,7 +2885,7 @@
28852885
'uri' => '/res/pkg/96bc37d6/differential.pkg.css',
28862886
'type' => 'css',
28872887
),
2888-
'df1fdda8' =>
2888+
'6617163c' =>
28892889
array(
28902890
'name' => 'differential.pkg.js',
28912891
'symbols' =>
@@ -2909,7 +2909,7 @@
29092909
16 => 'javelin-behavior-differential-dropdown-menus',
29102910
17 => 'javelin-behavior-buoyant',
29112911
),
2912-
'uri' => '/res/pkg/df1fdda8/differential.pkg.js',
2912+
'uri' => '/res/pkg/6617163c/differential.pkg.js',
29132913
'type' => 'js',
29142914
),
29152915
'c8ce2d88' =>
@@ -3017,7 +3017,7 @@
30173017
'aphront-typeahead-control-css' => '8b65e80d',
30183018
'differential-changeset-view-css' => '96bc37d6',
30193019
'differential-core-view-css' => '96bc37d6',
3020-
'differential-inline-comment-editor' => 'df1fdda8',
3020+
'differential-inline-comment-editor' => '6617163c',
30213021
'differential-local-commits-view-css' => '96bc37d6',
30223022
'differential-results-table-css' => '96bc37d6',
30233023
'differential-revision-add-comment-css' => '96bc37d6',
@@ -3030,21 +3030,21 @@
30303030
'inline-comment-summary-css' => '96bc37d6',
30313031
'javelin-behavior' => '6fb20113',
30323032
'javelin-behavior-aphront-basic-tokenizer' => '97f65640',
3033-
'javelin-behavior-aphront-drag-and-drop' => 'df1fdda8',
3034-
'javelin-behavior-aphront-drag-and-drop-textarea' => 'df1fdda8',
3033+
'javelin-behavior-aphront-drag-and-drop' => '6617163c',
3034+
'javelin-behavior-aphront-drag-and-drop-textarea' => '6617163c',
30353035
'javelin-behavior-aphront-form-disable-on-submit' => '971b021e',
30363036
'javelin-behavior-audit-preview' => '5e68be89',
3037-
'javelin-behavior-buoyant' => 'df1fdda8',
3038-
'javelin-behavior-differential-accept-with-errors' => 'df1fdda8',
3039-
'javelin-behavior-differential-add-reviewers-and-ccs' => 'df1fdda8',
3040-
'javelin-behavior-differential-comment-jump' => 'df1fdda8',
3041-
'javelin-behavior-differential-diff-radios' => 'df1fdda8',
3042-
'javelin-behavior-differential-dropdown-menus' => 'df1fdda8',
3043-
'javelin-behavior-differential-edit-inline-comments' => 'df1fdda8',
3044-
'javelin-behavior-differential-feedback-preview' => 'df1fdda8',
3045-
'javelin-behavior-differential-keyboard-navigation' => 'df1fdda8',
3046-
'javelin-behavior-differential-populate' => 'df1fdda8',
3047-
'javelin-behavior-differential-show-more' => 'df1fdda8',
3037+
'javelin-behavior-buoyant' => '6617163c',
3038+
'javelin-behavior-differential-accept-with-errors' => '6617163c',
3039+
'javelin-behavior-differential-add-reviewers-and-ccs' => '6617163c',
3040+
'javelin-behavior-differential-comment-jump' => '6617163c',
3041+
'javelin-behavior-differential-diff-radios' => '6617163c',
3042+
'javelin-behavior-differential-dropdown-menus' => '6617163c',
3043+
'javelin-behavior-differential-edit-inline-comments' => '6617163c',
3044+
'javelin-behavior-differential-feedback-preview' => '6617163c',
3045+
'javelin-behavior-differential-keyboard-navigation' => '6617163c',
3046+
'javelin-behavior-differential-populate' => '6617163c',
3047+
'javelin-behavior-differential-show-more' => '6617163c',
30483048
'javelin-behavior-diffusion-commit-graph' => '5e68be89',
30493049
'javelin-behavior-diffusion-pull-lastmodified' => '5e68be89',
30503050
'javelin-behavior-maniphest-batch-selector' => '7707de41',
@@ -3054,12 +3054,12 @@
30543054
'javelin-behavior-maniphest-transaction-preview' => '7707de41',
30553055
'javelin-behavior-phabricator-autofocus' => '971b021e',
30563056
'javelin-behavior-phabricator-keyboard-shortcuts' => '971b021e',
3057-
'javelin-behavior-phabricator-object-selector' => 'df1fdda8',
3057+
'javelin-behavior-phabricator-object-selector' => '6617163c',
30583058
'javelin-behavior-phabricator-oncopy' => '971b021e',
30593059
'javelin-behavior-phabricator-tooltips' => '971b021e',
30603060
'javelin-behavior-phabricator-watch-anchor' => '971b021e',
30613061
'javelin-behavior-refresh-csrf' => '971b021e',
3062-
'javelin-behavior-repository-crossreference' => 'df1fdda8',
3062+
'javelin-behavior-repository-crossreference' => '6617163c',
30633063
'javelin-behavior-workflow' => '971b021e',
30643064
'javelin-dom' => '6fb20113',
30653065
'javelin-event' => '6fb20113',
@@ -3085,7 +3085,7 @@
30853085
'phabricator-core-buttons-css' => '8b65e80d',
30863086
'phabricator-core-css' => '8b65e80d',
30873087
'phabricator-directory-css' => '8b65e80d',
3088-
'phabricator-drag-and-drop-file-upload' => 'df1fdda8',
3088+
'phabricator-drag-and-drop-file-upload' => '6617163c',
30893089
'phabricator-dropdown-menu' => '971b021e',
30903090
'phabricator-flag-css' => '8b65e80d',
30913091
'phabricator-jump-nav' => '8b65e80d',
@@ -3097,7 +3097,7 @@
30973097
'phabricator-prefab' => '971b021e',
30983098
'phabricator-project-tag-css' => '7839ae2d',
30993099
'phabricator-remarkup-css' => '8b65e80d',
3100-
'phabricator-shaped-request' => 'df1fdda8',
3100+
'phabricator-shaped-request' => '6617163c',
31013101
'phabricator-standard-page-view' => '8b65e80d',
31023102
'phabricator-tooltip' => '971b021e',
31033103
'phabricator-transaction-view-css' => '8b65e80d',

src/applications/diffusion/controller/DiffusionCommitController.php

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@ public function processRequest() {
114114

115115
$content[] = $this->buildMergesTable($commit);
116116

117-
$original_changes_count = count($changes);
118-
if ($request->getStr('show_all') !== 'true' &&
119-
$original_changes_count > self::CHANGES_LIMIT) {
120-
$changes = array_slice($changes, 0, self::CHANGES_LIMIT);
121-
}
122-
123117
$owners_paths = array();
124118
if ($this->highlightedAudits) {
125119
$packages = id(new PhabricatorOwnersPackage())->loadAllWhere(
@@ -180,7 +174,7 @@ public function processRequest() {
180174
$change_panel->setHeader("Changes (".number_format($count).")");
181175
$change_panel->setID('differential-review-toc');
182176

183-
if ($count !== $original_changes_count) {
177+
if ($count > self::CHANGES_LIMIT) {
184178
$show_all_button = phutil_render_tag(
185179
'a',
186180
array(
@@ -190,10 +184,9 @@ public function processRequest() {
190184
phutil_escape_html('Show All Changes'));
191185
$warning_view = id(new AphrontErrorView())
192186
->setSeverity(AphrontErrorView::SEVERITY_WARNING)
193-
->setTitle(sprintf(
194-
"Showing only the first %d changes out of %s!",
195-
self::CHANGES_LIMIT,
196-
number_format($original_changes_count)));
187+
->setTitle('Very Large Commit')
188+
->appendChild(
189+
"<p>This commit is very large. Load each file individually.</p>");
197190

198191
$change_panel->appendChild($warning_view);
199192
$change_panel->addButton($show_all_button);
@@ -240,16 +233,31 @@ public function processRequest() {
240233
// DifferentialChangeset. Make the objects ephemeral to make sure we don't
241234
// accidentally save them, and then set their ID to the appropriate ID for
242235
// this application (the path IDs).
243-
$pquery = new DiffusionPathIDQuery(mpull($changesets, 'getFilename'));
244-
$path_ids = $pquery->loadPathIDs();
236+
$path_ids = array_flip(mpull($changes, 'getPath'));
245237
foreach ($changesets as $changeset) {
246238
$changeset->makeEphemeral();
247239
$changeset->setID($path_ids[$changeset->getFilename()]);
248240
}
249241

242+
if ($count <= self::CHANGES_LIMIT) {
243+
$visible_changesets = $changesets;
244+
} else {
245+
$visible_changesets = array();
246+
$inlines = id(new PhabricatorAuditInlineComment())->loadAllWhere(
247+
'commitPHID = %s AND (auditCommentID IS NOT NULL OR authorPHID = %s)',
248+
$commit->getPHID(),
249+
$user->getPHID());
250+
$path_ids = mpull($inlines, null, 'getPathID');
251+
foreach ($changesets as $key => $changeset) {
252+
if (array_key_exists($changeset->getID(), $path_ids)) {
253+
$visible_changesets[$key] = $changeset;
254+
}
255+
}
256+
}
257+
250258
$change_list = new DifferentialChangesetListView();
251259
$change_list->setChangesets($changesets);
252-
$change_list->setVisibleChangesets($changesets);
260+
$change_list->setVisibleChangesets($visible_changesets);
253261
$change_list->setRenderingReferences($references);
254262
$change_list->setRenderURI('/diffusion/'.$callsign.'/diff/');
255263
$change_list->setRepository($repository);
@@ -266,6 +274,12 @@ public function processRequest() {
266274
$change_list->setInlineCommentControllerURI(
267275
'/diffusion/inline/edit/'.phutil_escape_uri($commit->getPHID()).'/');
268276

277+
$change_references = array();
278+
foreach ($changesets as $key => $changeset) {
279+
$change_references[$changeset->getID()] = $references[$key];
280+
}
281+
$change_table->setRenderingReferences($change_references);
282+
269283
// TODO: This is pretty awkward, unify the CSS between Diffusion and
270284
// Differential better.
271285
require_celerity_resource('differential-core-view-css');

src/applications/diffusion/query/pathchange/DiffusionPathChangeQuery.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ protected function executeQuery() {
8080
$change->setTargetPath(ltrim($raw_change['targetPathName'], '/'));
8181
$change->setTargetCommitIdentifier($raw_change['targetCommitIdentifier']);
8282

83-
$changes[] = $change;
83+
$id = $raw_change['pathID'];
84+
$changes[$id] = $change;
8485
}
8586

8687
// Deduce the away paths by examining all the changes.

src/applications/diffusion/view/DiffusionCommitChangeTableView.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ final class DiffusionCommitChangeTableView extends DiffusionView {
2020

2121
private $pathChanges;
2222
private $ownersPaths = array();
23+
private $renderingReferences;
2324

2425
public function setPathChanges(array $path_changes) {
2526
assert_instances_of($path_changes, 'DiffusionPathChange');
@@ -33,6 +34,11 @@ public function setOwnersPaths(array $owners_paths) {
3334
return $this;
3435
}
3536

37+
public function setRenderingReferences(array $value) {
38+
$this->renderingReferences = $value;
39+
return $this;
40+
}
41+
3642
public function render() {
3743
$rows = array();
3844
$rowc = array();
@@ -41,17 +47,22 @@ public function render() {
4147

4248
// TODO: Copy Away and Move Away are rendered junkily still.
4349

44-
foreach ($this->pathChanges as $change) {
50+
foreach ($this->pathChanges as $id => $change) {
4551
$path = $change->getPath();
4652
$hash = substr(md5($path), 0, 8);
4753
if ($change->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
4854
$path .= '/';
4955
}
5056

51-
$path_column = phutil_render_tag(
57+
$path_column = javelin_render_tag(
5258
'a',
5359
array(
5460
'href' => '#'.$hash,
61+
'meta' => array(
62+
'id' => 'diff-'.$hash,
63+
'ref' => $this->renderingReferences[$id],
64+
),
65+
'sigil' => 'differential-load',
5566
),
5667
phutil_escape_html($path));
5768

webroot/rsrc/js/application/differential/behavior-populate.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,24 @@ JX.behavior('differential-populate', function(config) {
4242
'differential-load',
4343
function(e) {
4444
var meta = e.getNodeData('differential-load');
45-
JX.DOM.setContent(
46-
JX.$(meta.id),
47-
JX.$H('<div class="differential-loading">Loading...</div>'));
48-
var data = {
49-
ref : meta.ref,
50-
whitespace : config.whitespace
51-
};
52-
new JX.Workflow(config.uri, data)
53-
.setHandler(JX.bind(null, onresponse, meta.id))
54-
.start();
45+
var diff;
46+
try {
47+
diff = JX.$(meta.id);
48+
} catch (e) {
49+
// Already loaded.
50+
}
51+
if (diff) {
52+
JX.DOM.setContent(
53+
diff,
54+
JX.$H('<div class="differential-loading">Loading...</div>'));
55+
var data = {
56+
ref : meta.ref,
57+
whitespace : config.whitespace
58+
};
59+
new JX.Workflow(config.uri, data)
60+
.setHandler(JX.bind(null, onresponse, meta.id))
61+
.start();
62+
}
5563
if (meta.kill) {
5664
e.kill();
5765
}

0 commit comments

Comments
 (0)