mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Some Diffusion path change stuff.
This commit is contained in:
parent
4893146815
commit
c7d343e05e
10 changed files with 182 additions and 18 deletions
|
@ -165,11 +165,13 @@ phutil_register_library_map(array(
|
|||
'DiffusionHistoryTableView' => 'applications/diffusion/view/historytable',
|
||||
'DiffusionHomeController' => 'applications/diffusion/controller/home',
|
||||
'DiffusionPathChange' => 'applications/diffusion/data/pathchange',
|
||||
'DiffusionPathChangeQuery' => 'applications/diffusion/query/pathchange/base',
|
||||
'DiffusionRepositoryController' => 'applications/diffusion/controller/repository',
|
||||
'DiffusionRepositoryPath' => 'applications/diffusion/data/repositorypath',
|
||||
'DiffusionRequest' => 'applications/diffusion/request/base',
|
||||
'DiffusionSvnBrowseQuery' => 'applications/diffusion/query/browse/svn',
|
||||
'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/svn',
|
||||
'DiffusionSvnPathChangeQuery' => 'applications/diffusion/query/pathchange/svn',
|
||||
'DiffusionView' => 'applications/diffusion/view/base',
|
||||
'Javelin' => 'infrastructure/javelin/api',
|
||||
'LiskDAO' => 'storage/lisk/dao',
|
||||
|
@ -487,6 +489,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionRepositoryController' => 'DiffusionController',
|
||||
'DiffusionSvnBrowseQuery' => 'DiffusionBrowseQuery',
|
||||
'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery',
|
||||
'DiffusionSvnPathChangeQuery' => 'DiffusionPathChangeQuery',
|
||||
'DiffusionView' => 'AphrontView',
|
||||
'ManiphestController' => 'PhabricatorController',
|
||||
'ManiphestDAO' => 'PhabricatorLiskDAO',
|
||||
|
|
|
@ -122,7 +122,7 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
|
||||
$branch_uri = $drequest->getBranchURIComponent($drequest->getBranch());
|
||||
|
||||
if (empty($spec['view'])) {
|
||||
if (empty($spec['view']) && empty($spec['commit'])) {
|
||||
$crumb_list[] = $repository_name;
|
||||
$crumbs->setCrumbs($crumb_list);
|
||||
return $crumbs;
|
||||
|
@ -135,8 +135,9 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
),
|
||||
$repository_name);
|
||||
|
||||
|
||||
if (empty($spec['view'])) {
|
||||
$raw_commit = $drequest->getRawCommit();
|
||||
if (isset($spec['commit'])) {
|
||||
$crumb_list[] = "r{$callsign}{$raw_commit}";
|
||||
$crumbs->setCrumbs($crumb_list);
|
||||
return $crumbs;
|
||||
}
|
||||
|
@ -161,7 +162,6 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
$jump_href = $view_root_uri;
|
||||
|
||||
$view_tail_uri = null;
|
||||
$raw_commit = $drequest->getRawCommit();
|
||||
if ($raw_commit) {
|
||||
$view_tail_uri = ';'.$drequest->getCommitURIComponent($raw_commit);
|
||||
}
|
||||
|
|
|
@ -19,34 +19,43 @@
|
|||
class DiffusionCommitController extends DiffusionController {
|
||||
|
||||
public function processRequest() {
|
||||
$drequest = $this->diffusionRequest;
|
||||
|
||||
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
|
||||
$content = array();
|
||||
$content[] = $this->buildCrumbs(array(
|
||||
'commit' => true,
|
||||
));
|
||||
|
||||
$detail_panel = new AphrontPanelView();
|
||||
$detail_panel->setHeader('Revision Detail');
|
||||
$detail_panel->appendChild('<div>'.$drequest->getCommit().'</div>');
|
||||
|
||||
$content[] = $detail_panel;
|
||||
|
||||
$change_query = DiffusionPathChangeQuery::newFromDiffusionRequest(
|
||||
$drequest);
|
||||
$changes = $change_query->loadChanges();
|
||||
|
||||
$change_table = new DiffusionCommitChangeTableView();
|
||||
$change_table->setDiffusionRequest($drequest);
|
||||
$change_table->setPathChanges(array());
|
||||
$change_table->setPathChanges($changes);
|
||||
|
||||
$change_panel = new AphrontPanelView();
|
||||
$change_panel->setHeader('Changes');
|
||||
$change_panel->appendChild($change_table);
|
||||
|
||||
$content[] = $change_panel;
|
||||
|
||||
|
||||
$change_list =
|
||||
'<div style="margin: 2em; color: #666; padding: 1em; background: #eee;">'.
|
||||
'(list of changes goes here)'.
|
||||
'</div>';
|
||||
|
||||
$content[] = $change_list;
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
array(
|
||||
$detail_panel,
|
||||
$change_panel,
|
||||
$change_list,
|
||||
),
|
||||
$content,
|
||||
array(
|
||||
'title' => 'Diffusion',
|
||||
));
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/pathchange/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/commitchangetable');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
|
|
|
@ -18,10 +18,51 @@
|
|||
|
||||
final class DiffusionPathChange {
|
||||
|
||||
private $path;
|
||||
private $commitIdentifier;
|
||||
private $commit;
|
||||
private $commitData;
|
||||
|
||||
private $changeType;
|
||||
private $fileType;
|
||||
private $targetPath;
|
||||
|
||||
final public function setPath($path) {
|
||||
$this->path = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function getPath() {
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function setChangeType($change_type) {
|
||||
$this->changeType = $change_type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChangeType() {
|
||||
return $this->changeType;
|
||||
}
|
||||
|
||||
public function setFileType($file_type) {
|
||||
$this->fileType = $file_type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFileType() {
|
||||
return $this->fileType;
|
||||
}
|
||||
|
||||
public function setTargetPath($target_path) {
|
||||
$this->targetPath = $target_path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTargetPath() {
|
||||
return $this->targetPath;
|
||||
}
|
||||
|
||||
final public function setCommitIdentifier($commit) {
|
||||
$this->commitIdentifier = $commit;
|
||||
return $this;
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?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 DiffusionPathChangeQuery {
|
||||
|
||||
private $request;
|
||||
|
||||
final private function __construct() {
|
||||
// <private>
|
||||
}
|
||||
|
||||
final public static function newFromDiffusionRequest(
|
||||
DiffusionRequest $request) {
|
||||
$query = new DiffusionPathChangeQuery();
|
||||
$query->request = $request;
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
final protected function getRequest() {
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
final public function loadChanges() {
|
||||
return $this->executeQuery();
|
||||
}
|
||||
|
||||
protected function executeQuery() {
|
||||
|
||||
$drequest = $this->getRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
|
||||
'repositoryID = %d AND commitIdentifier = %s',
|
||||
$repository->getID(),
|
||||
$drequest->getCommit());
|
||||
|
||||
$raw_changes = queryfx_all(
|
||||
$repository->establishConnection('r'),
|
||||
'SELECT c.*, p.path pathName, t.path targetPathName
|
||||
FROM %T c
|
||||
LEFT JOIN %T p ON c.pathID = p.id
|
||||
LEFT JOIN %T t on c.targetPathID = t.id
|
||||
WHERE c.commitID = %d',
|
||||
PhabricatorRepository::TABLE_PATHCHANGE,
|
||||
PhabricatorRepository::TABLE_PATH,
|
||||
PhabricatorRepository::TABLE_PATH,
|
||||
$commit->getID());
|
||||
|
||||
$changes = array();
|
||||
|
||||
$raw_changes = isort($raw_changes, 'pathName');
|
||||
foreach ($raw_changes as $raw_change) {
|
||||
$type = $raw_change['changeType'];
|
||||
if ($type == DifferentialChangeType::TYPE_CHILD) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$change = new DiffusionPathChange();
|
||||
$change->setPath(ltrim($raw_change['pathName'], '/'));
|
||||
$change->setChangeType($raw_change['changeType']);
|
||||
$change->setFileType($raw_change['fileType']);
|
||||
$changes[] = $change;
|
||||
}
|
||||
|
||||
return $changes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?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', 'applications/diffusion/data/pathchange');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/commit');
|
||||
phutil_require_module('phabricator', 'applications/repository/storage/repository');
|
||||
phutil_require_module('phabricator', 'storage/queryfx');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionPathChangeQuery.php');
|
|
@ -54,11 +54,16 @@ class DiffusionGitRequest extends DiffusionRequest {
|
|||
$branch);
|
||||
|
||||
if ($this->commit) {
|
||||
execx(
|
||||
list($commit) = execx(
|
||||
'(cd %s && %s rev-parse --verify %s)',
|
||||
$local_path,
|
||||
$git,
|
||||
$this->commit);
|
||||
|
||||
// Beyond verifying them, expand commit short forms to full 40-character
|
||||
// sha1s.
|
||||
$this->commit = trim($commit);
|
||||
|
||||
list($contains) = execx(
|
||||
'(cd %s && %s branch --contains %s)',
|
||||
$local_path,
|
||||
|
|
|
@ -29,10 +29,10 @@ final class DiffusionCommitChangeTableView extends DiffusionView {
|
|||
$rows = array();
|
||||
foreach ($this->pathChanges as $change) {
|
||||
$rows[] = array(
|
||||
'browse',
|
||||
'whatever',
|
||||
$change->getPath(), // TODO: link
|
||||
// TODO: etc etc
|
||||
$this->linkHistory($change->getPath()),
|
||||
$this->linkBrowse($change->getPath()),
|
||||
'-',
|
||||
phutil_escape_html($change->getPath()),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,13 @@ final class DiffusionCommitChangeTableView extends DiffusionView {
|
|||
$view->setHeaders(
|
||||
array(
|
||||
'History',
|
||||
'Browse',
|
||||
'Change',
|
||||
'Path',
|
||||
));
|
||||
$view->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'wide',
|
||||
|
|
|
@ -9,5 +9,7 @@
|
|||
phutil_require_module('phabricator', 'applications/diffusion/view/base');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionCommitChangeTableView.php');
|
||||
|
|
Loading…
Reference in a new issue