mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 04:02:43 +01:00
(stable) Fix several error handling issues with Subversion commits in Diffusion
Summary: Ref T9513. I checked this briefly but didn't do a very thorough job of it. - Don't try to query merges for Subversion, since it doesn't support them. - Fix up "existsquery" to work properly (and efficiently) for both hosted and imported repositories. - Fix up "parentsquery" to have similar behavior on invalid commits to other VCSes (throw an exception). Test Plan: - No more merges warning on SVN. - Hosted SVN gets the right exists result now. - Visiting "r23980283789287" now 404's instead of "not parsed yet". Reviewers: chad Reviewed By: chad Maniphest Tasks: T9513 Differential Revision: https://secure.phabricator.com/D14239
This commit is contained in:
parent
f760b3ec98
commit
5194ff3db5
3 changed files with 33 additions and 19 deletions
|
@ -33,16 +33,13 @@ final class DiffusionExistsQueryConduitAPIMethod
|
|||
protected function getSVNResult(ConduitAPIRequest $request) {
|
||||
$repository = $this->getDiffusionRequest()->getRepository();
|
||||
$commit = $request->getValue('commit');
|
||||
list($info) = $repository->execxRemoteCommand(
|
||||
'info %s',
|
||||
$repository->getRemoteURI());
|
||||
$exists = false;
|
||||
$matches = null;
|
||||
if (preg_match('/^Revision: (\d+)$/m', $info, $matches)) {
|
||||
$base_revision = $matches[1];
|
||||
$exists = $base_revision >= $commit;
|
||||
}
|
||||
return $exists;
|
||||
|
||||
$refs = id(new DiffusionCachedResolveRefsQuery())
|
||||
->setRepository($repository)
|
||||
->withRefs(array($commit))
|
||||
->execute();
|
||||
|
||||
return (bool)$refs;
|
||||
}
|
||||
|
||||
protected function getMercurialResult(ConduitAPIRequest $request) {
|
||||
|
|
|
@ -1136,14 +1136,17 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
$merge_limit = $this->getMergeDisplayLimit();
|
||||
|
||||
try {
|
||||
$merges = $this->callConduitWithDiffusionRequest(
|
||||
'diffusion.mergedcommitsquery',
|
||||
array(
|
||||
'commit' => $commit,
|
||||
'limit' => $merge_limit + 1,
|
||||
));
|
||||
|
||||
$this->commitMerges = DiffusionPathChange::newFromConduit($merges);
|
||||
if ($repository->isSVN()) {
|
||||
$this->commitMerges = array();
|
||||
} else {
|
||||
$merges = $this->callConduitWithDiffusionRequest(
|
||||
'diffusion.mergedcommitsquery',
|
||||
array(
|
||||
'commit' => $commit,
|
||||
'limit' => $merge_limit + 1,
|
||||
));
|
||||
$this->commitMerges = DiffusionPathChange::newFromConduit($merges);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
$this->commitMerges = false;
|
||||
$exceptions[] = $ex;
|
||||
|
|
|
@ -70,7 +70,21 @@ final class DiffusionLowLevelParentsQuery
|
|||
}
|
||||
|
||||
private function loadSubversionParents() {
|
||||
$n = (int)$this->identifier;
|
||||
$repository = $this->getRepository();
|
||||
$identifier = $this->identifier;
|
||||
|
||||
$refs = id(new DiffusionCachedResolveRefsQuery())
|
||||
->setRepository($repository)
|
||||
->withRefs(array($identifier))
|
||||
->execute();
|
||||
if (!$refs) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'No commit "%s" in this repository.',
|
||||
$identifier));
|
||||
}
|
||||
|
||||
$n = (int)$identifier;
|
||||
if ($n > 1) {
|
||||
$ids = array($n - 1);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue