Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/diffusion/query/diff/base/DiffusionDiffQuery.php b/src/applications/diffusion/query/diff/base/DiffusionDiffQuery.php
index 05708cc5ff..c29590ff78 100644
--- a/src/applications/diffusion/query/diff/base/DiffusionDiffQuery.php
+++ b/src/applications/diffusion/query/diff/base/DiffusionDiffQuery.php
@@ -1,82 +1,49 @@
<?php
/*
- * Copyright 2011 Facebook, Inc.
+ * Copyright 2012 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 DiffusionDiffQuery {
+abstract class DiffusionDiffQuery extends DiffusionQuery {
- private $request;
protected $renderingReference;
- final private function __construct() {
- // <private>
- }
-
final public static function newFromDiffusionRequest(
DiffusionRequest $request) {
-
- $repository = $request->getRepository();
-
- switch ($repository->getVersionControlSystem()) {
- case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
- $class = 'DiffusionGitDiffQuery';
- break;
- case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
- $class = 'DiffusionMercurialDiffQuery';
- break;
- case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
- $class = 'DiffusionSvnDiffQuery';
- break;
- default:
- throw new Exception("Unsupported VCS!");
- }
-
- PhutilSymbolLoader::loadClass($class);
- $query = new $class();
-
- $query->request = $request;
-
- return $query;
- }
-
- final protected function getRequest() {
- return $this->request;
+ return parent::newQueryObject(__CLASS__, $request);
}
final public function getRenderingReference() {
return $this->renderingReference;
}
final public function loadChangeset() {
return $this->executeQuery();
}
- abstract protected function executeQuery();
-
protected function getEffectiveCommit() {
$drequest = $this->getRequest();
$modified_query = DiffusionLastModifiedQuery::newFromDiffusionRequest(
$drequest);
list($commit) = $modified_query->loadLastModification();
if (!$commit) {
// TODO: Improve error messages here.
return null;
}
return $commit->getCommitIdentifier();
}
}
diff --git a/src/applications/diffusion/query/diff/base/__init__.php b/src/applications/diffusion/query/diff/base/__init__.php
index d6ecf69496..bf1f89873f 100644
--- a/src/applications/diffusion/query/diff/base/__init__.php
+++ b/src/applications/diffusion/query/diff/base/__init__.php
@@ -1,15 +1,13 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
+phutil_require_module('phabricator', 'applications/diffusion/query/base');
phutil_require_module('phabricator', 'applications/diffusion/query/lastmodified/base');
-phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
-
-phutil_require_module('phutil', 'symbols');
phutil_require_source('DiffusionDiffQuery.php');
diff --git a/src/applications/diffusion/query/diff/svn/DiffusionSvnDiffQuery.php b/src/applications/diffusion/query/diff/svn/DiffusionSvnDiffQuery.php
index e56be33a90..3824c74df1 100644
--- a/src/applications/diffusion/query/diff/svn/DiffusionSvnDiffQuery.php
+++ b/src/applications/diffusion/query/diff/svn/DiffusionSvnDiffQuery.php
@@ -1,164 +1,163 @@
<?php
/*
* Copyright 2012 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 DiffusionSvnDiffQuery extends DiffusionDiffQuery {
protected function executeQuery() {
$drequest = $this->getRequest();
$repository = $drequest->getRepository();
- if (!$drequest->getRawCommit()) {
- $effective_commit = $this->getEffectiveCommit();
- if (!$effective_commit) {
- return null;
- }
- // TODO: Sketchy side effect.
- $drequest->setCommit($effective_commit);
+ $effective_commit = $this->getEffectiveCommit();
+ if (!$effective_commit) {
+ return null;
}
+ $drequest = clone $drequest;
+ $drequest->setCommit($effective_commit);
+
$path_change_query = DiffusionPathChangeQuery::newFromDiffusionRequest(
$drequest);
$path_changes = $path_change_query->loadChanges();
$path = null;
foreach ($path_changes as $change) {
if ($change->getPath() == $drequest->getPath()) {
$path = $change;
}
}
if (!$path) {
return null;
}
$change_type = $path->getChangeType();
switch ($change_type) {
case DifferentialChangeType::TYPE_MULTICOPY:
case DifferentialChangeType::TYPE_DELETE:
if ($path->getTargetPath()) {
$old = array(
$path->getTargetPath(),
$path->getTargetCommitIdentifier());
} else {
$old = array($path->getPath(), $path->getCommitIdentifier() - 1);
}
$old_name = $path->getPath();
$new_name = '';
$new = null;
break;
case DifferentialChangeType::TYPE_ADD:
$old = null;
$new = array($path->getPath(), $path->getCommitIdentifier());
$old_name = '';
$new_name = $path->getPath();
break;
case DifferentialChangeType::TYPE_MOVE_HERE:
case DifferentialChangeType::TYPE_COPY_HERE:
$old = array(
$path->getTargetPath(),
$path->getTargetCommitIdentifier());
$new = array($path->getPath(), $path->getCommitIdentifier());
$old_name = $path->getTargetPath();
$new_name = $path->getPath();
break;
case DifferentialChangeType::TYPE_MOVE_AWAY:
$old = array(
$path->getPath(),
$path->getCommitIdentifier() - 1);
$old_name = $path->getPath();
$new_name = null;
$new = null;
break;
default:
$old = array($path->getPath(), $path->getCommitIdentifier() - 1);
$new = array($path->getPath(), $path->getCommitIdentifier());
$old_name = $path->getPath();
$new_name = $path->getPath();
break;
}
$futures = array(
'old' => $this->buildContentFuture($old),
'new' => $this->buildContentFuture($new),
);
$futures = array_filter($futures);
foreach (Futures($futures) as $key => $future) {
$stdout = '';
try {
list($stdout) = $future->resolvex();
} catch (CommandException $e) {
if ($path->getFileType() != DifferentialChangeType::FILE_DIRECTORY) {
throw $e;
}
}
$futures[$key] = $stdout;
}
$old_data = idx($futures, 'old', '');
$new_data = idx($futures, 'new', '');
$engine = new PhabricatorDifferenceEngine();
$engine->setOldName($old_name);
$engine->setNewName($new_name);
$raw_diff = $engine->generateRawDiffFromFileContent($old_data, $new_data);
$parser = new ArcanistDiffParser();
$try_encoding = $repository->getDetail('encoding');
if ($try_encoding) {
$parser->setTryEncoding($try_encoding);
}
$parser->setDetectBinaryFiles(true);
$arcanist_changes = DiffusionPathChange::convertToArcanistChanges(
$path_changes);
$parser->setChanges($arcanist_changes);
$parser->forcePath($path->getPath());
$changes = $parser->parseDiff($raw_diff);
$change = $changes[$path->getPath()];
$diff = DifferentialDiff::newFromRawChanges(array($change));
$changesets = $diff->getChangesets();
$changeset = reset($changesets);
$this->renderingReference = $drequest->getPath().';'.$drequest->getCommit();
return $changeset;
}
private function buildContentFuture($spec) {
if (!$spec) {
return null;
}
$drequest = $this->getRequest();
$repository = $drequest->getRepository();
list($ref, $rev) = $spec;
return $repository->getRemoteCommandFuture(
'cat %s%s@%d',
$repository->getRemoteURI(),
$ref,
$rev);
}
}
diff --git a/src/applications/diffusion/query/lastmodified/base/DiffusionLastModifiedQuery.php b/src/applications/diffusion/query/lastmodified/base/DiffusionLastModifiedQuery.php
index 4f5a3c4aee..9359266952 100644
--- a/src/applications/diffusion/query/lastmodified/base/DiffusionLastModifiedQuery.php
+++ b/src/applications/diffusion/query/lastmodified/base/DiffusionLastModifiedQuery.php
@@ -1,64 +1,30 @@
<?php
/*
- * Copyright 2011 Facebook, Inc.
+ * Copyright 2012 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 DiffusionLastModifiedQuery {
-
- private $request;
-
- final private function __construct() {
- // <private>
- }
+abstract class DiffusionLastModifiedQuery extends DiffusionQuery {
final public static function newFromDiffusionRequest(
DiffusionRequest $request) {
-
- $repository = $request->getRepository();
-
- switch ($repository->getVersionControlSystem()) {
- case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
- $class = 'DiffusionGitLastModifiedQuery';
- break;
- case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
- $class = 'DiffusionMercurialLastModifiedQuery';
- break;
- case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
- $class = 'DiffusionSvnLastModifiedQuery';
- break;
- default:
- throw new Exception("Unsupported VCS!");
- }
-
- PhutilSymbolLoader::loadClass($class);
- $query = new $class();
-
- $query->request = $request;
-
- return $query;
- }
-
- final protected function getRequest() {
- return $this->request;
+ return parent::newQueryObject(__CLASS__, $request);
}
final public function loadLastModification() {
return $this->executeQuery();
}
- abstract protected function executeQuery();
-
}
diff --git a/src/applications/diffusion/query/lastmodified/base/__init__.php b/src/applications/diffusion/query/lastmodified/base/__init__.php
index 201f669215..de060b1f6b 100644
--- a/src/applications/diffusion/query/lastmodified/base/__init__.php
+++ b/src/applications/diffusion/query/lastmodified/base/__init__.php
@@ -1,14 +1,12 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
-phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
-
-phutil_require_module('phutil', 'symbols');
+phutil_require_module('phabricator', 'applications/diffusion/query/base');
phutil_require_source('DiffusionLastModifiedQuery.php');
diff --git a/src/applications/diffusion/query/lastmodified/svn/DiffusionSvnLastModifiedQuery.php b/src/applications/diffusion/query/lastmodified/svn/DiffusionSvnLastModifiedQuery.php
index 513b72550b..c6c1e4b6f4 100644
--- a/src/applications/diffusion/query/lastmodified/svn/DiffusionSvnLastModifiedQuery.php
+++ b/src/applications/diffusion/query/lastmodified/svn/DiffusionSvnLastModifiedQuery.php
@@ -1,38 +1,43 @@
<?php
/*
- * Copyright 2011 Facebook, Inc.
+ * Copyright 2012 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();
+
+ if (!$history_array) {
+ return array(null, null);
+ }
+
$history = reset($history_array);
return array($history->getCommit(), $history->getCommitData());
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Nov 14, 12:04 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
337000
Default Alt Text
(13 KB)

Event Timeline