Rough cut of Diffusion change view.
This commit is contained in:
@@ -144,6 +144,19 @@ abstract class DiffusionController extends PhabricatorController {
|
||||
|
||||
$view = $spec['view'];
|
||||
|
||||
$path = null;
|
||||
if (isset($spec['path'])) {
|
||||
$path = $drequest->getPath();
|
||||
}
|
||||
|
||||
if ($raw_commit) {
|
||||
$commit_link = DiffusionView::linkCommit(
|
||||
$repository,
|
||||
$raw_commit);
|
||||
} else {
|
||||
$commit_link = '';
|
||||
}
|
||||
|
||||
switch ($view) {
|
||||
case 'history':
|
||||
$view_name = 'History';
|
||||
@@ -152,16 +165,12 @@ abstract class DiffusionController extends PhabricatorController {
|
||||
$view_name = 'Browse';
|
||||
break;
|
||||
case 'change':
|
||||
$crumb_list[] = 'TODO CHANGE';
|
||||
$view_name = 'Change';
|
||||
$crumb_list[] = phutil_escape_html($path).' ('.$commit_link.')';
|
||||
$crumbs->setCrumbs($crumb_list);
|
||||
return $crumbs;
|
||||
}
|
||||
|
||||
$path = null;
|
||||
if (isset($spec['path'])) {
|
||||
$path = $drequest->getPath();
|
||||
}
|
||||
|
||||
$view_root_uri = "/diffusion/{$callsign}/{$view}/{$branch_uri}";
|
||||
$jump_href = $view_root_uri;
|
||||
|
||||
@@ -209,9 +218,6 @@ abstract class DiffusionController extends PhabricatorController {
|
||||
$last_crumb = array_pop($crumb_list);
|
||||
|
||||
if ($raw_commit) {
|
||||
$commit_link = DiffusionView::linkCommit(
|
||||
$repository,
|
||||
$raw_commit);
|
||||
$jump_link = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
|
||||
@@ -21,9 +21,6 @@ class DiffusionChangeController extends DiffusionController {
|
||||
public function processRequest() {
|
||||
$drequest = $this->diffusionRequest;
|
||||
|
||||
// $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
|
||||
// $results = $browse_query->loadPaths();
|
||||
|
||||
$content = array();
|
||||
|
||||
$content[] = $this->buildCrumbs(
|
||||
@@ -33,55 +30,23 @@ class DiffusionChangeController extends DiffusionController {
|
||||
'view' => 'change',
|
||||
));
|
||||
|
||||
/*
|
||||
if (!$results) {
|
||||
|
||||
switch ($browse_query->getReasonForEmptyResultSet()) {
|
||||
case DiffusionBrowseQuery::REASON_IS_NONEXISTENT:
|
||||
$title = 'Path Does Not Exist';
|
||||
// TODO: Under git, this error message should be more specific. It
|
||||
// may exist on some other branch.
|
||||
$body = "This path does not exist anywhere.";
|
||||
$severity = AphrontErrorView::SEVERITY_ERROR;
|
||||
break;
|
||||
case DiffusionBrowseQuery::REASON_IS_DELETED:
|
||||
// TODO: Format all these commits into nice VCS-agnostic links.
|
||||
$commit = $drequest->getCommit();
|
||||
$deleted = $browse_query->getDeletedAtCommit();
|
||||
$existed = $browse_query->getExistedAtCommit();
|
||||
$diff_query = DiffusionDiffQuery::newFromDiffusionRequest($drequest);
|
||||
$changeset = $diff_query->loadChangeset();
|
||||
|
||||
$title = 'Path Was Deleted';
|
||||
$body = "This path does not exist at {$commit}. It was deleted in ".
|
||||
"{$deleted} and last existed at {$existed}.";
|
||||
$severity = AphrontErrorView::SEVERITY_WARNING;
|
||||
break;
|
||||
case DiffusionBrowseQuery::REASON_IS_FILE:
|
||||
$controller = new DiffusionBrowseFileController($this->getRequest());
|
||||
$controller->setDiffusionRequest($drequest);
|
||||
return $this->delegateToController($controller);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Unknown failure reason!");
|
||||
}
|
||||
$changeset_view = new DifferentialChangesetListView();
|
||||
$changeset_view->setChangesets(array($changeset));
|
||||
$changeset_view->setRenderURI(
|
||||
'/diffusion/'.$drequest->getRepository()->getCallsign().'/diff/');
|
||||
|
||||
$error_view = new AphrontErrorView();
|
||||
$error_view->setSeverity($severity);
|
||||
$error_view->setTitle($title);
|
||||
$error_view->appendChild('<p>'.$body.'</p>');
|
||||
// TODO: This is pretty awkward, unify the CSS between Diffusion and
|
||||
// Differential better.
|
||||
require_celerity_resource('differential-core-view-css');
|
||||
$content[] =
|
||||
'<div class="differential-primary-pane">'.
|
||||
$changeset_view->render().
|
||||
'</div>';
|
||||
|
||||
$content[] = $error_view;
|
||||
|
||||
} else {
|
||||
$browse_table = new DiffusionBrowseTableView();
|
||||
$browse_table->setDiffusionRequest($drequest);
|
||||
$browse_table->setPaths($results);
|
||||
|
||||
$browse_panel = new AphrontPanelView();
|
||||
$browse_panel->appendChild($browse_table);
|
||||
|
||||
$content[] = $browse_panel;
|
||||
}
|
||||
*/
|
||||
|
||||
$nav = $this->buildSideNav('change', true);
|
||||
$nav->appendChild($content);
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/view/changesetlistview');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/diff/base');
|
||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionChangeController.php');
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class DiffusionDiffController extends DiffusionController {
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$request = $this->getRequest();
|
||||
if ($request->getStr('id')) {
|
||||
$parts = explode(';', $request->getStr('id'));
|
||||
$data['path'] = idx($parts, 0);
|
||||
$data['commit'] = idx($parts, 1);
|
||||
}
|
||||
|
||||
$this->diffusionRequest = DiffusionRequest::newFromAphrontRequestDictionary(
|
||||
$data);
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$request = $this->getRequest();
|
||||
|
||||
$diff_query = DiffusionDiffQuery::newFromDiffusionRequest($drequest);
|
||||
$changeset = $diff_query->loadChangeset();
|
||||
|
||||
if (!$changeset) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$parser = new DifferentialChangesetParser();
|
||||
$parser->setChangeset($changeset);
|
||||
$parser->setWhitespaceMode(
|
||||
DifferentialChangesetParser::WHITESPACE_SHOW_ALL);
|
||||
|
||||
$range_s = null;
|
||||
$range_e = null;
|
||||
$mask = array();
|
||||
|
||||
// TODO: This duplicates a block in DifferentialChangesetViewController.
|
||||
$range = $request->getStr('range');
|
||||
if ($range) {
|
||||
$match = null;
|
||||
if (preg_match('@^(\d+)-(\d+)(?:/(\d+)-(\d+))?$@', $range, $match)) {
|
||||
$range_s = (int)$match[1];
|
||||
$range_e = (int)$match[2];
|
||||
if (count($match) > 3) {
|
||||
$start = (int)$match[3];
|
||||
$len = (int)$match[4];
|
||||
for ($ii = $start; $ii < $start + $len; $ii++) {
|
||||
$mask[$ii] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output = $parser->render($range_s, $range_e, $mask);
|
||||
|
||||
return id(new AphrontAjaxResponse())
|
||||
->setContent($output);
|
||||
}
|
||||
}
|
||||
19
src/applications/diffusion/controller/diff/__init__.php
Normal file
19
src/applications/diffusion/controller/diff/__init__.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/ajax');
|
||||
phutil_require_module('phabricator', 'applications/differential/parser/changeset');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/diff/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/request/base');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionDiffController.php');
|
||||
Reference in New Issue
Block a user