1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 04:50:55 +01:00

Restore some commit metadata to browse views.

This commit is contained in:
epriestley 2011-03-30 22:41:31 -07:00
parent e6cf7a9cb0
commit e25c58ed9c
8 changed files with 131 additions and 6 deletions

View file

@ -83,6 +83,15 @@ final class DiffusionPathChange {
return $this->commitIdentifier;
}
final public function setTargetCommitIdentifier($target_commit_identifier) {
$this->targetCommitIdentifier = $target_commit_identifier;
return $this;
}
final public function getTargetCommitIdentifier() {
return $this->targetCommitIdentifier;
}
final public function setCommit($commit) {
$this->commit = $commit;
return $this;

View file

@ -23,6 +23,9 @@ final class DiffusionRepositoryPath {
private $fileType;
private $fileSize;
private $lastModifiedCommit;
private $lastCommitData;
final public function setPath($path) {
$this->path = $path;
return $this;
@ -41,6 +44,26 @@ final class DiffusionRepositoryPath {
return $this->hash;
}
final public function setLastModifiedCommit(
PhabricatorRepositoryCommit $commit) {
$this->lastModifiedCommit = $commit;
return $this;
}
final public function getLastModifiedCommit() {
return $this->lastModifiedCommit;
}
final public function setLastCommitData(
PhabricatorRepositoryCommitData $last_commit_data) {
$this->lastCommitData = $last_commit_data;
return $this;
}
final public function getLastCommitData() {
return $this->lastCommitData;
}
final public function setFileType($file_type) {
$this->fileType = $file_type;
return $this;

View file

@ -123,6 +123,32 @@ final class DiffusionSvnBrowseQuery extends DiffusionBrowseQuery {
$path_id,
implode(', ', $sql));
$loadable_commits = array();
foreach ($browse as $key => $file) {
// We need to strip out directories because we don't store last-modified
// in the filesystem table.
if ($file['fileType'] != DifferentialChangeType::FILE_DIRECTORY) {
$loadable_commits[] = $file['svnCommit'];
$browse[$key]['hasCommit'] = true;
}
}
$commits = array();
$commit_data = array();
if ($loadable_commits) {
// NOTE: Even though these are integers, use '%Ls' because MySQL doesn't
// use the second part of the key otherwise!
$commits = id(new PhabricatorRepositoryCommit())->loadAllWhere(
'repositoryID = %d AND commitIdentifier IN (%Ls)',
$repository->getID(),
$loadable_commits);
$commits = mpull($commits, null, 'getCommitIdentifier');
$commit_data = id(new PhabricatorRepositoryCommitData())->loadAllWhere(
'commitID in (%Ld)',
mpull($commits, 'getID'));
$commit_data = mpull($commit_data, null, 'getCommitID');
}
$path_normal = DiffusionGitPathIDQuery::normalizePath($path);
$results = array();
@ -137,6 +163,15 @@ final class DiffusionSvnBrowseQuery extends DiffusionBrowseQuery {
$result->setFileType($file['fileType']);
// $result->setFileSize($size);
if (!empty($file['hasCommit'])) {
$commit = idx($commits, $file['svnCommit']);
if ($commit) {
$data = idx($commit_data, $commit->getID());
$result->setLastModifiedCommit($commit);
$result->setLastCommitData($data);
}
}
$results[] = $result;
}

View file

@ -10,8 +10,12 @@ phutil_require_module('phabricator', 'applications/differential/constants/change
phutil_require_module('phabricator', 'applications/diffusion/data/repositorypath');
phutil_require_module('phabricator', 'applications/diffusion/query/browse/base');
phutil_require_module('phabricator', 'applications/diffusion/query/pathid/base');
phutil_require_module('phabricator', 'applications/repository/storage/commit');
phutil_require_module('phabricator', 'applications/repository/storage/commitdata');
phutil_require_module('phabricator', 'applications/repository/storage/repository');
phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phutil', 'utils');
phutil_require_source('DiffusionSvnBrowseQuery.php');

View file

@ -62,6 +62,8 @@ class DiffusionPathChangeQuery {
$changes = array();
$raw_changes = isort($raw_changes, 'pathName');
foreach ($raw_changes as $raw_change) {
$type = $raw_change['changeType'];

View file

@ -27,6 +27,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
public function render() {
$request = $this->getDiffusionRequest();
$repository = $request->getRepository();
$base_path = trim($request->getPath(), '/');
if ($base_path) {
@ -39,18 +40,53 @@ final class DiffusionBrowseTableView extends DiffusionView {
if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
$browse_text = $path->getPath().'/';
$dir_slash = '/';
$browse_link = '<strong>'.$this->linkBrowse(
$base_path.$path->getPath().$dir_slash,
array(
'text' => $browse_text,
)).'</strong>';
} else {
$browse_text = $path->getPath();
$dir_slash = null;
$browse_link = $this->linkBrowse(
$base_path.$path->getPath().$dir_slash,
array(
'text' => $browse_text,
));
}
$commit = $path->getLastModifiedCommit();
if ($commit) {
$epoch = $commit->getEpoch();
$modified = $this->linkCommit(
$repository,
$commit->getCommitIdentifier());
$date = date('M j, Y', $epoch);
$time = date('g:i A', $epoch);
} else {
$modified = '';
$date = '';
$time = '';
}
$data = $path->getLastCommitData();
if ($data) {
$author = phutil_escape_html($data->getAuthorName());
$details = phutil_escape_html($data->getSummary());
} else {
$author = '';
$details = '';
}
$rows[] = array(
$this->linkHistory($base_path.$path->getPath().$dir_slash),
$this->linkBrowse(
$base_path.$path->getPath().$dir_slash,
array(
'text' => $browse_text,
)),
$browse_link,
$modified,
$date,
$time,
$author,
$details,
);
}
@ -59,11 +95,21 @@ final class DiffusionBrowseTableView extends DiffusionView {
array(
'History',
'Path',
'Modified',
'Date',
'Time',
'Author',
'Details',
));
$view->setColumnClasses(
array(
'',
'wide pri',
'',
'',
'',
'right',
'',
'wide',
));
return $view->render();
}

View file

@ -10,5 +10,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/change
phutil_require_module('phabricator', 'applications/diffusion/view/base');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phutil', 'markup');
phutil_require_source('DiffusionBrowseTableView.php');

View file

@ -32,4 +32,8 @@ class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO {
) + parent::getConfiguration();
}
public function getSummary() {
return substr($this->getCommitMessage(), 0, 80);
}
}