Page MenuHomePhabricator

D7480.id16860.diff
No OneTemporary

D7480.id16860.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -493,6 +493,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',
@@ -2695,6 +2696,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

Mime Type
text/plain
Expires
Tue, Oct 22, 8:12 AM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6725486
Default Alt Text
D7480.id16860.diff (4 KB)

Event Timeline