Page MenuHomePhorge

No OneTemporary

diff --git a/src/applications/diffusion/query/history/base/DiffusionHistoryQuery.php b/src/applications/diffusion/query/history/base/DiffusionHistoryQuery.php
index 78e8eaf182..20f6923232 100644
--- a/src/applications/diffusion/query/history/base/DiffusionHistoryQuery.php
+++ b/src/applications/diffusion/query/history/base/DiffusionHistoryQuery.php
@@ -1,87 +1,93 @@
<?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.
*/
abstract class DiffusionHistoryQuery {
private $request;
private $limit = 100;
private $offset = 0;
protected $needDirectChanges;
+ protected $needChildChanges;
final private function __construct() {
// <private>
}
final public static function newFromDiffusionRequest(
DiffusionRequest $request) {
$repository = $request->getRepository();
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$class = 'DiffusionGitHistoryQuery';
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$class = 'DiffusionSvnHistoryQuery';
break;
default:
throw new Exception("Unsupported VCS!");
}
PhutilSymbolLoader::loadClass($class);
$query = new $class();
$query->request = $request;
return $query;
}
final public function needDirectChanges($direct) {
$this->needDirectChanges = $direct;
return $this;
}
+ final public function needChildChanges($child) {
+ $this->needChildChanges = $child;
+ return $this;
+ }
+
final protected function getRequest() {
return $this->request;
}
final public function loadHistory() {
return $this->executeQuery();
}
final public function setLimit($limit) {
$this->limit = $limit;
return $this;
}
final public function getLimit() {
return $this->limit;
}
final public function setOffset($offset) {
$this->offset = $offset;
return $this;
}
final public function getOffset() {
return $this->offset;
}
abstract protected function executeQuery();
}
diff --git a/src/applications/diffusion/query/history/svn/DiffusionSvnHistoryQuery.php b/src/applications/diffusion/query/history/svn/DiffusionSvnHistoryQuery.php
index ac6f16fa10..34cc7a78da 100644
--- a/src/applications/diffusion/query/history/svn/DiffusionSvnHistoryQuery.php
+++ b/src/applications/diffusion/query/history/svn/DiffusionSvnHistoryQuery.php
@@ -1,93 +1,103 @@
<?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 DiffusionSvnHistoryQuery extends DiffusionHistoryQuery {
protected function executeQuery() {
$drequest = $this->getRequest();
$repository = $drequest->getRepository();
$path = $drequest->getPath();
$commit = $drequest->getCommit();
$conn_r = $repository->establishConnection('r');
$paths = queryfx_all(
$conn_r,
'SELECT id, path FROM %T WHERE path IN (%Ls)',
PhabricatorRepository::TABLE_PATH,
array('/'.trim($path, '/')));
$paths = ipull($paths, 'id', 'path');
$path_id = $paths['/'.trim($path, '/')];
+ $filter_query = '';
+ if ($this->needDirectChanges) {
+ if ($this->needChildChanges) {
+ $type = DifferentialChangeType::TYPE_CHILD;
+ $filter_query = 'AND (isDirect = 1 OR changeType = '.$type.')';
+ } else {
+ $filter_query = 'AND (isDirect = 1)';
+ }
+ }
+
$history_data = queryfx_all(
$conn_r,
'SELECT * FROM %T WHERE repositoryID = %d AND pathID = %d
AND commitSequence <= %d
%Q
ORDER BY commitSequence DESC
LIMIT %d, %d',
PhabricatorRepository::TABLE_PATHCHANGE,
$repository->getID(),
$path_id,
$commit ? $commit : 0x7FFFFFFF,
- ($this->needDirectChanges ? 'AND isDirect = 1' : ''),
+ $filter_query,
$this->getOffset(),
$this->getLimit());
$commits = array();
$commit_data = array();
$commit_ids = ipull($history_data, 'commitID');
if ($commit_ids) {
$commits = id(new PhabricatorRepositoryCommit())->loadAllWhere(
'id IN (%Ld)',
$commit_ids);
if ($commits) {
$commit_data = id(new PhabricatorRepositoryCommitData())->loadAllWhere(
'commitID in (%Ld)',
$commit_ids);
$commit_data = mpull($commit_data, null, 'getCommitID');
}
}
$history = array();
foreach ($history_data as $row) {
$item = new DiffusionPathChange();
$commit = idx($commits, $row['commitID']);
if ($commit) {
$item->setCommit($commit);
$item->setCommitIdentifier($commit->getCommitIdentifier());
$data = idx($commit_data, $commit->getID());
if ($data) {
$item->setCommitData($data);
}
}
$item->setChangeType($row['changeType']);
$item->setFileType($row['fileType']);
$history[] = $item;
}
return $history;
}
}
diff --git a/src/applications/diffusion/query/history/svn/__init__.php b/src/applications/diffusion/query/history/svn/__init__.php
index 4c14b8da0f..485c9296d6 100644
--- a/src/applications/diffusion/query/history/svn/__init__.php
+++ b/src/applications/diffusion/query/history/svn/__init__.php
@@ -1,19 +1,20 @@
<?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/diffusion/query/history/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('DiffusionSvnHistoryQuery.php');
diff --git a/src/applications/diffusion/query/lastmodified/svn/DiffusionSvnLastModifiedQuery.php b/src/applications/diffusion/query/lastmodified/svn/DiffusionSvnLastModifiedQuery.php
index 3604c3a63a..513b72550b 100644
--- a/src/applications/diffusion/query/lastmodified/svn/DiffusionSvnLastModifiedQuery.php
+++ b/src/applications/diffusion/query/lastmodified/svn/DiffusionSvnLastModifiedQuery.php
@@ -1,38 +1,38 @@
<?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 DiffusionSvnLastModifiedQuery extends DiffusionLastModifiedQuery {
protected function executeQuery() {
$drequest = $this->getRequest();
$repository = $drequest->getRepository();
$path = $drequest->getPath();
$history_query = DiffusionHistoryQuery::newFromDiffusionRequest(
$drequest);
$history_query->setLimit(1);
-
+ $history_query->needChildChanges(true);
$history_query->needDirectChanges(true);
$history_array = $history_query->loadHistory();
$history = reset($history_array);
return array($history->getCommit(), $history->getCommitData());
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 14:55 (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1125703
Default Alt Text
(8 KB)

Event Timeline