Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14017491
D7480.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D7480.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -496,6 +496,7 @@
'DiffusionLintDetailsController' => 'applications/diffusion/controller/DiffusionLintDetailsController.php',
'DiffusionLintSaveRunner' => 'applications/diffusion/DiffusionLintSaveRunner.php',
'DiffusionLowLevelGitRefQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelGitRefQuery.php',
+ 'DiffusionLowLevelMercurialBranchesQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php',
'DiffusionLowLevelQuery' => 'applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php',
'DiffusionMercurialCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionMercurialCommitParentsQuery.php',
'DiffusionMercurialExpandShortNameQuery' => 'applications/diffusion/query/expandshortname/DiffusionMercurialExpandShortNameQuery.php',
@@ -2701,6 +2702,7 @@
'DiffusionLintController' => 'DiffusionController',
'DiffusionLintDetailsController' => 'DiffusionController',
'DiffusionLowLevelGitRefQuery' => 'DiffusionLowLevelQuery',
+ 'DiffusionLowLevelMercurialBranchesQuery' => 'DiffusionLowLevelQuery',
'DiffusionLowLevelQuery' => 'Phobject',
'DiffusionMercurialCommitParentsQuery' => 'DiffusionCommitParentsQuery',
'DiffusionMercurialExpandShortNameQuery' => 'DiffusionExpandShortNameQuery',
Index: src/applications/diffusion/conduit/ConduitAPI_diffusion_branchquery_Method.php
===================================================================
--- src/applications/diffusion/conduit/ConduitAPI_diffusion_branchquery_Method.php
+++ src/applications/diffusion/conduit/ConduitAPI_diffusion_branchquery_Method.php
@@ -65,17 +65,9 @@
$offset = $request->getValue('offset');
$limit = $request->getValue('limit');
- list($stdout) = $repository->execxLocalCommand(
- '--debug branches');
- $branch_info = ArcanistMercurialParser::parseMercurialBranches($stdout);
-
- $branches = array();
- foreach ($branch_info as $name => $info) {
- $branch = new DiffusionBranchInformation();
- $branch->setName($name);
- $branch->setHeadCommitIdentifier($info['rev']);
- $branches[] = $branch->toDictionary();
- }
+ $branches = id(new DiffusionLowLevelMercurialBranchesQuery())
+ ->setRepository($repository)
+ ->execute();
if ($offset) {
$branches = array_slice($branches, $offset);
@@ -85,6 +77,6 @@
$branches = array_slice($branches, 0, $limit);
}
- return $branches;
+ return mpull($branches, 'toDictionary');
}
}
Index: src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php
===================================================================
--- /dev/null
+++ src/applications/diffusion/query/lowlevel/DiffusionLowLevelMercurialBranchesQuery.php
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * Execute and parse a low-level Mercurial branches query using `hg branches`.
+ */
+final class DiffusionLowLevelMercurialBranchesQuery
+ extends DiffusionLowLevelQuery {
+
+ protected function executeQuery() {
+ $repository = $this->getRepository();
+
+ // NOTE: `--debug` gives us 40-character hashes.
+ list($stdout) = $repository->execxLocalCommand(
+ '--debug branches');
+
+ $branches = array();
+
+ $lines = ArcanistMercurialParser::parseMercurialBranches($stdout);
+ foreach ($lines as $name => $spec) {
+ $branches[] = id(new DiffusionBranchInformation())
+ ->setName($name)
+ ->setHeadCommitIdentifier($spec['rev']);
+ }
+
+ return $branches;
+ }
+
+}
Index: src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
===================================================================
--- src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
+++ src/applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php
@@ -743,15 +743,12 @@
private function executeHgDiscover(PhabricatorRepository $repository) {
- // NOTE: "--debug" gives us 40-character hashes.
- list($stdout) = $repository->execxLocalCommand('--debug branches');
- if (!trim($stdout)) {
- // No branches; likely a newly initialized repository.
- return false;
- }
+ $branches = id(new DiffusionLowLevelMercurialBranchesQuery())
+ ->setRepository($repository)
+ ->execute();
+ $branches = mpull($branches, 'getHeadCommitIdentifier', 'getName');
- $branches = ArcanistMercurialParser::parseMercurialBranches($stdout);
$got_something = false;
foreach ($branches as $name => $branch) {
$commit = $branch['rev'];
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 5, 5:48 PM (2 w, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6723997
Default Alt Text
D7480.diff (4 KB)
Attached To
Mode
D7480: Clean up `hg --debug branches` calls
Attached
Detach File
Event Timeline
Log In to Comment