Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14035265
D18717.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D18717.diff
View Options
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
@@ -256,6 +256,66 @@
return $results;
}
+ // If some of the refs look like hashes, try to bulk resolve them. This
+ // workflow happens via RefEngine and bulk resolution is dramatically
+ // faster than individual resolution. See PHI158.
+
+ $hashlike = array();
+ foreach ($unresolved as $key => $ref) {
+ if (preg_match('/^[a-f0-9]{40}\z/', $ref)) {
+ $hashlike[$key] = $ref;
+ }
+ }
+
+ if (count($hashlike) > 1) {
+ $hashlike_map = array();
+
+ $hashlike_groups = array_chunk($hashlike, 64, true);
+ foreach ($hashlike_groups as $hashlike_group) {
+ $hashlike_arg = array();
+ foreach ($hashlike_group as $hashlike_ref) {
+ $hashlike_arg[] = hgsprintf('%s', $hashlike_ref);
+ }
+ $hashlike_arg = '('.implode(' or ', $hashlike_arg).')';
+
+ list($err, $refs) = $repository->execLocalCommand(
+ 'log --template=%s --rev %s',
+ '{node}\n',
+ $hashlike_arg);
+ if ($err) {
+ // NOTE: If any ref fails to resolve, Mercurial will exit with an
+ // error. We just give up on the whole group and resolve it
+ // individually below. In theory, we could split it into subgroups
+ // but the pathway where this bulk resolution matters rarely tries
+ // to resolve missing refs (see PHI158).
+ continue;
+ }
+
+ $refs = phutil_split_lines($refs, false);
+
+ foreach ($refs as $ref) {
+ $hashlike_map[$ref] = true;
+ }
+ }
+
+ foreach ($unresolved as $key => $ref) {
+ if (!isset($hashlike_map[$ref])) {
+ continue;
+ }
+
+ $results[$ref][] = array(
+ 'type' => 'commit',
+ 'identifier' => $ref,
+ );
+
+ unset($unresolved[$key]);
+ }
+ }
+
+ if (!$unresolved) {
+ return $results;
+ }
+
// If we still have unresolved refs (which might be things like "tip"),
// try to resolve them individually.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 11, 5:13 AM (5 d, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6714337
Default Alt Text
D18717.diff (2 KB)
Attached To
Mode
D18717: Improve "refengine" performance for testing large numbers of Mercurial branches
Attached
Detach File
Event Timeline
Log In to Comment