mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-04 20:01:00 +01:00
Rough cut of Diffusion change view.
This commit is contained in:
parent
51a6ce65aa
commit
3d5f03607b
16 changed files with 393 additions and 64 deletions
|
@ -157,6 +157,8 @@ phutil_register_library_map(array(
|
||||||
'DiffusionCommitChangeTableView' => 'applications/diffusion/view/commitchangetable',
|
'DiffusionCommitChangeTableView' => 'applications/diffusion/view/commitchangetable',
|
||||||
'DiffusionCommitController' => 'applications/diffusion/controller/commit',
|
'DiffusionCommitController' => 'applications/diffusion/controller/commit',
|
||||||
'DiffusionController' => 'applications/diffusion/controller/base',
|
'DiffusionController' => 'applications/diffusion/controller/base',
|
||||||
|
'DiffusionDiffController' => 'applications/diffusion/controller/diff',
|
||||||
|
'DiffusionDiffQuery' => 'applications/diffusion/query/diff/base',
|
||||||
'DiffusionFileContent' => 'applications/diffusion/data/filecontent',
|
'DiffusionFileContent' => 'applications/diffusion/data/filecontent',
|
||||||
'DiffusionFileContentQuery' => 'applications/diffusion/query/filecontent/base',
|
'DiffusionFileContentQuery' => 'applications/diffusion/query/filecontent/base',
|
||||||
'DiffusionGitBranchQuery' => 'applications/diffusion/query/branch/git',
|
'DiffusionGitBranchQuery' => 'applications/diffusion/query/branch/git',
|
||||||
|
@ -175,6 +177,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionRepositoryPath' => 'applications/diffusion/data/repositorypath',
|
'DiffusionRepositoryPath' => 'applications/diffusion/data/repositorypath',
|
||||||
'DiffusionRequest' => 'applications/diffusion/request/base',
|
'DiffusionRequest' => 'applications/diffusion/request/base',
|
||||||
'DiffusionSvnBrowseQuery' => 'applications/diffusion/query/browse/svn',
|
'DiffusionSvnBrowseQuery' => 'applications/diffusion/query/browse/svn',
|
||||||
|
'DiffusionSvnDiffQuery' => 'applications/diffusion/query/diff/svn',
|
||||||
'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/svn',
|
'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/svn',
|
||||||
'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/svn',
|
'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/svn',
|
||||||
'DiffusionSvnRequest' => 'applications/diffusion/request/svn',
|
'DiffusionSvnRequest' => 'applications/diffusion/request/svn',
|
||||||
|
@ -525,6 +528,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionCommitChangeTableView' => 'DiffusionView',
|
'DiffusionCommitChangeTableView' => 'DiffusionView',
|
||||||
'DiffusionCommitController' => 'DiffusionController',
|
'DiffusionCommitController' => 'DiffusionController',
|
||||||
'DiffusionController' => 'PhabricatorController',
|
'DiffusionController' => 'PhabricatorController',
|
||||||
|
'DiffusionDiffController' => 'DiffusionController',
|
||||||
'DiffusionGitBranchQuery' => 'DiffusionBranchQuery',
|
'DiffusionGitBranchQuery' => 'DiffusionBranchQuery',
|
||||||
'DiffusionGitBrowseQuery' => 'DiffusionBrowseQuery',
|
'DiffusionGitBrowseQuery' => 'DiffusionBrowseQuery',
|
||||||
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
|
@ -535,6 +539,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionHomeController' => 'DiffusionController',
|
'DiffusionHomeController' => 'DiffusionController',
|
||||||
'DiffusionRepositoryController' => 'DiffusionController',
|
'DiffusionRepositoryController' => 'DiffusionController',
|
||||||
'DiffusionSvnBrowseQuery' => 'DiffusionBrowseQuery',
|
'DiffusionSvnBrowseQuery' => 'DiffusionBrowseQuery',
|
||||||
|
'DiffusionSvnDiffQuery' => 'DiffusionDiffQuery',
|
||||||
'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery',
|
'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery',
|
||||||
'DiffusionSvnRequest' => 'DiffusionRequest',
|
'DiffusionSvnRequest' => 'DiffusionRequest',
|
||||||
|
|
|
@ -205,6 +205,11 @@ class AphrontDefaultApplicationConfiguration
|
||||||
'(?:[$](?P<line>\d+))?'.
|
'(?:[$](?P<line>\d+))?'.
|
||||||
'$'
|
'$'
|
||||||
=> 'DiffusionBrowseController',
|
=> 'DiffusionBrowseController',
|
||||||
|
'diff/'.
|
||||||
|
'(?P<path>.*?)'.
|
||||||
|
'(?:[;](?P<commit>[a-z0-9]+))?'.
|
||||||
|
'$'
|
||||||
|
=> 'DiffusionDiffController',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ class DifferentialChangesetListView extends AphrontView {
|
||||||
private $changesets = array();
|
private $changesets = array();
|
||||||
private $editable;
|
private $editable;
|
||||||
private $revision;
|
private $revision;
|
||||||
|
private $renderURI = '/differential/changeset/';
|
||||||
private $vsMap = array();
|
private $vsMap = array();
|
||||||
|
|
||||||
public function setChangesets($changesets) {
|
public function setChangesets($changesets) {
|
||||||
|
@ -43,6 +44,11 @@ class DifferentialChangesetListView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setRenderURI($render_uri) {
|
||||||
|
$this->renderURI = $render_uri;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
require_celerity_resource('differential-changeset-view-css');
|
require_celerity_resource('differential-changeset-view-css');
|
||||||
|
|
||||||
|
@ -105,11 +111,11 @@ class DifferentialChangesetListView extends AphrontView {
|
||||||
Javelin::initBehavior('differential-populate', array(
|
Javelin::initBehavior('differential-populate', array(
|
||||||
'registry' => $mapping,
|
'registry' => $mapping,
|
||||||
'whitespace' => $whitespace,
|
'whitespace' => $whitespace,
|
||||||
'uri' => '/differential/changeset/',
|
'uri' => $this->renderURI,
|
||||||
));
|
));
|
||||||
|
|
||||||
Javelin::initBehavior('differential-show-more', array(
|
Javelin::initBehavior('differential-show-more', array(
|
||||||
'uri' => '/differential/changeset/',
|
'uri' => $this->renderURI,
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($this->editable) {
|
if ($this->editable) {
|
||||||
|
|
|
@ -144,6 +144,19 @@ abstract class DiffusionController extends PhabricatorController {
|
||||||
|
|
||||||
$view = $spec['view'];
|
$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) {
|
switch ($view) {
|
||||||
case 'history':
|
case 'history':
|
||||||
$view_name = 'History';
|
$view_name = 'History';
|
||||||
|
@ -152,16 +165,12 @@ abstract class DiffusionController extends PhabricatorController {
|
||||||
$view_name = 'Browse';
|
$view_name = 'Browse';
|
||||||
break;
|
break;
|
||||||
case 'change':
|
case 'change':
|
||||||
$crumb_list[] = 'TODO CHANGE';
|
$view_name = 'Change';
|
||||||
|
$crumb_list[] = phutil_escape_html($path).' ('.$commit_link.')';
|
||||||
$crumbs->setCrumbs($crumb_list);
|
$crumbs->setCrumbs($crumb_list);
|
||||||
return $crumbs;
|
return $crumbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = null;
|
|
||||||
if (isset($spec['path'])) {
|
|
||||||
$path = $drequest->getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
$view_root_uri = "/diffusion/{$callsign}/{$view}/{$branch_uri}";
|
$view_root_uri = "/diffusion/{$callsign}/{$view}/{$branch_uri}";
|
||||||
$jump_href = $view_root_uri;
|
$jump_href = $view_root_uri;
|
||||||
|
|
||||||
|
@ -209,9 +218,6 @@ abstract class DiffusionController extends PhabricatorController {
|
||||||
$last_crumb = array_pop($crumb_list);
|
$last_crumb = array_pop($crumb_list);
|
||||||
|
|
||||||
if ($raw_commit) {
|
if ($raw_commit) {
|
||||||
$commit_link = DiffusionView::linkCommit(
|
|
||||||
$repository,
|
|
||||||
$raw_commit);
|
|
||||||
$jump_link = phutil_render_tag(
|
$jump_link = phutil_render_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -21,9 +21,6 @@ class DiffusionChangeController extends DiffusionController {
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
$drequest = $this->diffusionRequest;
|
$drequest = $this->diffusionRequest;
|
||||||
|
|
||||||
// $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
|
|
||||||
// $results = $browse_query->loadPaths();
|
|
||||||
|
|
||||||
$content = array();
|
$content = array();
|
||||||
|
|
||||||
$content[] = $this->buildCrumbs(
|
$content[] = $this->buildCrumbs(
|
||||||
|
@ -33,55 +30,23 @@ class DiffusionChangeController extends DiffusionController {
|
||||||
'view' => 'change',
|
'view' => 'change',
|
||||||
));
|
));
|
||||||
|
|
||||||
/*
|
|
||||||
if (!$results) {
|
|
||||||
|
|
||||||
switch ($browse_query->getReasonForEmptyResultSet()) {
|
$diff_query = DiffusionDiffQuery::newFromDiffusionRequest($drequest);
|
||||||
case DiffusionBrowseQuery::REASON_IS_NONEXISTENT:
|
$changeset = $diff_query->loadChangeset();
|
||||||
$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();
|
|
||||||
|
|
||||||
$title = 'Path Was Deleted';
|
$changeset_view = new DifferentialChangesetListView();
|
||||||
$body = "This path does not exist at {$commit}. It was deleted in ".
|
$changeset_view->setChangesets(array($changeset));
|
||||||
"{$deleted} and last existed at {$existed}.";
|
$changeset_view->setRenderURI(
|
||||||
$severity = AphrontErrorView::SEVERITY_WARNING;
|
'/diffusion/'.$drequest->getRepository()->getCallsign().'/diff/');
|
||||||
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!");
|
|
||||||
}
|
|
||||||
|
|
||||||
$error_view = new AphrontErrorView();
|
// TODO: This is pretty awkward, unify the CSS between Diffusion and
|
||||||
$error_view->setSeverity($severity);
|
// Differential better.
|
||||||
$error_view->setTitle($title);
|
require_celerity_resource('differential-core-view-css');
|
||||||
$error_view->appendChild('<p>'.$body.'</p>');
|
$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 = $this->buildSideNav('change', true);
|
||||||
$nav->appendChild($content);
|
$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/controller/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/diffusion/query/diff/base');
|
||||||
|
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||||
|
|
||||||
|
|
||||||
phutil_require_source('DiffusionChangeController.php');
|
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');
|
|
@ -26,6 +26,8 @@ final class DiffusionPathChange {
|
||||||
private $changeType;
|
private $changeType;
|
||||||
private $fileType;
|
private $fileType;
|
||||||
private $targetPath;
|
private $targetPath;
|
||||||
|
private $targetCommitIdentifier;
|
||||||
|
private $awayPaths = array();
|
||||||
|
|
||||||
final public function setPath($path) {
|
final public function setPath($path) {
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
|
@ -63,6 +65,15 @@ final class DiffusionPathChange {
|
||||||
return $this->targetPath;
|
return $this->targetPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setAwayPaths(array $away_paths) {
|
||||||
|
$this->awayPaths = $away_paths;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAwayPaths() {
|
||||||
|
return $this->awayPaths;
|
||||||
|
}
|
||||||
|
|
||||||
final public function setCommitIdentifier($commit) {
|
final public function setCommitIdentifier($commit) {
|
||||||
$this->commitIdentifier = $commit;
|
$this->commitIdentifier = $commit;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -115,6 +126,4 @@ final class DiffusionPathChange {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract class DiffusionDiffQuery {
|
||||||
|
|
||||||
|
private $request;
|
||||||
|
|
||||||
|
final private function __construct() {
|
||||||
|
// <private>
|
||||||
|
}
|
||||||
|
|
||||||
|
final public static function newFromDiffusionRequest(
|
||||||
|
DiffusionRequest $request) {
|
||||||
|
|
||||||
|
$repository = $request->getRepository();
|
||||||
|
|
||||||
|
switch ($repository->getVersionControlSystem()) {
|
||||||
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
||||||
|
$class = 'DiffusionGitDiffQuery';
|
||||||
|
break;
|
||||||
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||||
|
$class = 'DiffusionSvnDiffQuery';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception("Unsupported VCS!");
|
||||||
|
}
|
||||||
|
|
||||||
|
PhutilSymbolLoader::loadClass($class);
|
||||||
|
$query = new $class();
|
||||||
|
|
||||||
|
$query->request = $request;
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
final protected function getRequest() {
|
||||||
|
return $this->request;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function loadChangeset() {
|
||||||
|
return $this->executeQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected function executeQuery();
|
||||||
|
}
|
14
src/applications/diffusion/query/diff/base/__init__.php
Normal file
14
src/applications/diffusion/query/diff/base/__init__.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'symbols');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DiffusionDiffQuery.php');
|
|
@ -0,0 +1,137 @@
|
||||||
|
<?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 DiffusionSvnDiffQuery extends DiffusionDiffQuery {
|
||||||
|
|
||||||
|
protected function executeQuery() {
|
||||||
|
$drequest = $this->getRequest();
|
||||||
|
|
||||||
|
$path_change_query = DiffusionPathChangeQuery::newFromDiffusionRequest(
|
||||||
|
$drequest);
|
||||||
|
$path_changes = $path_change_query->loadChanges();
|
||||||
|
|
||||||
|
$path = null;
|
||||||
|
foreach ($path_changes as $change) {
|
||||||
|
if ($change->getPath() == $drequest->getPath()) {
|
||||||
|
$path = $change;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$path) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$change_type = $path->getChangeType();
|
||||||
|
switch ($change_type) {
|
||||||
|
case DifferentialChangeType::TYPE_MULTICOPY:
|
||||||
|
case DifferentialChangeType::TYPE_DELETE:
|
||||||
|
if ($path->getTargetPath()) {
|
||||||
|
$old = array(
|
||||||
|
$path->getTargetPath(),
|
||||||
|
$path->getTargetCommitIdentifier());
|
||||||
|
} else {
|
||||||
|
$old = array($path->getPath(), $path->getCommitIdentifier() - 1);
|
||||||
|
}
|
||||||
|
$old_name = $path->getPath();
|
||||||
|
$new_name = '';
|
||||||
|
$new = null;
|
||||||
|
break;
|
||||||
|
case DifferentialChangeType::TYPE_ADD:
|
||||||
|
$old = null;
|
||||||
|
$new = array($path->getPath(), $path->getCommitIdentifier());
|
||||||
|
$old_name = '';
|
||||||
|
$new_name = $path->getPath();
|
||||||
|
break;
|
||||||
|
case DifferentialChangeType::TYPE_MOVE_HERE:
|
||||||
|
case DifferentialChangeType::TYPE_COPY_HERE:
|
||||||
|
$old = array(
|
||||||
|
$path->getTargetPath(),
|
||||||
|
$path->getTargetCommitIdentifier());
|
||||||
|
$new = array($path->getPath(), $path->getCommitIdentifier());
|
||||||
|
$old_name = $path->getTargetPath();
|
||||||
|
$new_name = $path->getPath();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$old = array($path->getPath(), $path->getCommitIdentifier() - 1);
|
||||||
|
$new = array($path->getPath(), $path->getCommitIdentifier());
|
||||||
|
$old_name = $path->getPath();
|
||||||
|
$new_name = $path->getPath();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$futures = array(
|
||||||
|
'old' => $this->buildContentFuture($old),
|
||||||
|
'new' => $this->buildContentFuture($new),
|
||||||
|
);
|
||||||
|
$futures = array_filter($futures);
|
||||||
|
|
||||||
|
foreach (Futures($futures) as $key => $future) {
|
||||||
|
$futures[$key] = $future->resolvex();
|
||||||
|
}
|
||||||
|
|
||||||
|
$old_data = idx($futures, 'old', '');
|
||||||
|
$new_data = idx($futures, 'new', '');
|
||||||
|
|
||||||
|
$old_tmp = new TempFile();
|
||||||
|
$new_tmp = new TempFile();
|
||||||
|
|
||||||
|
Filesystem::writeFile($old_tmp, $old_data);
|
||||||
|
Filesystem::writeFile($new_tmp, $new_data);
|
||||||
|
|
||||||
|
list($err, $raw_diff) = exec_manual(
|
||||||
|
'diff -L %s -L %s -U65535 %s %s',
|
||||||
|
nonempty($old_name, '/dev/universe').' 9999-99-99',
|
||||||
|
nonempty($new_name, '/dev/universe').' 9999-99-99',
|
||||||
|
$old_tmp,
|
||||||
|
$new_tmp);
|
||||||
|
|
||||||
|
$parser = new ArcanistDiffParser();
|
||||||
|
$parser->setDetectBinaryFiles(true);
|
||||||
|
|
||||||
|
$change = $parser->parseDiffusionPathChangesAndRawDiff(
|
||||||
|
$drequest->getPath(),
|
||||||
|
$path_changes,
|
||||||
|
$raw_diff);
|
||||||
|
|
||||||
|
$diff = DifferentialDiff::newFromRawChanges(array($change));
|
||||||
|
$changesets = $diff->getChangesets();
|
||||||
|
$changeset = reset($changesets);
|
||||||
|
|
||||||
|
$id = $drequest->getPath().';'.$drequest->getCommit();
|
||||||
|
$changeset->setID($id);
|
||||||
|
|
||||||
|
return $changeset;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildContentFuture($spec) {
|
||||||
|
if (!$spec) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$drequest = $this->getRequest();
|
||||||
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
|
list($ref, $rev) = $spec;
|
||||||
|
return new ExecFuture(
|
||||||
|
'svn --non-interactive cat %s%s@%d',
|
||||||
|
$repository->getDetail('remote-uri'),
|
||||||
|
$ref,
|
||||||
|
$rev);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
23
src/applications/diffusion/query/diff/svn/__init__.php
Normal file
23
src/applications/diffusion/query/diff/svn/__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', 'parser/diff');
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/constants/changetype');
|
||||||
|
phutil_require_module('phabricator', 'applications/differential/storage/diff');
|
||||||
|
phutil_require_module('phabricator', 'applications/diffusion/query/diff/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/diffusion/query/pathchange/base');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'filesystem');
|
||||||
|
phutil_require_module('phutil', 'filesystem/tempfile');
|
||||||
|
phutil_require_module('phutil', 'future');
|
||||||
|
phutil_require_module('phutil', 'future/exec');
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('DiffusionSvnDiffQuery.php');
|
|
@ -73,6 +73,7 @@ class DiffusionPathChangeQuery {
|
||||||
$change->setPath(ltrim($raw_change['pathName'], '/'));
|
$change->setPath(ltrim($raw_change['pathName'], '/'));
|
||||||
$change->setChangeType($raw_change['changeType']);
|
$change->setChangeType($raw_change['changeType']);
|
||||||
$change->setFileType($raw_change['fileType']);
|
$change->setFileType($raw_change['fileType']);
|
||||||
|
$change->setCommitIdentifier($commit->getCommitIdentifier());
|
||||||
$changes[] = $change;
|
$changes[] = $change;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ abstract class DiffusionView extends AphrontView {
|
||||||
return $this->diffusionRequest;
|
return $this->diffusionRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function linkChange($change_type, $file_type) {
|
final public function linkChange($change_type, $file_type, $path = null) {
|
||||||
|
|
||||||
$text = DifferentialChangeType::getFullNameForChangeType($change_type);
|
$text = DifferentialChangeType::getFullNameForChangeType($change_type);
|
||||||
if ($change_type == DifferentialChangeType::TYPE_CHILD) {
|
if ($change_type == DifferentialChangeType::TYPE_CHILD) {
|
||||||
|
@ -52,7 +52,7 @@ abstract class DiffusionView extends AphrontView {
|
||||||
$callsign = $repository->getCallsign();
|
$callsign = $repository->getCallsign();
|
||||||
|
|
||||||
$branch = $drequest->getBranchURIComponent($drequest->getBranch());
|
$branch = $drequest->getBranchURIComponent($drequest->getBranch());
|
||||||
$path = $branch.$drequest->getPath();
|
$path = $branch.($path ? $path : $drequest->getPath());
|
||||||
|
|
||||||
return phutil_render_tag(
|
return phutil_render_tag(
|
||||||
'a',
|
'a',
|
||||||
|
|
|
@ -49,7 +49,8 @@ final class DiffusionCommitChangeTableView extends DiffusionView {
|
||||||
$this->linkBrowse($change->getPath()),
|
$this->linkBrowse($change->getPath()),
|
||||||
$this->linkChange(
|
$this->linkChange(
|
||||||
$change->getChangeType(),
|
$change->getChangeType(),
|
||||||
$change->getFileType()),
|
$change->getFileType(),
|
||||||
|
$change->getPath()),
|
||||||
phutil_render_tag(
|
phutil_render_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
|
|
Loading…
Reference in a new issue