mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-15 22:04:57 +01:00
In the SVN "Change" view, identify the last time a file was modified instead of 404ing
Summary: If a file was last modified at revision 50 and you look at revision 55, we currently 404. Instead, always identify the last modification. Also simplify some of the query objects. Test Plan: Viewed after-modification revisions for several files in SVN. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran, epriestley Maniphest Tasks: T851 Differential Revision: https://secure.phabricator.com/D2028
This commit is contained in:
parent
43f0076615
commit
ea148c4841
6 changed files with 20 additions and 87 deletions
|
@ -1,7 +1,7 @@
|
|||
<?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.
|
||||
|
@ -16,44 +16,13 @@
|
|||
* 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() {
|
||||
|
@ -64,8 +33,6 @@ abstract class DiffusionDiffQuery {
|
|||
return $this->executeQuery();
|
||||
}
|
||||
|
||||
abstract protected function executeQuery();
|
||||
|
||||
protected function getEffectiveCommit() {
|
||||
$drequest = $this->getRequest();
|
||||
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
|
||||
|
||||
|
||||
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');
|
||||
|
|
|
@ -22,15 +22,14 @@ final class DiffusionSvnDiffQuery extends DiffusionDiffQuery {
|
|||
$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();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?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.
|
||||
|
@ -16,49 +16,15 @@
|
|||
* 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();
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
|
||||
|
||||
|
||||
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');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?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.
|
||||
|
@ -30,6 +30,11 @@ final class DiffusionSvnLastModifiedQuery extends DiffusionLastModifiedQuery {
|
|||
$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());
|
||||
|
|
Loading…
Add table
Reference in a new issue