mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10: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',
|
'DiffusionLowLevelCommitQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelCommitQuery.php',
|
||||||
'DiffusionLowLevelGitRefQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php',
|
'DiffusionLowLevelGitRefQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php',
|
||||||
'DiffusionLowLevelMercurialBranchesQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php',
|
'DiffusionLowLevelMercurialBranchesQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php',
|
||||||
|
'DiffusionLowLevelMercurialPathsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php',
|
||||||
'DiffusionLowLevelParentsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelParentsQuery.php',
|
'DiffusionLowLevelParentsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelParentsQuery.php',
|
||||||
'DiffusionLowLevelQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php',
|
'DiffusionLowLevelQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php',
|
||||||
'DiffusionLowLevelResolveRefsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php',
|
'DiffusionLowLevelResolveRefsQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php',
|
||||||
|
@ -3182,6 +3183,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionLowLevelCommitQuery' => 'DiffusionLowLevelQuery',
|
'DiffusionLowLevelCommitQuery' => 'DiffusionLowLevelQuery',
|
||||||
'DiffusionLowLevelGitRefQuery' => 'DiffusionLowLevelQuery',
|
'DiffusionLowLevelGitRefQuery' => 'DiffusionLowLevelQuery',
|
||||||
'DiffusionLowLevelMercurialBranchesQuery' => 'DiffusionLowLevelQuery',
|
'DiffusionLowLevelMercurialBranchesQuery' => 'DiffusionLowLevelQuery',
|
||||||
|
'DiffusionLowLevelMercurialPathsQuery' => 'DiffusionLowLevelQuery',
|
||||||
'DiffusionLowLevelParentsQuery' => 'DiffusionLowLevelQuery',
|
'DiffusionLowLevelParentsQuery' => 'DiffusionLowLevelQuery',
|
||||||
'DiffusionLowLevelQuery' => 'Phobject',
|
'DiffusionLowLevelQuery' => 'Phobject',
|
||||||
'DiffusionLowLevelResolveRefsQuery' => 'DiffusionLowLevelQuery',
|
'DiffusionLowLevelResolveRefsQuery' => 'DiffusionLowLevelQuery',
|
||||||
|
|
|
@ -198,18 +198,16 @@ final class DiffusionBrowseQueryConduitAPIMethod
|
||||||
$commit = $request->getValue('commit');
|
$commit = $request->getValue('commit');
|
||||||
$result = $this->getEmptyResultSet();
|
$result = $this->getEmptyResultSet();
|
||||||
|
|
||||||
$match_against = trim($path, '/');
|
|
||||||
|
|
||||||
$prefix = trim('./'.$match_against, '/');
|
$entire_manifest = id(new DiffusionLowLevelMercurialPathsQuery())
|
||||||
|
->setRepository($repository)
|
||||||
list($entire_manifest) = $repository->execxLocalCommand(
|
->withCommit($commit)
|
||||||
'locate --print0 --rev %s -I %s',
|
->withPath($path)
|
||||||
hgsprintf('%s', $commit),
|
->execute();
|
||||||
$prefix);
|
|
||||||
$entire_manifest = explode("\0", $entire_manifest);
|
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
|
$match_against = trim($path, '/');
|
||||||
$match_len = strlen($match_against);
|
$match_len = strlen($match_against);
|
||||||
|
|
||||||
// For the root, don't trim. For other paths, trim the "/" after we match.
|
// 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');
|
$path = $request->getValue('path');
|
||||||
$commit = $request->getValue('commit');
|
$commit = $request->getValue('commit');
|
||||||
|
|
||||||
// Adapted from diffusion.browsequery.
|
$entire_manifest = id(new DiffusionLowLevelMercurialPathsQuery())
|
||||||
list($entire_manifest) = $repository->execxLocalCommand(
|
->setRepository($repository)
|
||||||
'manifest --rev %s',
|
->withCommit($commit)
|
||||||
hgsprintf('%s', $commit));
|
->withPath($path)
|
||||||
$entire_manifest = explode("\n", $entire_manifest);
|
->execute();
|
||||||
|
|
||||||
$match_against = trim($path, '/');
|
$match_against = trim($path, '/');
|
||||||
$match_len = strlen($match_against);
|
$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