Page MenuHomePhabricator

D10380.id24986.diff
No OneTemporary

D10380.id24986.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -425,6 +425,7 @@
'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 @@
'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
--- a/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php
+++ b/src/applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php
@@ -198,18 +198,16 @@
$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
--- a/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php
+++ b/src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php
@@ -55,11 +55,11 @@
$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
--- /dev/null
+++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialPathsQuery.php
@@ -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);
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 29, 2:30 AM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7386782
Default Alt Text
D10380.id24986.diff (4 KB)

Event Timeline