Page MenuHomePhorge

No OneTemporary

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
@@ -1,157 +1,166 @@
<?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 DiffusionPathChange {
private $path;
private $commitIdentifier;
private $commit;
private $commitData;
private $changeType;
private $fileType;
private $targetPath;
private $targetCommitIdentifier;
private $awayPaths = array();
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;
}
public function setAwayPaths(array $away_paths) {
$this->awayPaths = $away_paths;
return $this;
}
public function getAwayPaths() {
return $this->awayPaths;
}
final public function setCommitIdentifier($commit) {
$this->commitIdentifier = $commit;
return $this;
}
final public function getCommitIdentifier() {
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;
}
final public function getCommit() {
return $this->commit;
}
final public function setCommitData($commit_data) {
$this->commitData = $commit_data;
return $this;
}
final public function getCommitData() {
return $this->commitData;
}
final public function getEpoch() {
if ($this->getCommit()) {
return $this->getCommit()->getEpoch();
}
return null;
}
final public function getAuthorName() {
if ($this->getCommitData()) {
return $this->getCommitData()->getAuthorName();
}
return null;
}
final public function getSummary() {
if (!$this->getCommitData()) {
return null;
}
$message = $this->getCommitData()->getCommitMessage();
$first = idx(explode("\n", $message), 0);
return substr($first, 0, 80);
}
final public static function convertToArcanistChanges(array $changes) {
$direct = array();
$result = array();
foreach ($changes as $path) {
$change = new ArcanistDiffChange();
$change->setCurrentPath($path->getPath());
$direct[] = $path->getPath();
$change->setType($path->getChangeType());
$file_type = $path->getFileType();
if ($file_type == DifferentialChangeType::FILE_NORMAL) {
$file_type = DifferentialChangeType::FILE_TEXT;
}
$change->setFileType($file_type);
$change->setOldPath($path->getTargetPath());
foreach ($path->getAwayPaths() as $away_path) {
$change->addAwayPath($away_path);
}
$result[$path->getPath()] = $change;
}
return array_select_keys($result, $direct);
}
final public static function convertToDifferentialChangesets(array $changes) {
$arcanist_changes = self::convertToArcanistChanges($changes);
$diff = DifferentialDiff::newFromRawChanges($arcanist_changes);
return $diff->getChangesets();
}
}
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
@@ -1,62 +1,85 @@
<?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 DiffusionRepositoryPath {
private $path;
private $hash;
private $fileType;
private $fileSize;
+ private $lastModifiedCommit;
+ private $lastCommitData;
+
final public function setPath($path) {
$this->path = $path;
return $this;
}
final public function getPath() {
return $this->path;
}
final public function setHash($hash) {
$this->hash = $hash;
return $this;
}
final public function getHash() {
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;
}
final public function getFileType() {
return $this->fileType;
}
final public function setFileSize($file_size) {
$this->fileSize = $file_size;
return $this;
}
final public function getFileSize() {
return $this->fileSize;
}
}
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
@@ -1,146 +1,181 @@
<?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 DiffusionSvnBrowseQuery extends DiffusionBrowseQuery {
protected function executeQuery() {
$drequest = $this->getRequest();
$repository = $drequest->getRepository();
$path = $drequest->getPath();
$commit = $drequest->getCommit();
$conn_r = $repository->establishConnection('r');
$parent_path = dirname($path);
$path_query = new DiffusionGitPathIDQuery(
array(
$path,
$parent_path,
));
$path_map = $path_query->loadPathIDs();
$path_id = $path_map[$path];
$parent_path_id = $path_map[$parent_path];
if (empty($path_id)) {
$this->reason = self::REASON_IS_NONEXISTENT;
return array();
}
if ($commit) {
$slice_clause = 'AND svnCommit <= '.(int)$commit;
} else {
$slice_clause = '';
}
$index = queryfx_all(
$conn_r,
'SELECT pathID, max(svnCommit) maxCommit FROM %T WHERE
repositoryID = %d AND parentID = %d
%Q GROUP BY pathID',
PhabricatorRepository::TABLE_FILESYSTEM,
$repository->getID(),
$path_id,
$slice_clause);
if (!$index) {
if ($path == '/') {
$this->reason = self::REASON_IS_EMPTY;
} else {
// NOTE: The parent path ID is included so this query can take
// advantage of the table's primary key; it is uniquely determined by
// the pathID but if we don't do the lookup ourselves MySQL doesn't have
// the information it needs to avoid a table scan.
$reasons = queryfx_all(
$conn_r,
'SELECT * FROM %T WHERE repositoryID = %d
AND parentID = %d
AND pathID = %d
%Q ORDER BY svnCommit DESC LIMIT 2',
PhabricatorRepository::TABLE_FILESYSTEM,
$repository->getID(),
$parent_path_id,
$path_id,
$slice_clause);
$reason = reset($reasons);
if (!$reason) {
$this->reason = self::REASON_IS_NONEXISTENT;
} else {
$file_type = $reason['fileType'];
if (empty($reason['existed'])) {
$this->reason = self::REASON_IS_DELETED;
$this->deletedAtCommit = $reason['svnCommit'];
if (!empty($reasons[1])) {
$this->existedAtCommit = $reasons[1]['svnCommit'];
}
} else if ($file_type == DifferentialChangeType::FILE_DIRECTORY) {
$this->reason = self::REASON_IS_EMPTY;
} else {
$this->reason = self::REASON_IS_FILE;
}
}
}
return array();
}
$sql = array();
foreach ($index as $row) {
$sql[] = '('.(int)$row['pathID'].', '.(int)$row['maxCommit'].')';
}
$browse = queryfx_all(
$conn_r,
'SELECT *, p.path pathName
FROM %T f JOIN %T p ON f.pathID = p.id
WHERE repositoryID = %d
AND parentID = %d
AND existed = 1
AND (pathID, svnCommit) in (%Q)
ORDER BY pathName',
PhabricatorRepository::TABLE_FILESYSTEM,
PhabricatorRepository::TABLE_PATH,
$repository->getID(),
$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();
foreach ($browse as $file) {
$file_path = $file['pathName'];
$file_path = ltrim(substr($file_path, strlen($path_normal)), '/');
$result = new DiffusionRepositoryPath();
$result->setPath($file_path);
// $result->setHash($hash);
$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;
}
return $results;
}
}
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
@@ -1,17 +1,21 @@
<?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/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
@@ -1,82 +1,84 @@
<?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 = $drequest->loadCommit();
$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 AND isDirect = 1',
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']);
$change->setCommitIdentifier($commit->getCommitIdentifier());
$changes[] = $change;
}
return $changes;
}
}
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
@@ -1,71 +1,117 @@
<?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 DiffusionBrowseTableView extends DiffusionView {
private $paths;
public function setPaths(array $paths) {
$this->paths = $paths;
return $this;
}
public function render() {
$request = $this->getDiffusionRequest();
+ $repository = $request->getRepository();
$base_path = trim($request->getPath(), '/');
if ($base_path) {
$base_path = $base_path.'/';
}
$rows = array();
foreach ($this->paths as $path) {
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,
);
}
$view = new AphrontTableView($rows);
$view->setHeaders(
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
@@ -1,14 +1,16 @@
<?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/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
@@ -1,35 +1,39 @@
<?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 PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO {
protected $commitID;
protected $authorName;
protected $commitMessage;
protected $commitDetails = array();
public function getConfiguration() {
return array(
self::CONFIG_TIMESTAMPS => false,
self::CONFIG_SERIALIZATION => array(
'commitDetails' => self::SERIALIZATION_JSON,
),
) + parent::getConfiguration();
}
+ public function getSummary() {
+ return substr($this->getCommitMessage(), 0, 80);
+ }
+
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 16:55 (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126691
Default Alt Text
(22 KB)

Event Timeline