diff --git a/src/applications/diffusion/data/pathchange/DiffusionPathChange.php b/src/applications/diffusion/data/pathchange/DiffusionPathChange.php index 65d93d520b..a0d7f29b22 100644 --- a/src/applications/diffusion/data/pathchange/DiffusionPathChange.php +++ b/src/applications/diffusion/data/pathchange/DiffusionPathChange.php @@ -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; diff --git a/src/applications/diffusion/data/repositorypath/DiffusionRepositoryPath.php b/src/applications/diffusion/data/repositorypath/DiffusionRepositoryPath.php index ac45cb8192..4344b6ce52 100644 --- a/src/applications/diffusion/data/repositorypath/DiffusionRepositoryPath.php +++ b/src/applications/diffusion/data/repositorypath/DiffusionRepositoryPath.php @@ -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; diff --git a/src/applications/diffusion/query/browse/svn/DiffusionSvnBrowseQuery.php b/src/applications/diffusion/query/browse/svn/DiffusionSvnBrowseQuery.php index fc6f080966..db676941d3 100644 --- a/src/applications/diffusion/query/browse/svn/DiffusionSvnBrowseQuery.php +++ b/src/applications/diffusion/query/browse/svn/DiffusionSvnBrowseQuery.php @@ -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; } diff --git a/src/applications/diffusion/query/browse/svn/__init__.php b/src/applications/diffusion/query/browse/svn/__init__.php index 021f807b5d..df45078e3d 100644 --- a/src/applications/diffusion/query/browse/svn/__init__.php +++ b/src/applications/diffusion/query/browse/svn/__init__.php @@ -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'); diff --git a/src/applications/diffusion/query/pathchange/base/DiffusionPathChangeQuery.php b/src/applications/diffusion/query/pathchange/base/DiffusionPathChangeQuery.php index 45868951ef..241c9e3d9b 100644 --- a/src/applications/diffusion/query/pathchange/base/DiffusionPathChangeQuery.php +++ b/src/applications/diffusion/query/pathchange/base/DiffusionPathChangeQuery.php @@ -62,6 +62,8 @@ class DiffusionPathChangeQuery { $changes = array(); + + $raw_changes = isort($raw_changes, 'pathName'); foreach ($raw_changes as $raw_change) { $type = $raw_change['changeType']; diff --git a/src/applications/diffusion/view/browsetable/DiffusionBrowseTableView.php b/src/applications/diffusion/view/browsetable/DiffusionBrowseTableView.php index 613ca488ff..bd73cbc6d8 100644 --- a/src/applications/diffusion/view/browsetable/DiffusionBrowseTableView.php +++ b/src/applications/diffusion/view/browsetable/DiffusionBrowseTableView.php @@ -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 = ''.$this->linkBrowse( + $base_path.$path->getPath().$dir_slash, + array( + 'text' => $browse_text, + )).''; } 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(); } diff --git a/src/applications/diffusion/view/browsetable/__init__.php b/src/applications/diffusion/view/browsetable/__init__.php index 12e1f538ef..1dde4b2648 100644 --- a/src/applications/diffusion/view/browsetable/__init__.php +++ b/src/applications/diffusion/view/browsetable/__init__.php @@ -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'); diff --git a/src/applications/repository/storage/commitdata/PhabricatorRepositoryCommitData.php b/src/applications/repository/storage/commitdata/PhabricatorRepositoryCommitData.php index 119393a13f..bb5b2c44ab 100644 --- a/src/applications/repository/storage/commitdata/PhabricatorRepositoryCommitData.php +++ b/src/applications/repository/storage/commitdata/PhabricatorRepositoryCommitData.php @@ -32,4 +32,8 @@ class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO { ) + parent::getConfiguration(); } + public function getSummary() { + return substr($this->getCommitMessage(), 0, 80); + } + }