1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 13:30:55 +01:00

Some Diffusion path change stuff.

This commit is contained in:
epriestley 2011-03-13 16:19:39 -07:00
parent 4893146815
commit c7d343e05e
10 changed files with 182 additions and 18 deletions

View file

@ -165,11 +165,13 @@ phutil_register_library_map(array(
'DiffusionHistoryTableView' => 'applications/diffusion/view/historytable', 'DiffusionHistoryTableView' => 'applications/diffusion/view/historytable',
'DiffusionHomeController' => 'applications/diffusion/controller/home', 'DiffusionHomeController' => 'applications/diffusion/controller/home',
'DiffusionPathChange' => 'applications/diffusion/data/pathchange', 'DiffusionPathChange' => 'applications/diffusion/data/pathchange',
'DiffusionPathChangeQuery' => 'applications/diffusion/query/pathchange/base',
'DiffusionRepositoryController' => 'applications/diffusion/controller/repository', 'DiffusionRepositoryController' => 'applications/diffusion/controller/repository',
'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',
'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/svn', 'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/svn',
'DiffusionSvnPathChangeQuery' => 'applications/diffusion/query/pathchange/svn',
'DiffusionView' => 'applications/diffusion/view/base', 'DiffusionView' => 'applications/diffusion/view/base',
'Javelin' => 'infrastructure/javelin/api', 'Javelin' => 'infrastructure/javelin/api',
'LiskDAO' => 'storage/lisk/dao', 'LiskDAO' => 'storage/lisk/dao',
@ -487,6 +489,7 @@ phutil_register_library_map(array(
'DiffusionRepositoryController' => 'DiffusionController', 'DiffusionRepositoryController' => 'DiffusionController',
'DiffusionSvnBrowseQuery' => 'DiffusionBrowseQuery', 'DiffusionSvnBrowseQuery' => 'DiffusionBrowseQuery',
'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery', 'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery',
'DiffusionSvnPathChangeQuery' => 'DiffusionPathChangeQuery',
'DiffusionView' => 'AphrontView', 'DiffusionView' => 'AphrontView',
'ManiphestController' => 'PhabricatorController', 'ManiphestController' => 'PhabricatorController',
'ManiphestDAO' => 'PhabricatorLiskDAO', 'ManiphestDAO' => 'PhabricatorLiskDAO',

View file

@ -122,7 +122,7 @@ abstract class DiffusionController extends PhabricatorController {
$branch_uri = $drequest->getBranchURIComponent($drequest->getBranch()); $branch_uri = $drequest->getBranchURIComponent($drequest->getBranch());
if (empty($spec['view'])) { if (empty($spec['view']) && empty($spec['commit'])) {
$crumb_list[] = $repository_name; $crumb_list[] = $repository_name;
$crumbs->setCrumbs($crumb_list); $crumbs->setCrumbs($crumb_list);
return $crumbs; return $crumbs;
@ -135,8 +135,9 @@ abstract class DiffusionController extends PhabricatorController {
), ),
$repository_name); $repository_name);
$raw_commit = $drequest->getRawCommit();
if (empty($spec['view'])) { if (isset($spec['commit'])) {
$crumb_list[] = "r{$callsign}{$raw_commit}";
$crumbs->setCrumbs($crumb_list); $crumbs->setCrumbs($crumb_list);
return $crumbs; return $crumbs;
} }
@ -161,7 +162,6 @@ abstract class DiffusionController extends PhabricatorController {
$jump_href = $view_root_uri; $jump_href = $view_root_uri;
$view_tail_uri = null; $view_tail_uri = null;
$raw_commit = $drequest->getRawCommit();
if ($raw_commit) { if ($raw_commit) {
$view_tail_uri = ';'.$drequest->getCommitURIComponent($raw_commit); $view_tail_uri = ';'.$drequest->getCommitURIComponent($raw_commit);
} }

View file

@ -19,34 +19,43 @@
class DiffusionCommitController extends DiffusionController { class DiffusionCommitController extends DiffusionController {
public function processRequest() { public function processRequest() {
$drequest = $this->diffusionRequest; $drequest = $this->getDiffusionRequest();
$content = array();
$content[] = $this->buildCrumbs(array(
'commit' => true,
));
$detail_panel = new AphrontPanelView(); $detail_panel = new AphrontPanelView();
$detail_panel->setHeader('Revision Detail'); $detail_panel->setHeader('Revision Detail');
$detail_panel->appendChild('<div>'.$drequest->getCommit().'</div>'); $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 = new DiffusionCommitChangeTableView();
$change_table->setDiffusionRequest($drequest); $change_table->setDiffusionRequest($drequest);
$change_table->setPathChanges(array()); $change_table->setPathChanges($changes);
$change_panel = new AphrontPanelView(); $change_panel = new AphrontPanelView();
$change_panel->setHeader('Changes'); $change_panel->setHeader('Changes');
$change_panel->appendChild($change_table); $change_panel->appendChild($change_table);
$content[] = $change_panel;
$change_list = $change_list =
'<div style="margin: 2em; color: #666; padding: 1em; background: #eee;">'. '<div style="margin: 2em; color: #666; padding: 1em; background: #eee;">'.
'(list of changes goes here)'. '(list of changes goes here)'.
'</div>'; '</div>';
$content[] = $change_list;
return $this->buildStandardPageResponse( return $this->buildStandardPageResponse(
array( $content,
$detail_panel,
$change_panel,
$change_list,
),
array( array(
'title' => 'Diffusion', 'title' => 'Diffusion',
)); ));

View file

@ -7,6 +7,7 @@
phutil_require_module('phabricator', 'applications/diffusion/controller/base'); 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', 'applications/diffusion/view/commitchangetable');
phutil_require_module('phabricator', 'view/layout/panel'); phutil_require_module('phabricator', 'view/layout/panel');

View file

@ -18,10 +18,51 @@
final class DiffusionPathChange { final class DiffusionPathChange {
private $path;
private $commitIdentifier; private $commitIdentifier;
private $commit; private $commit;
private $commitData; 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) { final public function setCommitIdentifier($commit) {
$this->commitIdentifier = $commit; $this->commitIdentifier = $commit;
return $this; return $this;

View file

@ -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;
}
}

View file

@ -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');

View file

@ -54,11 +54,16 @@ class DiffusionGitRequest extends DiffusionRequest {
$branch); $branch);
if ($this->commit) { if ($this->commit) {
execx( list($commit) = execx(
'(cd %s && %s rev-parse --verify %s)', '(cd %s && %s rev-parse --verify %s)',
$local_path, $local_path,
$git, $git,
$this->commit); $this->commit);
// Beyond verifying them, expand commit short forms to full 40-character
// sha1s.
$this->commit = trim($commit);
list($contains) = execx( list($contains) = execx(
'(cd %s && %s branch --contains %s)', '(cd %s && %s branch --contains %s)',
$local_path, $local_path,

View file

@ -29,10 +29,10 @@ final class DiffusionCommitChangeTableView extends DiffusionView {
$rows = array(); $rows = array();
foreach ($this->pathChanges as $change) { foreach ($this->pathChanges as $change) {
$rows[] = array( $rows[] = array(
'browse', $this->linkHistory($change->getPath()),
'whatever', $this->linkBrowse($change->getPath()),
$change->getPath(), // TODO: link '-',
// TODO: etc etc phutil_escape_html($change->getPath()),
); );
} }
@ -40,11 +40,13 @@ final class DiffusionCommitChangeTableView extends DiffusionView {
$view->setHeaders( $view->setHeaders(
array( array(
'History', 'History',
'Browse',
'Change', 'Change',
'Path', 'Path',
)); ));
$view->setColumnClasses( $view->setColumnClasses(
array( array(
'',
'', '',
'', '',
'wide', 'wide',

View file

@ -9,5 +9,7 @@
phutil_require_module('phabricator', 'applications/diffusion/view/base'); phutil_require_module('phabricator', 'applications/diffusion/view/base');
phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phutil', 'markup');
phutil_require_source('DiffusionCommitChangeTableView.php'); phutil_require_source('DiffusionCommitChangeTableView.php');