@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Simplify Mercurial ref resolution; expose "closed" at top-level

Summary: Ref T7100. Ref T6160. Share branch code. Surface "closed".

Test Plan: Browsed a mercurial repository and saw consistent ref/cache state.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T6160, T7100

Differential Revision: https://secure.phabricator.com/D12551

+13 -34
+2 -1
src/applications/diffusion/query/DiffusionCachedResolveRefsQuery.php
··· 96 96 97 97 $cursors = queryfx_all( 98 98 $conn_r, 99 - 'SELECT refNameHash, refType, commitIdentifier FROM %T 99 + 'SELECT refNameHash, refType, commitIdentifier, isClosed FROM %T 100 100 WHERE repositoryPHID = %s AND refNameHash IN (%Ls)', 101 101 id(new PhabricatorRepositoryRefCursor())->getTableName(), 102 102 $repository->getPHID(), ··· 107 107 $results[$name_hashes[$cursor['refNameHash']]][] = array( 108 108 'type' => $cursor['refType'], 109 109 'identifier' => $cursor['commitIdentifier'], 110 + 'closed' => (bool)$cursor['isClosed'], 110 111 ); 111 112 112 113 // TODO: In Git, we don't store (and thus don't return) the hash
+11 -33
src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php
··· 143 143 // First, pull all of the branch heads in the repository. Doing this in 144 144 // bulk is much faster than querying each individual head if we're 145 145 // checking even a small number of refs. 146 - $futures = array(); 147 - $futures['all'] = $repository->getLocalCommandFuture( 148 - 'log --template=%s --rev %s', 149 - '{node} {branch}\\n', 150 - hgsprintf('head()')); 151 - $futures['open'] = $repository->getLocalCommandFuture( 152 - 'log --template=%s --rev %s', 153 - '{node} {branch}\\n', 154 - hgsprintf('head() and not closed()')); 155 - 146 + $branches = id(new DiffusionLowLevelMercurialBranchesQuery()) 147 + ->setRepository($repository) 148 + ->executeQuery(); 156 149 157 - $map = array(); 158 - foreach (new FutureIterator($futures) as $key => $future) { 159 - list($stdout) = $future->resolvex(); 160 - $lines = phutil_split_lines($stdout, $retain_endings = false); 161 - foreach ($lines as $idx => $line) { 162 - list($node, $branch) = explode(' ', $line, 2); 163 - $map[$branch]['nodes'][] = $node; 164 - if ($key == 'open') { 165 - $map[$branch]['open'] = true; 166 - } 167 - } 168 - } 150 + $branches = mgroup($branches, 'getShortName'); 169 151 170 152 $results = array(); 171 153 $unresolved = $this->refs; 172 154 foreach ($unresolved as $key => $ref) { 173 - if (!isset($map[$ref])) { 155 + if (empty($branches[$ref])) { 174 156 continue; 175 157 } 176 158 177 - $is_closed = !idx($map[$ref], 'open', false); 178 - foreach ($map[$ref]['nodes'] as $node) { 179 - $results[$ref][$node] = array( 159 + foreach ($branches[$ref] as $branch) { 160 + $fields = $branch->getRawFields(); 161 + 162 + $results[$ref][] = array( 180 163 'type' => 'branch', 181 - 'identifier' => $node, 182 - 'closed' => $is_closed, 164 + 'identifier' => $branch->getCommitIdentifier(), 165 + 'closed' => idx($fields, 'closed', false), 183 166 ); 184 167 } 185 168 186 169 unset($unresolved[$key]); 187 - } 188 - 189 - // Strip the node keys off the result list. 190 - foreach ($results as $ref => $result_list) { 191 - $results[$ref] = array_values($result_list); 192 170 } 193 171 194 172 if (!$unresolved) {