diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 3c4b3d25a7..c0ce4d8ee1 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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', diff --git a/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php index d4a5c70abb..ab20f13d02 100644 --- a/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php +++ b/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php @@ -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. diff --git a/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php index 757c5116b5..c25d71aeb4 100644 --- a/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php +++ b/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php @@ -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); diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php new file mode 100644 index 0000000000..aca82df79f --- /dev/null +++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php @@ -0,0 +1,36 @@ +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); + } + +}