diff --git a/src/applications/diffusion/query/DiffusionCachedResolveRefsQuery.php b/src/applications/diffusion/query/DiffusionCachedResolveRefsQuery.php --- a/src/applications/diffusion/query/DiffusionCachedResolveRefsQuery.php +++ b/src/applications/diffusion/query/DiffusionCachedResolveRefsQuery.php @@ -96,7 +96,7 @@ $cursors = queryfx_all( $conn_r, - 'SELECT refNameHash, refType, commitIdentifier FROM %T + 'SELECT refNameHash, refType, commitIdentifier, isClosed FROM %T WHERE repositoryPHID = %s AND refNameHash IN (%Ls)', id(new PhabricatorRepositoryRefCursor())->getTableName(), $repository->getPHID(), @@ -107,6 +107,7 @@ $results[$name_hashes[$cursor['refNameHash']]][] = array( 'type' => $cursor['refType'], 'identifier' => $cursor['commitIdentifier'], + 'closed' => (bool)$cursor['isClosed'], ); // TODO: In Git, we don't store (and thus don't return) the hash diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php --- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php +++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php @@ -143,54 +143,32 @@ // First, pull all of the branch heads in the repository. Doing this in // bulk is much faster than querying each individual head if we're // checking even a small number of refs. - $futures = array(); - $futures['all'] = $repository->getLocalCommandFuture( - 'log --template=%s --rev %s', - '{node} {branch}\\n', - hgsprintf('head()')); - $futures['open'] = $repository->getLocalCommandFuture( - 'log --template=%s --rev %s', - '{node} {branch}\\n', - hgsprintf('head() and not closed()')); - - - $map = array(); - foreach (new FutureIterator($futures) as $key => $future) { - list($stdout) = $future->resolvex(); - $lines = phutil_split_lines($stdout, $retain_endings = false); - foreach ($lines as $idx => $line) { - list($node, $branch) = explode(' ', $line, 2); - $map[$branch]['nodes'][] = $node; - if ($key == 'open') { - $map[$branch]['open'] = true; - } - } - } + $branches = id(new DiffusionLowLevelMercurialBranchesQuery()) + ->setRepository($repository) + ->executeQuery(); + + $branches = mgroup($branches, 'getShortName'); $results = array(); $unresolved = $this->refs; foreach ($unresolved as $key => $ref) { - if (!isset($map[$ref])) { + if (empty($branches[$ref])) { continue; } - $is_closed = !idx($map[$ref], 'open', false); - foreach ($map[$ref]['nodes'] as $node) { - $results[$ref][$node] = array( + foreach ($branches[$ref] as $branch) { + $fields = $branch->getRawFields(); + + $results[$ref][] = array( 'type' => 'branch', - 'identifier' => $node, - 'closed' => $is_closed, + 'identifier' => $branch->getCommitIdentifier(), + 'closed' => idx($fields, 'closed', false), ); } unset($unresolved[$key]); } - // Strip the node keys off the result list. - foreach ($results as $ref => $result_list) { - $results[$ref] = array_values($result_list); - } - if (!$unresolved) { return $results; }