mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-09 14:21:02 +01:00
Speed up diffusion_browsequery for mercurial repositories
Summary: Ref T4387. By using `hg locate` to attempt to only list files in the given path browsing diffusion is a bit faster. In a repo of about 600M it shaves a rough 100ms off viewing the root of the project. Test Plan: Looked around in diffusion and saw it showed everything including .files, which was nice Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T4387 Differential Revision: https://secure.phabricator.com/D8163
This commit is contained in:
parent
df98ea3ba9
commit
5771d13952
1 changed files with 7 additions and 14 deletions
|
@ -197,25 +197,18 @@ final class ConduitAPI_diffusion_browsequery_Method
|
||||||
$commit = $request->getValue('commit');
|
$commit = $request->getValue('commit');
|
||||||
$result = $this->getEmptyResultSet();
|
$result = $this->getEmptyResultSet();
|
||||||
|
|
||||||
// TODO: This is a really really awful mess but Mercurial doesn't offer
|
$match_against = trim($path, '/');
|
||||||
// an equivalent of "git ls-files -- directory". If it's any comfort, this
|
|
||||||
// is what "hgweb" does too, see:
|
$prefix = trim('./'.$match_against, '/');
|
||||||
//
|
|
||||||
// http://selenic.com/repo/hg/file/91dc8878f888/mercurial/hgweb/webcommands.py#l320
|
|
||||||
//
|
|
||||||
// derp derp derp derp
|
|
||||||
//
|
|
||||||
// Anyway, figure out what's in this path by applying massive amounts
|
|
||||||
// of brute force.
|
|
||||||
|
|
||||||
list($entire_manifest) = $repository->execxLocalCommand(
|
list($entire_manifest) = $repository->execxLocalCommand(
|
||||||
'manifest --rev %s',
|
'locate --print0 --rev %s -I %s',
|
||||||
hgsprintf('%s', $commit));
|
hgsprintf('%s', $commit),
|
||||||
$entire_manifest = explode("\n", $entire_manifest);
|
$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.
|
||||||
|
|
Loading…
Reference in a new issue