mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Diffusion - replace last hg manifest
call with hg locate
Summary: Fixes T4387. Test Plan: Setup a mercurial repository for rabbitmq-server. Browsed around it and things looked good. Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T4387 Differential Revision: https://secure.phabricator.com/D10380
This commit is contained in:
parent
763d6dd3a7
commit
d1936711a0
4 changed files with 49 additions and 13 deletions
|
@ -425,6 +425,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionLowLevelCommitQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php',
|
||||
'DiffusionLowLevelGitRefQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php',
|
||||
'DiffusionLowLevelMercurialBranchesQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php',
|
||||
'DiffusionLowLevelMercurialPathsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php',
|
||||
'DiffusionLowLevelParentsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelParentsQuery.php',
|
||||
'DiffusionLowLevelQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php',
|
||||
'DiffusionLowLevelResolveRefsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php',
|
||||
|
@ -3182,6 +3183,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionLowLevelCommitQuery' => 'DiffusionLowLevelQuery',
|
||||
'DiffusionLowLevelGitRefQuery' => 'DiffusionLowLevelQuery',
|
||||
'DiffusionLowLevelMercurialBranchesQuery' => 'DiffusionLowLevelQuery',
|
||||
'DiffusionLowLevelMercurialPathsQuery' => 'DiffusionLowLevelQuery',
|
||||
'DiffusionLowLevelParentsQuery' => 'DiffusionLowLevelQuery',
|
||||
'DiffusionLowLevelQuery' => 'Phobject',
|
||||
'DiffusionLowLevelResolveRefsQuery' => 'DiffusionLowLevelQuery',
|
||||
|
|
|
@ -198,18 +198,16 @@ final class DiffusionBrowseQueryConduitAPIMethod
|
|||
$commit = $request->getValue('commit');
|
||||
$result = $this->getEmptyResultSet();
|
||||
|
||||
$match_against = trim($path, '/');
|
||||
|
||||
$prefix = trim('./'.$match_against, '/');
|
||||
|
||||
list($entire_manifest) = $repository->execxLocalCommand(
|
||||
'locate --print0 --rev %s -I %s',
|
||||
hgsprintf('%s', $commit),
|
||||
$prefix);
|
||||
$entire_manifest = explode("\0", $entire_manifest);
|
||||
$entire_manifest = id(new DiffusionLowLevelMercurialPathsQuery())
|
||||
->setRepository($repository)
|
||||
->withCommit($commit)
|
||||
->withPath($path)
|
||||
->execute();
|
||||
|
||||
$results = array();
|
||||
|
||||
$match_against = trim($path, '/');
|
||||
$match_len = strlen($match_against);
|
||||
|
||||
// For the root, don't trim. For other paths, trim the "/" after we match.
|
||||
|
|
|
@ -55,11 +55,11 @@ final class DiffusionQueryPathsConduitAPIMethod
|
|||
$path = $request->getValue('path');
|
||||
$commit = $request->getValue('commit');
|
||||
|
||||
// Adapted from diffusion.browsequery.
|
||||
list($entire_manifest) = $repository->execxLocalCommand(
|
||||
'manifest --rev %s',
|
||||
hgsprintf('%s', $commit));
|
||||
$entire_manifest = explode("\n", $entire_manifest);
|
||||
$entire_manifest = id(new DiffusionLowLevelMercurialPathsQuery())
|
||||
->setRepository($repository)
|
||||
->withCommit($commit)
|
||||
->withPath($path)
|
||||
->execute();
|
||||
|
||||
$match_against = trim($path, '/');
|
||||
$match_len = strlen($match_against);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Execute and parse a low-level Mercurial paths query using `hg locate`.
|
||||
*/
|
||||
final class DiffusionLowLevelMercurialPathsQuery
|
||||
extends DiffusionLowLevelQuery {
|
||||
|
||||
private $commit;
|
||||
private $path;
|
||||
|
||||
public function withCommit($commit) {
|
||||
$this->commit = $commit;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withPath($path) {
|
||||
$this->path = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function executeQuery() {
|
||||
$repository = $this->getRepository();
|
||||
$path = $this->path;
|
||||
$commit = $this->commit;
|
||||
|
||||
$match_against = trim($path, '/');
|
||||
$prefix = trim('./'.$match_against, '/');
|
||||
list($entire_manifest) = $repository->execxLocalCommand(
|
||||
'locate --print0 --rev %s -I %s',
|
||||
hgsprintf('%s', $commit),
|
||||
$prefix);
|
||||
return explode("\0", $entire_manifest);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue