mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
DifferentialChangesetView
This commit is contained in:
parent
e85ecd03de
commit
a3df19976f
13 changed files with 1613 additions and 4 deletions
|
@ -58,6 +58,8 @@ phutil_register_library_map(array(
|
||||||
'DifferentialChangeType' => 'applications/differential/constants/changetype',
|
'DifferentialChangeType' => 'applications/differential/constants/changetype',
|
||||||
'DifferentialChangeset' => 'applications/differential/storage/changeset',
|
'DifferentialChangeset' => 'applications/differential/storage/changeset',
|
||||||
'DifferentialChangesetDetailView' => 'applications/differential/view/changesetdetailview',
|
'DifferentialChangesetDetailView' => 'applications/differential/view/changesetdetailview',
|
||||||
|
'DifferentialChangesetParser' => 'applications/differential/parser/changeset',
|
||||||
|
'DifferentialChangesetViewController' => 'applications/differential/controller/changesetview',
|
||||||
'DifferentialController' => 'applications/differential/controller/base',
|
'DifferentialController' => 'applications/differential/controller/base',
|
||||||
'DifferentialDAO' => 'applications/differential/storage/base',
|
'DifferentialDAO' => 'applications/differential/storage/base',
|
||||||
'DifferentialDiff' => 'applications/differential/storage/diff',
|
'DifferentialDiff' => 'applications/differential/storage/diff',
|
||||||
|
@ -95,6 +97,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFileDAO' => 'applications/files/storage/base',
|
'PhabricatorFileDAO' => 'applications/files/storage/base',
|
||||||
'PhabricatorFileListController' => 'applications/files/controller/list',
|
'PhabricatorFileListController' => 'applications/files/controller/list',
|
||||||
'PhabricatorFileStorageBlob' => 'applications/files/storage/storageblob',
|
'PhabricatorFileStorageBlob' => 'applications/files/storage/storageblob',
|
||||||
|
'PhabricatorFileURI' => 'applications/files/uri',
|
||||||
'PhabricatorFileUploadController' => 'applications/files/controller/upload',
|
'PhabricatorFileUploadController' => 'applications/files/controller/upload',
|
||||||
'PhabricatorFileViewController' => 'applications/files/controller/view',
|
'PhabricatorFileViewController' => 'applications/files/controller/view',
|
||||||
'PhabricatorLiskDAO' => 'applications/base/storage/lisk',
|
'PhabricatorLiskDAO' => 'applications/base/storage/lisk',
|
||||||
|
@ -165,6 +168,7 @@ phutil_register_library_map(array(
|
||||||
'ConduitAPI_user_find_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_user_find_Method' => 'ConduitAPIMethod',
|
||||||
'DifferentialChangeset' => 'DifferentialDAO',
|
'DifferentialChangeset' => 'DifferentialDAO',
|
||||||
'DifferentialChangesetDetailView' => 'AphrontView',
|
'DifferentialChangesetDetailView' => 'AphrontView',
|
||||||
|
'DifferentialChangesetViewController' => 'DifferentialController',
|
||||||
'DifferentialController' => 'PhabricatorController',
|
'DifferentialController' => 'PhabricatorController',
|
||||||
'DifferentialDAO' => 'PhabricatorLiskDAO',
|
'DifferentialDAO' => 'PhabricatorLiskDAO',
|
||||||
'DifferentialDiff' => 'DifferentialDAO',
|
'DifferentialDiff' => 'DifferentialDAO',
|
||||||
|
|
|
@ -77,7 +77,8 @@ class AphrontDefaultApplicationConfiguration
|
||||||
'/api/(?<method>[^/]+)$' => 'PhabricatorConduitAPIController',
|
'/api/(?<method>[^/]+)$' => 'PhabricatorConduitAPIController',
|
||||||
|
|
||||||
'/differential/' => array(
|
'/differential/' => array(
|
||||||
'diff/(?<id>\d+)/$' => 'DifferentialDiffViewController',
|
'diff/(?<id>\d+)/$' => 'DifferentialDiffViewController',
|
||||||
|
'changeset/(?<id>\d+)/$' => 'DifferentialChangesetViewController',
|
||||||
),
|
),
|
||||||
|
|
||||||
'.*' => 'AphrontDefaultApplicationController',
|
'.*' => 'AphrontDefaultApplicationController',
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?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 DifferentialChangesetViewController extends DifferentialController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = $data['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$changeset = id(new DifferentialChangeset())->load($this->id);
|
||||||
|
if (!$changeset) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$changeset->attachHunks($changeset->loadHunks());
|
||||||
|
|
||||||
|
$parser = new DifferentialChangesetParser();
|
||||||
|
$parser->setChangeset($changeset);
|
||||||
|
|
||||||
|
$output = $parser->render();
|
||||||
|
|
||||||
|
// TODO: This is a bit of a hacky mess.
|
||||||
|
$output =
|
||||||
|
'<div style="padding: 2em 1em;">'.
|
||||||
|
'<div class="differential-primary-pane">'.
|
||||||
|
'<div class="differential-review-stage">'.
|
||||||
|
'<h1>'.phutil_escape_html($changeset->getDisplayFilename()).'</h1>'.
|
||||||
|
'<br />'.
|
||||||
|
$output.
|
||||||
|
'</div>'.
|
||||||
|
'</div>'.
|
||||||
|
'</div>';
|
||||||
|
|
||||||
|
return $this->buildStandardPageResponse(
|
||||||
|
array(
|
||||||
|
$output
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'title' => 'Changeset View',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/404');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/controller/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/parser/changeset');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/storage/changeset');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DifferentialChangesetViewController.php');
|
File diff suppressed because it is too large
Load diff
23
src/applications/differential/parser/changeset/__init__.php
Normal file
23
src/applications/differential/parser/changeset/__init__.php
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('arcanist', 'difference');
|
||||||
|
phutil_require_module('arcanist', 'parser/diff');
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/constants/changetype');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/storage/diff');
|
||||||
|
phutil_require_module('phabricator', 'applications/files/uri');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'filesystem');
|
||||||
|
phutil_require_module('phutil', 'filesystem/tempfile');
|
||||||
|
phutil_require_module('phutil', 'future/exec');
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DifferentialChangesetParser.php');
|
|
@ -31,6 +31,7 @@ class DifferentialChangeset extends DifferentialDAO {
|
||||||
protected $delLines;
|
protected $delLines;
|
||||||
|
|
||||||
private $unsavedHunks = array();
|
private $unsavedHunks = array();
|
||||||
|
private $hunks;
|
||||||
|
|
||||||
protected function getConfiguration() {
|
protected function getConfiguration() {
|
||||||
return array(
|
return array(
|
||||||
|
@ -54,6 +55,18 @@ class DifferentialChangeset extends DifferentialDAO {
|
||||||
return $this->changeType;
|
return $this->changeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function attachHunks(array $hunks) {
|
||||||
|
$this->hunks = $hunks;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHunks() {
|
||||||
|
if ($this->hunks === null) {
|
||||||
|
throw new Exception("Must load and attach hunks first!");
|
||||||
|
}
|
||||||
|
return $this->hunks;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDisplayFilename() {
|
public function getDisplayFilename() {
|
||||||
$name = $this->getFilename();
|
$name = $this->getFilename();
|
||||||
if ($this->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
|
if ($this->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
|
||||||
|
@ -63,6 +76,10 @@ class DifferentialChangeset extends DifferentialDAO {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addUnsavedHunk(DifferentialHunk $hunk) {
|
public function addUnsavedHunk(DifferentialHunk $hunk) {
|
||||||
|
if ($this->hunks === null) {
|
||||||
|
$this->hunks = array();
|
||||||
|
}
|
||||||
|
$this->hunks[] = $hunk;
|
||||||
$this->unsavedHunks[] = $hunk;
|
$this->unsavedHunks[] = $hunk;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,12 +40,29 @@ class DifferentialDiff extends DifferentialDAO {
|
||||||
protected $creationMethod;
|
protected $creationMethod;
|
||||||
|
|
||||||
private $unsavedChangesets = array();
|
private $unsavedChangesets = array();
|
||||||
|
private $changesets;
|
||||||
|
|
||||||
public function addUnsavedChangeset(DifferentialChangeset $changeset) {
|
public function addUnsavedChangeset(DifferentialChangeset $changeset) {
|
||||||
|
if ($this->changesets === null) {
|
||||||
|
$this->changesets = array();
|
||||||
|
}
|
||||||
$this->unsavedChangesets[] = $changeset;
|
$this->unsavedChangesets[] = $changeset;
|
||||||
|
$this->changesets[] = $changeset;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function attachChangesets(array $changesets) {
|
||||||
|
$this->changesets = $changesets;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getChangesets() {
|
||||||
|
if ($this->changesets === null) {
|
||||||
|
throw new Exception("Must load and attach changesets first!");
|
||||||
|
}
|
||||||
|
return $this->changesets;
|
||||||
|
}
|
||||||
|
|
||||||
public function loadChangesets() {
|
public function loadChangesets() {
|
||||||
if (!$this->getID()) {
|
if (!$this->getID()) {
|
||||||
return array();
|
return array();
|
||||||
|
|
|
@ -63,12 +63,13 @@ class DifferentialChangesetDetailView extends AphrontView {
|
||||||
'whitespace' => $whitespace,
|
'whitespace' => $whitespace,
|
||||||
));
|
));
|
||||||
*/
|
*/
|
||||||
$detail_uri = '!';
|
$detail_uri = '/differential/changeset/'.$changeset->getID().'/';
|
||||||
|
|
||||||
$detail = phutil_render_tag(
|
$detail = phutil_render_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
'style' => 'float: right',
|
'style' => 'float: right',
|
||||||
|
'class' => 'button small grey',
|
||||||
'href' => $detail_uri,
|
'href' => $detail_uri,
|
||||||
'target' => '_blank',
|
'target' => '_blank',
|
||||||
),
|
),
|
||||||
|
@ -79,7 +80,7 @@ class DifferentialChangesetDetailView extends AphrontView {
|
||||||
$display_filename = $changeset->getDisplayFilename();
|
$display_filename = $changeset->getDisplayFilename();
|
||||||
$output[] =
|
$output[] =
|
||||||
'<div>'.
|
'<div>'.
|
||||||
'<h1>'.phutil_escape_html($display_filename).'</h1>'.
|
'<h1>'.$detail.phutil_escape_html($display_filename).'</h1>'.
|
||||||
'<div>Loading...</div>'.
|
'<div>Loading...</div>'.
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/constants/changetype');
|
||||||
|
phutil_require_module('phabricator', 'view/base');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DifferentialChangesetDetailView.php');
|
25
src/applications/files/uri/PhabricatorFileURI.php
Normal file
25
src/applications/files/uri/PhabricatorFileURI.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
final class PhabricatorFileURI {
|
||||||
|
|
||||||
|
public static function getViewURIForPHID($phid) {
|
||||||
|
return '/file/view/'.$phid.'/';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
src/applications/files/uri/__init__.php
Normal file
10
src/applications/files/uri/__init__.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorFileURI.php');
|
|
@ -636,3 +636,114 @@ th.aphront-side-nav-navigation a.aphront-side-nav-selected:hover {
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
/* changeset view */
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
.differential-diff {
|
||||||
|
background: #ffffff;
|
||||||
|
font-family: "Menlo", "Consolas", "Monaco", monospace;
|
||||||
|
font-size: 10px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-diff td {
|
||||||
|
/* using monospace fonts makes ex/em most useful:
|
||||||
|
*
|
||||||
|
* Unfortunately, firefox 3.6 renders diffs columns for added and removed
|
||||||
|
* files "way-too-wide" when given em as the dimension measurement, so we
|
||||||
|
* use an eyeballed ex equivalent and reset it to the ch character width
|
||||||
|
* measurement for browsers that support that css3 measurement.
|
||||||
|
*/
|
||||||
|
width: 88ex;
|
||||||
|
width: 81ch;
|
||||||
|
/*
|
||||||
|
Disable ligatures in Firefox. Firefox 3 has fancypants ligature support, but
|
||||||
|
it gets applied to monospaced fonts, which sucks because it means that the
|
||||||
|
"fi" ligature only takes up one character, e.g. It's probably the font's
|
||||||
|
fault that it even specifies ligatures (seriously, what the hell?) but
|
||||||
|
that's hard to fix and this is "easy" to "fix": custom letter spacing
|
||||||
|
disables ligatures, as long as it's at least 0.008333-repeating pixels of
|
||||||
|
custom letter spacing. I have no idea where this number comes from, but note
|
||||||
|
that .83333.. = 5/6. -epriestley
|
||||||
|
*/
|
||||||
|
letter-spacing: 0.0083334px;
|
||||||
|
vertical-align: top;
|
||||||
|
white-space: pre;
|
||||||
|
padding: 0 8px 1px;
|
||||||
|
line-height: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-diff th {
|
||||||
|
text-align: right;
|
||||||
|
padding: 2px 6px;
|
||||||
|
width: 44px;
|
||||||
|
vertical-align: top;
|
||||||
|
background: #eeeeee;
|
||||||
|
color: #888888;
|
||||||
|
cursor: pointer;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 0px 1px;
|
||||||
|
border-color: #eeeeee #999999 #eeeeee #dddddd;
|
||||||
|
font-weight: bold;
|
||||||
|
font-family: "Verdana";
|
||||||
|
font-size: 11px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-diff td.old {
|
||||||
|
background: #ffd0d0;
|
||||||
|
color: #161111;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-diff td.new {
|
||||||
|
background: #d0ffd0;
|
||||||
|
color: #111611;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-diff td.old-full,
|
||||||
|
.differential-diff td.old span.bright {
|
||||||
|
background: #ffaaaa;
|
||||||
|
color: #221111;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-diff td.new-full,
|
||||||
|
.differential-diff td.new span.bright {
|
||||||
|
background: #aaffaa;
|
||||||
|
color: #112211;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-diff td.show-more,
|
||||||
|
.differential-diff td.differential-shield {
|
||||||
|
background: #ffffee;
|
||||||
|
padding: 1em;
|
||||||
|
text-align: center;
|
||||||
|
font-family: "Verdana";
|
||||||
|
font-size: 11px;
|
||||||
|
border: 1px solid #ccccaa;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-diff td.show-more {
|
||||||
|
color: #999966;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-diff td.differential-shield {
|
||||||
|
text-align: center;
|
||||||
|
max-width: 1160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.differential-diff td.differential-shield a {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.differential-primary-pane {
|
||||||
|
margin: 0 40px;
|
||||||
|
max-width: 1162px;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue