mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Detect if a commit *really* doesn't exist and 4oh4 from Diffusion commit view
Summary: rather than showing an erroneous "we still parsing" message. Test Plan: for each version control system, typed in a garbage URL and got a 4oh4. (note this actually fails for SVN -- see comment about how my code fails atm -- and DiffusionGitRequest seems to pick off this error in advance and returns an AphrontUsageException.) Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1624 Differential Revision: https://secure.phabricator.com/D3201
This commit is contained in:
parent
d32926e5f7
commit
b86d995b40
6 changed files with 150 additions and 4 deletions
|
@ -327,6 +327,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionDiffController' => 'applications/diffusion/controller/DiffusionDiffController.php',
|
'DiffusionDiffController' => 'applications/diffusion/controller/DiffusionDiffController.php',
|
||||||
'DiffusionDiffQuery' => 'applications/diffusion/query/diff/DiffusionDiffQuery.php',
|
'DiffusionDiffQuery' => 'applications/diffusion/query/diff/DiffusionDiffQuery.php',
|
||||||
'DiffusionEmptyResultView' => 'applications/diffusion/view/DiffusionEmptyResultView.php',
|
'DiffusionEmptyResultView' => 'applications/diffusion/view/DiffusionEmptyResultView.php',
|
||||||
|
'DiffusionExistsQuery' => 'applications/diffusion/query/exists/DiffusionExistsQuery.php',
|
||||||
'DiffusionExternalController' => 'applications/diffusion/controller/DiffusionExternalController.php',
|
'DiffusionExternalController' => 'applications/diffusion/controller/DiffusionExternalController.php',
|
||||||
'DiffusionFileContent' => 'applications/diffusion/data/DiffusionFileContent.php',
|
'DiffusionFileContent' => 'applications/diffusion/data/DiffusionFileContent.php',
|
||||||
'DiffusionFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionFileContentQuery.php',
|
'DiffusionFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionFileContentQuery.php',
|
||||||
|
@ -337,6 +338,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionGitCommitTagsQuery' => 'applications/diffusion/query/committags/DiffusionGitCommitTagsQuery.php',
|
'DiffusionGitCommitTagsQuery' => 'applications/diffusion/query/committags/DiffusionGitCommitTagsQuery.php',
|
||||||
'DiffusionGitContainsQuery' => 'applications/diffusion/query/contains/DiffusionGitContainsQuery.php',
|
'DiffusionGitContainsQuery' => 'applications/diffusion/query/contains/DiffusionGitContainsQuery.php',
|
||||||
'DiffusionGitDiffQuery' => 'applications/diffusion/query/diff/DiffusionGitDiffQuery.php',
|
'DiffusionGitDiffQuery' => 'applications/diffusion/query/diff/DiffusionGitDiffQuery.php',
|
||||||
|
'DiffusionGitExistsQuery' => 'applications/diffusion/query/exists/DiffusionGitExistsQuery.php',
|
||||||
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php',
|
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php',
|
||||||
'DiffusionGitHistoryQuery' => 'applications/diffusion/query/history/DiffusionGitHistoryQuery.php',
|
'DiffusionGitHistoryQuery' => 'applications/diffusion/query/history/DiffusionGitHistoryQuery.php',
|
||||||
'DiffusionGitLastModifiedQuery' => 'applications/diffusion/query/lastmodified/DiffusionGitLastModifiedQuery.php',
|
'DiffusionGitLastModifiedQuery' => 'applications/diffusion/query/lastmodified/DiffusionGitLastModifiedQuery.php',
|
||||||
|
@ -359,6 +361,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionMercurialCommitTagsQuery' => 'applications/diffusion/query/committags/DiffusionMercurialCommitTagsQuery.php',
|
'DiffusionMercurialCommitTagsQuery' => 'applications/diffusion/query/committags/DiffusionMercurialCommitTagsQuery.php',
|
||||||
'DiffusionMercurialContainsQuery' => 'applications/diffusion/query/contains/DiffusionMercurialContainsQuery.php',
|
'DiffusionMercurialContainsQuery' => 'applications/diffusion/query/contains/DiffusionMercurialContainsQuery.php',
|
||||||
'DiffusionMercurialDiffQuery' => 'applications/diffusion/query/diff/DiffusionMercurialDiffQuery.php',
|
'DiffusionMercurialDiffQuery' => 'applications/diffusion/query/diff/DiffusionMercurialDiffQuery.php',
|
||||||
|
'DiffusionMercurialExistsQuery' => 'applications/diffusion/query/exists/DiffusionMercurialExistsQuery.php',
|
||||||
'DiffusionMercurialFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionMercurialFileContentQuery.php',
|
'DiffusionMercurialFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionMercurialFileContentQuery.php',
|
||||||
'DiffusionMercurialHistoryQuery' => 'applications/diffusion/query/history/DiffusionMercurialHistoryQuery.php',
|
'DiffusionMercurialHistoryQuery' => 'applications/diffusion/query/history/DiffusionMercurialHistoryQuery.php',
|
||||||
'DiffusionMercurialLastModifiedQuery' => 'applications/diffusion/query/lastmodified/DiffusionMercurialLastModifiedQuery.php',
|
'DiffusionMercurialLastModifiedQuery' => 'applications/diffusion/query/lastmodified/DiffusionMercurialLastModifiedQuery.php',
|
||||||
|
@ -388,6 +391,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionSvnCommitTagsQuery' => 'applications/diffusion/query/committags/DiffusionSvnCommitTagsQuery.php',
|
'DiffusionSvnCommitTagsQuery' => 'applications/diffusion/query/committags/DiffusionSvnCommitTagsQuery.php',
|
||||||
'DiffusionSvnContainsQuery' => 'applications/diffusion/query/contains/DiffusionSvnContainsQuery.php',
|
'DiffusionSvnContainsQuery' => 'applications/diffusion/query/contains/DiffusionSvnContainsQuery.php',
|
||||||
'DiffusionSvnDiffQuery' => 'applications/diffusion/query/diff/DiffusionSvnDiffQuery.php',
|
'DiffusionSvnDiffQuery' => 'applications/diffusion/query/diff/DiffusionSvnDiffQuery.php',
|
||||||
|
'DiffusionSvnExistsQuery' => 'applications/diffusion/query/exists/DiffusionSvnExistsQuery.php',
|
||||||
'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionSvnFileContentQuery.php',
|
'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionSvnFileContentQuery.php',
|
||||||
'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/DiffusionSvnHistoryQuery.php',
|
'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/DiffusionSvnHistoryQuery.php',
|
||||||
'DiffusionSvnLastModifiedQuery' => 'applications/diffusion/query/lastmodified/DiffusionSvnLastModifiedQuery.php',
|
'DiffusionSvnLastModifiedQuery' => 'applications/diffusion/query/lastmodified/DiffusionSvnLastModifiedQuery.php',
|
||||||
|
@ -1440,6 +1444,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionDiffController' => 'DiffusionController',
|
'DiffusionDiffController' => 'DiffusionController',
|
||||||
'DiffusionDiffQuery' => 'DiffusionQuery',
|
'DiffusionDiffQuery' => 'DiffusionQuery',
|
||||||
'DiffusionEmptyResultView' => 'DiffusionView',
|
'DiffusionEmptyResultView' => 'DiffusionView',
|
||||||
|
'DiffusionExistsQuery' => 'DiffusionQuery',
|
||||||
'DiffusionExternalController' => 'DiffusionController',
|
'DiffusionExternalController' => 'DiffusionController',
|
||||||
'DiffusionFileContentQuery' => 'DiffusionQuery',
|
'DiffusionFileContentQuery' => 'DiffusionQuery',
|
||||||
'DiffusionGitBranchQuery' => 'DiffusionBranchQuery',
|
'DiffusionGitBranchQuery' => 'DiffusionBranchQuery',
|
||||||
|
@ -1449,6 +1454,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionGitCommitTagsQuery' => 'DiffusionCommitTagsQuery',
|
'DiffusionGitCommitTagsQuery' => 'DiffusionCommitTagsQuery',
|
||||||
'DiffusionGitContainsQuery' => 'DiffusionContainsQuery',
|
'DiffusionGitContainsQuery' => 'DiffusionContainsQuery',
|
||||||
'DiffusionGitDiffQuery' => 'DiffusionDiffQuery',
|
'DiffusionGitDiffQuery' => 'DiffusionDiffQuery',
|
||||||
|
'DiffusionGitExistsQuery' => 'DiffusionExistsQuery',
|
||||||
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionGitHistoryQuery' => 'DiffusionHistoryQuery',
|
'DiffusionGitHistoryQuery' => 'DiffusionHistoryQuery',
|
||||||
'DiffusionGitLastModifiedQuery' => 'DiffusionLastModifiedQuery',
|
'DiffusionGitLastModifiedQuery' => 'DiffusionLastModifiedQuery',
|
||||||
|
@ -1471,6 +1477,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionMercurialCommitTagsQuery' => 'DiffusionCommitTagsQuery',
|
'DiffusionMercurialCommitTagsQuery' => 'DiffusionCommitTagsQuery',
|
||||||
'DiffusionMercurialContainsQuery' => 'DiffusionContainsQuery',
|
'DiffusionMercurialContainsQuery' => 'DiffusionContainsQuery',
|
||||||
'DiffusionMercurialDiffQuery' => 'DiffusionDiffQuery',
|
'DiffusionMercurialDiffQuery' => 'DiffusionDiffQuery',
|
||||||
|
'DiffusionMercurialExistsQuery' => 'DiffusionExistsQuery',
|
||||||
'DiffusionMercurialFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionMercurialFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionMercurialHistoryQuery' => 'DiffusionHistoryQuery',
|
'DiffusionMercurialHistoryQuery' => 'DiffusionHistoryQuery',
|
||||||
'DiffusionMercurialLastModifiedQuery' => 'DiffusionLastModifiedQuery',
|
'DiffusionMercurialLastModifiedQuery' => 'DiffusionLastModifiedQuery',
|
||||||
|
@ -1492,6 +1499,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionSvnCommitTagsQuery' => 'DiffusionCommitTagsQuery',
|
'DiffusionSvnCommitTagsQuery' => 'DiffusionCommitTagsQuery',
|
||||||
'DiffusionSvnContainsQuery' => 'DiffusionContainsQuery',
|
'DiffusionSvnContainsQuery' => 'DiffusionContainsQuery',
|
||||||
'DiffusionSvnDiffQuery' => 'DiffusionDiffQuery',
|
'DiffusionSvnDiffQuery' => 'DiffusionDiffQuery',
|
||||||
|
'DiffusionSvnExistsQuery' => 'DiffusionExistsQuery',
|
||||||
'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
|
'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
|
||||||
'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery',
|
'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery',
|
||||||
'DiffusionSvnLastModifiedQuery' => 'DiffusionLastModifiedQuery',
|
'DiffusionSvnLastModifiedQuery' => 'DiffusionLastModifiedQuery',
|
||||||
|
|
|
@ -50,13 +50,16 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
$commit = $drequest->loadCommit();
|
$commit = $drequest->loadCommit();
|
||||||
|
|
||||||
if (!$commit) {
|
if (!$commit) {
|
||||||
// TODO -- T1624 -- detect if this has actually not been parsed yet
|
$query = DiffusionExistsQuery::newFromDiffusionRequest($drequest);
|
||||||
// and show this UI if so, else 404
|
$exists = $query->loadExistentialData();
|
||||||
|
if (!$exists) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
id(new AphrontErrorView())
|
id(new AphrontErrorView())
|
||||||
->setTitle('Error displaying commit.')
|
->setTitle('Error displaying commit.')
|
||||||
->appendChild('Failed to load the commit. The commit has not been '.
|
->appendChild('Failed to load the commit because the commit has not '.
|
||||||
'parsed yet.'),
|
'been parsed yet.'),
|
||||||
array('title' => 'Commit Still Parsing')
|
array('title' => 'Commit Still Parsing')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract class DiffusionExistsQuery extends DiffusionQuery {
|
||||||
|
|
||||||
|
final public static function newFromDiffusionRequest(
|
||||||
|
DiffusionRequest $request) {
|
||||||
|
return self::newQueryObject(__CLASS__, $request);
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function loadExistentialData() {
|
||||||
|
return $this->executeQuery();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?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 DiffusionGitExistsQuery extends DiffusionExistsQuery {
|
||||||
|
|
||||||
|
final protected function executeQuery() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$repository = $request->getRepository();
|
||||||
|
|
||||||
|
list($err, $merge_base) = $repository->execLocalCommand(
|
||||||
|
'cat-file -t %s',
|
||||||
|
$request->getCommit()
|
||||||
|
);
|
||||||
|
|
||||||
|
return !$err;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?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 DiffusionMercurialExistsQuery extends DiffusionExistsQuery {
|
||||||
|
|
||||||
|
protected function executeQuery() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$repository = $request->getRepository();
|
||||||
|
|
||||||
|
list($err, $stdout) = $repository->execLocalCommand(
|
||||||
|
'id --rev %s',
|
||||||
|
$request->getCommit()
|
||||||
|
);
|
||||||
|
|
||||||
|
return !$err;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?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 DiffusionSvnExistsQuery extends DiffusionExistsQuery {
|
||||||
|
|
||||||
|
protected function executeQuery() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$repository = $request->getRepository();
|
||||||
|
|
||||||
|
list($info) = $repository->execxRemoteCommand(
|
||||||
|
'info %s',
|
||||||
|
$repository->getRemoteURI()
|
||||||
|
);
|
||||||
|
|
||||||
|
$matches = null;
|
||||||
|
$exists = false;
|
||||||
|
if (preg_match('/^Revision: (\d+)$/m', $info, $matches)) {
|
||||||
|
$base_revision = $matches[1];
|
||||||
|
$exists = $base_revision >= $request->getCommit();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $exists;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue