@ref0/git 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE +202 -0
- package/dist/access/private-refs.d.mts +27 -0
- package/dist/access/private-refs.mjs +173 -0
- package/dist/access.d.mts +2 -0
- package/dist/access.mjs +1 -0
- package/dist/auth/access-jwt.d.mts +21 -0
- package/dist/auth/access-jwt.mjs +102 -0
- package/dist/auth/acting.mjs +15 -0
- package/dist/auth/authorize.d.mts +5 -0
- package/dist/auth/authorize.mjs +292 -0
- package/dist/auth/credentials.mjs +57 -0
- package/dist/auth/fences.d.mts +5 -0
- package/dist/auth/fences.mjs +65 -0
- package/dist/auth/grants.mjs +61 -0
- package/dist/auth/helpers.d.mts +17 -0
- package/dist/auth/helpers.mjs +25 -0
- package/dist/auth/host-function.d.mts +4 -0
- package/dist/auth/host-function.mjs +69 -0
- package/dist/auth/identify.d.mts +6 -0
- package/dist/auth/identify.mjs +97 -0
- package/dist/auth/token-rows.mjs +100 -0
- package/dist/auth/token-text.mjs +66 -0
- package/dist/auth/tokens.d.mts +10 -0
- package/dist/auth/tokens.mjs +347 -0
- package/dist/auth.d.mts +7 -0
- package/dist/auth.mjs +6 -0
- package/dist/client/answer.mjs +141 -0
- package/dist/client/client.d.mts +23 -0
- package/dist/client/client.mjs +51 -0
- package/dist/client/git-http.mjs +201 -0
- package/dist/client/helper-node.mjs +19 -0
- package/dist/client/local.mjs +160 -0
- package/dist/client/negotiate.mjs +170 -0
- package/dist/client/push-upload.mjs +53 -0
- package/dist/client/remote-helper.mjs +129 -0
- package/dist/client/remote.mjs +398 -0
- package/dist/client/run-remote-helper.d.mts +35 -0
- package/dist/client/run-remote-helper.mjs +259 -0
- package/dist/client/scrub.d.mts +18 -0
- package/dist/client/scrub.mjs +38 -0
- package/dist/client/transport.d.mts +2 -0
- package/dist/client/transport.mjs +211 -0
- package/dist/contracts/access.d.mts +87 -0
- package/dist/contracts/actors.d.mts +144 -0
- package/dist/contracts/blobs.d.mts +38 -0
- package/dist/contracts/calls-spent.d.mts +11 -0
- package/dist/contracts/calls-spent.mjs +150 -0
- package/dist/contracts/client.d.mts +90 -0
- package/dist/contracts/commits.d.mts +126 -0
- package/dist/contracts/engine.d.mts +134 -0
- package/dist/contracts/events.d.mts +276 -0
- package/dist/contracts/files.d.mts +75 -0
- package/dist/contracts/forks.d.mts +78 -0
- package/dist/contracts/grants.d.mts +60 -0
- package/dist/contracts/handlers.d.mts +10 -0
- package/dist/contracts/ids.d.mts +15 -0
- package/dist/contracts/ids.mjs +15 -0
- package/dist/contracts/lfs.d.mts +27 -0
- package/dist/contracts/merges.d.mts +33 -0
- package/dist/contracts/objects.d.mts +645 -0
- package/dist/contracts/objects.mjs +54 -0
- package/dist/contracts/operations.d.mts +133 -0
- package/dist/contracts/promises.d.mts +63 -0
- package/dist/contracts/push-uploads.d.mts +44 -0
- package/dist/contracts/queue.d.mts +401 -0
- package/dist/contracts/refs.d.mts +95 -0
- package/dist/contracts/remote.d.mts +50 -0
- package/dist/contracts/repos.d.mts +153 -0
- package/dist/contracts/result.d.mts +126 -0
- package/dist/contracts/result.mjs +34 -0
- package/dist/contracts/rules.d.mts +159 -0
- package/dist/contracts/server.d.mts +245 -0
- package/dist/contracts/services.d.mts +36 -0
- package/dist/contracts/services.mjs +13 -0
- package/dist/contracts/signin.d.mts +126 -0
- package/dist/contracts/store.d.mts +41 -0
- package/dist/contracts/sync.d.mts +210 -0
- package/dist/contracts/sync.mjs +8 -0
- package/dist/contracts/tags.d.mts +50 -0
- package/dist/contracts/tags.mjs +6 -0
- package/dist/contracts/tokens.d.mts +87 -0
- package/dist/contracts/tokens.mjs +15 -0
- package/dist/contracts/topics.d.mts +174 -0
- package/dist/contracts/trees.d.mts +84 -0
- package/dist/contracts/work.d.mts +31 -0
- package/dist/core/access.d.mts +22 -0
- package/dist/core/access.mjs +262 -0
- package/dist/core/ancestry.mjs +235 -0
- package/dist/core/clock.mjs +18 -0
- package/dist/core/events/deliver.mjs +468 -0
- package/dist/core/events/stream.d.mts +19 -0
- package/dist/core/events/stream.mjs +290 -0
- package/dist/core/forks.mjs +1027 -0
- package/dist/core/hooks/post-receive.mjs +204 -0
- package/dist/core/hooks/pre-receive.d.mts +5 -0
- package/dist/core/hooks/pre-receive.mjs +34 -0
- package/dist/core/index-job.mjs +198 -0
- package/dist/core/names.mjs +30 -0
- package/dist/core/objects/blobs.mjs +60 -0
- package/dist/core/objects/commit-writes.mjs +185 -0
- package/dist/core/objects/commits.mjs +172 -0
- package/dist/core/objects/files.mjs +211 -0
- package/dist/core/objects/lines.mjs +42 -0
- package/dist/core/objects/merges.mjs +83 -0
- package/dist/core/objects/peel.mjs +166 -0
- package/dist/core/objects/reading.mjs +284 -0
- package/dist/core/objects/tags.mjs +96 -0
- package/dist/core/objects/tree-edits.mjs +266 -0
- package/dist/core/objects/trees.mjs +229 -0
- package/dist/core/objects/writing.mjs +266 -0
- package/dist/core/own-writes.mjs +94 -0
- package/dist/core/promise.mjs +46 -0
- package/dist/core/publish.mjs +142 -0
- package/dist/core/push-decide.mjs +206 -0
- package/dist/core/push.mjs +1069 -0
- package/dist/core/receipts.d.mts +7 -0
- package/dist/core/receipts.mjs +234 -0
- package/dist/core/ref-conflicts.mjs +27 -0
- package/dist/core/refs.mjs +359 -0
- package/dist/core/repack.mjs +521 -0
- package/dist/core/repos.mjs +752 -0
- package/dist/core/rules/changes.mjs +57 -0
- package/dist/core/rules/check.mjs +101 -0
- package/dist/core/rules/commit-changes.mjs +216 -0
- package/dist/core/rules/context.d.mts +9 -0
- package/dist/core/rules/context.mjs +120 -0
- package/dist/core/rules/define.d.mts +5 -0
- package/dist/core/rules/define.mjs +13 -0
- package/dist/core/rules/facts.mjs +13 -0
- package/dist/core/rules/fetch.d.mts +5 -0
- package/dist/core/rules/fetch.mjs +59 -0
- package/dist/core/rules/file-globs.mjs +55 -0
- package/dist/core/rules/files.mjs +142 -0
- package/dist/core/rules/patterns.mjs +23 -0
- package/dist/core/rules/protect.d.mts +9 -0
- package/dist/core/rules/protect.mjs +116 -0
- package/dist/core/seam.d.mts +24 -0
- package/dist/core/seam.mjs +41 -0
- package/dist/core/sight.mjs +99 -0
- package/dist/core/tokens.mjs +95 -0
- package/dist/core/view.d.mts +9 -0
- package/dist/core/view.mjs +221 -0
- package/dist/core/work.mjs +92 -0
- package/dist/effect.d.mts +20 -0
- package/dist/effect.mjs +18 -0
- package/dist/engine/allotted-xdiff.d.mts +4 -0
- package/dist/engine/allotted-xdiff.mjs +80 -0
- package/dist/engine/attribute-patterns.mjs +163 -0
- package/dist/engine/attributes.mjs +226 -0
- package/dist/engine/combined.mjs +653 -0
- package/dist/engine/commits.mjs +90 -0
- package/dist/engine/content.d.mts +4 -0
- package/dist/engine/content.mjs +221 -0
- package/dist/engine/diff.mjs +49 -0
- package/dist/engine/engine.d.mts +25 -0
- package/dist/engine/engine.mjs +49 -0
- package/dist/engine/failures.d.mts +4 -0
- package/dist/engine/failures.mjs +23 -0
- package/dist/engine/line-count.mjs +23 -0
- package/dist/engine/merge-base-walk.d.mts +2 -0
- package/dist/engine/merge-base-walk.mjs +265 -0
- package/dist/engine/merge-bases.mjs +27 -0
- package/dist/engine/merge-renames.mjs +165 -0
- package/dist/engine/merge.mjs +1125 -0
- package/dist/engine/parts.d.mts +8 -0
- package/dist/engine/parts.mjs +9 -0
- package/dist/engine/reads.d.mts +5 -0
- package/dist/engine/reads.mjs +105 -0
- package/dist/engine/walk.mjs +328 -0
- package/dist/engine/xdiff/NOTICE.md +63 -0
- package/dist/engine/xdiff/compiled.d.mts +7 -0
- package/dist/engine/xdiff/compiled.mjs +9 -0
- package/dist/engine/xdiff/embedded.mjs +4 -0
- package/dist/engine/xdiff/node.d.mts +7 -0
- package/dist/engine/xdiff/node.mjs +10 -0
- package/dist/engine/xdiff/upstream/LGPL-2.1 +511 -0
- package/dist/engine/xdiff/xdiff.wasm +0 -0
- package/dist/engine/xdiff.d.mts +34 -0
- package/dist/engine/xdiff.mjs +380 -0
- package/dist/engine.d.mts +3 -0
- package/dist/engine.mjs +3 -0
- package/dist/extend.d.mts +3 -0
- package/dist/extend.mjs +1 -0
- package/dist/http/answers.mjs +74 -0
- package/dist/http/bodies.mjs +143 -0
- package/dist/http/core-parts.mjs +252 -0
- package/dist/http/fetch-depth.mjs +26 -0
- package/dist/http/handler.mjs +94 -0
- package/dist/http/node.d.mts +70 -0
- package/dist/http/node.mjs +178 -0
- package/dist/http/paths.d.mts +9 -0
- package/dist/http/paths.mjs +118 -0
- package/dist/http/push-uploads.mjs +286 -0
- package/dist/http/receive-pack.mjs +235 -0
- package/dist/http/upload-pack.mjs +229 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.mjs +16 -0
- package/dist/lfs/calls.mjs +16 -0
- package/dist/lfs/locks.mjs +161 -0
- package/dist/lfs/objects.mjs +370 -0
- package/dist/lfs/pointers.mjs +141 -0
- package/dist/lfs/repo.mjs +42 -0
- package/dist/lfs/rows.mjs +108 -0
- package/dist/lfs/service.mjs +34 -0
- package/dist/lfs/upkeep.mjs +162 -0
- package/dist/lfs/wire.mjs +102 -0
- package/dist/node.d.mts +3 -0
- package/dist/node.mjs +3 -0
- package/dist/protocol/bytes/buffers.d.mts +38 -0
- package/dist/protocol/bytes/buffers.mjs +62 -0
- package/dist/protocol/bytes/crc32.d.mts +4 -0
- package/dist/protocol/bytes/crc32.mjs +14 -0
- package/dist/protocol/bytes/deflate.d.mts +78 -0
- package/dist/protocol/bytes/deflate.mjs +175 -0
- package/dist/protocol/bytes/errors.d.mts +20 -0
- package/dist/protocol/bytes/errors.mjs +19 -0
- package/dist/protocol/bytes/hex.mjs +16 -0
- package/dist/protocol/bytes/hmac-sha256.mjs +91 -0
- package/dist/protocol/bytes/inflate.d.mts +40 -0
- package/dist/protocol/bytes/inflate.mjs +109 -0
- package/dist/protocol/bytes/joined.d.mts +2 -0
- package/dist/protocol/bytes/joined.mjs +25 -0
- package/dist/protocol/bytes/sha1-hasher.d.mts +20 -0
- package/dist/protocol/bytes/sha1-hasher.mjs +72 -0
- package/dist/protocol/bytes/sha1.d.mts +35 -0
- package/dist/protocol/bytes/sha1.mjs +409 -0
- package/dist/protocol/bytes/sha256.mjs +156 -0
- package/dist/protocol/bytes/streams.mjs +11 -0
- package/dist/protocol/bytes/text.mjs +19 -0
- package/dist/protocol/diff/diff-raw.d.mts +29 -0
- package/dist/protocol/diff/diff-raw.mjs +73 -0
- package/dist/protocol/diff/patch.mjs +92 -0
- package/dist/protocol/diff/paths.mjs +67 -0
- package/dist/protocol/diff/read.d.mts +62 -0
- package/dist/protocol/diff/read.mjs +342 -0
- package/dist/protocol/diff/rename-similarity.mjs +428 -0
- package/dist/protocol/diff/text.mjs +12 -0
- package/dist/protocol/diff/tree-diff.d.mts +41 -0
- package/dist/protocol/diff/tree-diff.mjs +607 -0
- package/dist/protocol/framing/band.d.mts +10 -0
- package/dist/protocol/framing/band.mjs +16 -0
- package/dist/protocol/framing/pkt-line.d.mts +48 -0
- package/dist/protocol/framing/pkt-line.mjs +92 -0
- package/dist/protocol/objects/checked-blobs.mjs +127 -0
- package/dist/protocol/objects/commit.d.mts +25 -0
- package/dist/protocol/objects/commit.mjs +138 -0
- package/dist/protocol/objects/fsck-gitmodules.mjs +296 -0
- package/dist/protocol/objects/fsck-names.mjs +189 -0
- package/dist/protocol/objects/fsck.mjs +297 -0
- package/dist/protocol/objects/headers.mjs +109 -0
- package/dist/protocol/objects/held.mjs +56 -0
- package/dist/protocol/objects/iconv.mjs +145 -0
- package/dist/protocol/objects/ident.mjs +111 -0
- package/dist/protocol/objects/lfs-pointer.d.mts +8 -0
- package/dist/protocol/objects/lfs-pointer.mjs +63 -0
- package/dist/protocol/objects/links-raw.mjs +89 -0
- package/dist/protocol/objects/object-rules.mjs +75 -0
- package/dist/protocol/objects/object.d.mts +16 -0
- package/dist/protocol/objects/object.mjs +29 -0
- package/dist/protocol/objects/tag.d.mts +21 -0
- package/dist/protocol/objects/tag.mjs +96 -0
- package/dist/protocol/objects/tree.d.mts +43 -0
- package/dist/protocol/objects/tree.mjs +162 -0
- package/dist/protocol/objects/utf8-verify.mjs +71 -0
- package/dist/protocol/packs/delta.d.mts +57 -0
- package/dist/protocol/packs/delta.mjs +229 -0
- package/dist/protocol/packs/graph.mjs +78 -0
- package/dist/protocol/packs/idx.d.mts +54 -0
- package/dist/protocol/packs/idx.mjs +274 -0
- package/dist/protocol/packs/indexer.d.mts +167 -0
- package/dist/protocol/packs/indexer.mjs +507 -0
- package/dist/protocol/packs/parts.d.mts +40 -0
- package/dist/protocol/packs/parts.mjs +89 -0
- package/dist/protocol/packs/pos.mjs +51 -0
- package/dist/protocol/packs/reader.d.mts +180 -0
- package/dist/protocol/packs/reader.mjs +414 -0
- package/dist/protocol/packs/rev.d.mts +32 -0
- package/dist/protocol/packs/rev.mjs +99 -0
- package/dist/protocol/packs/step.d.mts +10 -0
- package/dist/protocol/packs/step.mjs +12 -0
- package/dist/protocol/packs/write-error.d.mts +12 -0
- package/dist/protocol/packs/write-error.mjs +27 -0
- package/dist/protocol/packs/writer.d.mts +157 -0
- package/dist/protocol/packs/writer.mjs +353 -0
- package/dist/protocol/wire/advertisement.d.mts +72 -0
- package/dist/protocol/wire/advertisement.mjs +161 -0
- package/dist/protocol/wire/fetch.d.mts +155 -0
- package/dist/protocol/wire/fetch.mjs +458 -0
- package/dist/protocol/wire/lines.mjs +107 -0
- package/dist/protocol/wire/push-uploads.mjs +43 -0
- package/dist/protocol/wire/receive-pack.d.mts +71 -0
- package/dist/protocol/wire/receive-pack.mjs +157 -0
- package/dist/protocol/wire/report-status.d.mts +47 -0
- package/dist/protocol/wire/report-status.mjs +119 -0
- package/dist/protocol/wire/v2.d.mts +90 -0
- package/dist/protocol/wire/v2.mjs +185 -0
- package/dist/protocol.d.mts +31 -0
- package/dist/protocol.mjs +31 -0
- package/dist/queue/advance.mjs +1036 -0
- package/dist/queue/callers.mjs +134 -0
- package/dist/queue/calls.mjs +1154 -0
- package/dist/queue/commit.mjs +85 -0
- package/dist/queue/host.d.mts +15 -0
- package/dist/queue/host.mjs +88 -0
- package/dist/queue/ids.d.mts +5 -0
- package/dist/queue/ids.mjs +21 -0
- package/dist/queue/lanes.mjs +86 -0
- package/dist/queue/limits.mjs +99 -0
- package/dist/queue/pages.mjs +76 -0
- package/dist/queue/push-option.mjs +62 -0
- package/dist/queue/rows.mjs +206 -0
- package/dist/queue/schedule.mjs +132 -0
- package/dist/queue/search.mjs +315 -0
- package/dist/queue/state.mjs +325 -0
- package/dist/queue/steps.mjs +317 -0
- package/dist/remote-helper.d.mts +3 -0
- package/dist/remote-helper.mjs +3 -0
- package/dist/rest/api.d.mts +23 -0
- package/dist/rest/api.mjs +27 -0
- package/dist/rest/blobs.d.mts +58 -0
- package/dist/rest/blobs.mjs +41 -0
- package/dist/rest/caller.d.mts +102 -0
- package/dist/rest/caller.mjs +18 -0
- package/dist/rest/client.d.mts +18 -0
- package/dist/rest/client.mjs +587 -0
- package/dist/rest/commits.d.mts +435 -0
- package/dist/rest/commits.mjs +140 -0
- package/dist/rest/errors.d.mts +44 -0
- package/dist/rest/errors.mjs +186 -0
- package/dist/rest/events.d.mts +38 -0
- package/dist/rest/events.mjs +74 -0
- package/dist/rest/files.d.mts +179 -0
- package/dist/rest/files.mjs +92 -0
- package/dist/rest/forks.d.mts +205 -0
- package/dist/rest/forks.mjs +51 -0
- package/dist/rest/handler.d.mts +17 -0
- package/dist/rest/handler.mjs +106 -0
- package/dist/rest/handlers.d.mts +8 -0
- package/dist/rest/handlers.mjs +592 -0
- package/dist/rest/listen.d.mts +24 -0
- package/dist/rest/listen.mjs +142 -0
- package/dist/rest/me.d.mts +55 -0
- package/dist/rest/me.mjs +21 -0
- package/dist/rest/merges.d.mts +90 -0
- package/dist/rest/merges.mjs +39 -0
- package/dist/rest/paths.mjs +86 -0
- package/dist/rest/queue.d.mts +486 -0
- package/dist/rest/queue.mjs +228 -0
- package/dist/rest/refs.d.mts +232 -0
- package/dist/rest/refs.mjs +86 -0
- package/dist/rest/repos.d.mts +223 -0
- package/dist/rest/repos.mjs +93 -0
- package/dist/rest/tags.d.mts +153 -0
- package/dist/rest/tags.mjs +72 -0
- package/dist/rest/tokens.d.mts +297 -0
- package/dist/rest/tokens.mjs +88 -0
- package/dist/rest/topics.d.mts +257 -0
- package/dist/rest/topics.mjs +116 -0
- package/dist/rest/trees.d.mts +158 -0
- package/dist/rest/trees.mjs +118 -0
- package/dist/rest/wire.mjs +57 -0
- package/dist/rest/work.d.mts +107 -0
- package/dist/rest/work.mjs +77 -0
- package/dist/rest.d.mts +8 -0
- package/dist/rest.mjs +5 -0
- package/dist/server/extension.d.mts +14 -0
- package/dist/server/extension.mjs +85 -0
- package/dist/server/routes.d.mts +25 -0
- package/dist/server/routes.mjs +67 -0
- package/dist/server/server.d.mts +2 -0
- package/dist/server/server.mjs +439 -0
- package/dist/signin/codes.mjs +47 -0
- package/dist/signin/context.d.mts +9 -0
- package/dist/signin/context.mjs +121 -0
- package/dist/signin/device.mjs +122 -0
- package/dist/signin/forms.mjs +157 -0
- package/dist/signin/grants.d.mts +5 -0
- package/dist/signin/grants.mjs +257 -0
- package/dist/signin/route.mjs +68 -0
- package/dist/signin/web.mjs +125 -0
- package/dist/signin/wire.d.mts +42 -0
- package/dist/signin/wire.mjs +43 -0
- package/dist/storage/allotted.mjs +102 -0
- package/dist/storage/budget.mjs +96 -0
- package/dist/storage/calls.d.mts +18 -0
- package/dist/storage/calls.mjs +273 -0
- package/dist/storage/clean-up.mjs +124 -0
- package/dist/storage/distinct-ids.mjs +39 -0
- package/dist/storage/ewah.mjs +97 -0
- package/dist/storage/fetch.d.mts +13 -0
- package/dist/storage/fetch.mjs +792 -0
- package/dist/storage/fsck.mjs +77 -0
- package/dist/storage/held-memo.mjs +188 -0
- package/dist/storage/index-bitmaps.d.mts +4 -0
- package/dist/storage/index-bitmaps.mjs +654 -0
- package/dist/storage/index-build.d.mts +15 -0
- package/dist/storage/index-build.mjs +1433 -0
- package/dist/storage/index-fetch.d.mts +9 -0
- package/dist/storage/index-fetch.mjs +756 -0
- package/dist/storage/index-files.mjs +232 -0
- package/dist/storage/index-graph.d.mts +3 -0
- package/dist/storage/index-graph.mjs +1049 -0
- package/dist/storage/index-layers.mjs +317 -0
- package/dist/storage/index-reach.mjs +216 -0
- package/dist/storage/index-remap.d.mts +8 -0
- package/dist/storage/index-remap.mjs +592 -0
- package/dist/storage/layout.mjs +69 -0
- package/dist/storage/lfs-pointers.d.mts +21 -0
- package/dist/storage/lfs-pointers.mjs +175 -0
- package/dist/storage/link-join.mjs +106 -0
- package/dist/storage/links.mjs +105 -0
- package/dist/storage/loose.d.mts +15 -0
- package/dist/storage/loose.mjs +120 -0
- package/dist/storage/memory-budget.d.mts +8 -0
- package/dist/storage/memory-budget.mjs +546 -0
- package/dist/storage/merge.mjs +416 -0
- package/dist/storage/object-rows.d.mts +6 -0
- package/dist/storage/object-rows.mjs +211 -0
- package/dist/storage/pack-order.d.mts +8 -0
- package/dist/storage/pack-order.mjs +779 -0
- package/dist/storage/pack-ranges.d.mts +5 -0
- package/dist/storage/pack-ranges.mjs +284 -0
- package/dist/storage/pack-reads.d.mts +11 -0
- package/dist/storage/pack-reads.mjs +990 -0
- package/dist/storage/pack-receive.d.mts +11 -0
- package/dist/storage/pack-receive.mjs +449 -0
- package/dist/storage/packs.d.mts +56 -0
- package/dist/storage/packs.mjs +600 -0
- package/dist/storage/prune.mjs +506 -0
- package/dist/storage/push-allotment.mjs +109 -0
- package/dist/storage/push-uploads.mjs +151 -0
- package/dist/storage/pushed-commits.mjs +136 -0
- package/dist/storage/quarantine.mjs +98 -0
- package/dist/storage/raw-ids.mjs +44 -0
- package/dist/storage/ready.d.mts +19 -0
- package/dist/storage/ready.mjs +328 -0
- package/dist/storage/receive-links.mjs +297 -0
- package/dist/storage/repack-job.mjs +48 -0
- package/dist/storage/repack.d.mts +31 -0
- package/dist/storage/repack.mjs +182 -0
- package/dist/storage/roots.mjs +42 -0
- package/dist/storage/rows.d.mts +3 -0
- package/dist/storage/rows.mjs +71 -0
- package/dist/storage/shallow.d.mts +5 -0
- package/dist/storage/shallow.mjs +128 -0
- package/dist/storage/stream-whole.mjs +236 -0
- package/dist/storage/unpack.mjs +236 -0
- package/dist/storage/visible.mjs +137 -0
- package/dist/storage/walk.d.mts +7 -0
- package/dist/storage/walk.mjs +170 -0
- package/dist/storage/wants.mjs +362 -0
- package/dist/store/call-count.d.mts +47 -0
- package/dist/store/call-count.mjs +207 -0
- package/dist/store/catalogue.d.mts +7 -0
- package/dist/store/catalogue.mjs +643 -0
- package/dist/store/crossing.mjs +66 -0
- package/dist/store/cursor-seal.d.mts +2 -0
- package/dist/store/cursor-seal.mjs +85 -0
- package/dist/store/errors.d.mts +12 -0
- package/dist/store/errors.mjs +129 -0
- package/dist/store/git-store.mjs +75 -0
- package/dist/store/list-job.mjs +35 -0
- package/dist/store/outbox.d.mts +7 -0
- package/dist/store/outbox.mjs +295 -0
- package/dist/store/queue-jobs.mjs +43 -0
- package/dist/store/random.mjs +28 -0
- package/dist/store/records.d.mts +4 -0
- package/dist/store/records.mjs +192 -0
- package/dist/store/ref-rows.d.mts +4 -0
- package/dist/store/ref-rows.mjs +30 -0
- package/dist/store/repo-record.mjs +100 -0
- package/dist/store/reservations.mjs +82 -0
- package/dist/store/scopes.mjs +170 -0
- package/dist/store/settle.mjs +63 -0
- package/dist/store/topic-jobs.mjs +62 -0
- package/dist/sync/bound.d.mts +7 -0
- package/dist/sync/bound.mjs +29 -0
- package/dist/sync/github.d.mts +12 -0
- package/dist/sync/github.mjs +297 -0
- package/dist/sync/import.d.mts +8 -0
- package/dist/sync/import.mjs +154 -0
- package/dist/sync/jobs.d.mts +9 -0
- package/dist/sync/jobs.mjs +80 -0
- package/dist/sync/mirror.d.mts +9 -0
- package/dist/sync/mirror.mjs +227 -0
- package/dist/sync/publish.d.mts +5 -0
- package/dist/sync/publish.mjs +117 -0
- package/dist/sync/records.mjs +73 -0
- package/dist/sync/smart-http.d.mts +8 -0
- package/dist/sync/smart-http.mjs +23 -0
- package/dist/sync/step.mjs +334 -0
- package/dist/sync/tries.mjs +126 -0
- package/dist/sync.d.mts +8 -0
- package/dist/sync.mjs +8 -0
- package/dist/topics/advance.mjs +554 -0
- package/dist/topics/calls.mjs +346 -0
- package/dist/topics/directory.mjs +107 -0
- package/dist/topics/host.d.mts +11 -0
- package/dist/topics/host.mjs +71 -0
- package/dist/topics/members.mjs +177 -0
- package/dist/topics/rows.mjs +99 -0
- package/dist/topics/topic.mjs +126 -0
- package/package.json +88 -3
- package/README.md +0 -3
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
import { objectsReadMost } from "../contracts/objects.mjs";
|
|
2
|
+
import { spentAt } from "../contracts/calls-spent.mjs";
|
|
3
|
+
import { reject } from "../contracts/result.mjs";
|
|
4
|
+
import { hexOf } from "../protocol/bytes/hex.mjs";
|
|
5
|
+
import { emptyTree } from "../protocol/objects/object.mjs";
|
|
6
|
+
import { compareNames } from "../protocol/objects/tree.mjs";
|
|
7
|
+
// src/engine/combined.ts
|
|
8
|
+
/** The most the walk holds of trees read ahead and not yet open, besides those open: 1 MiB. */
|
|
9
|
+
const aheadMost = 1048576;
|
|
10
|
+
/**
|
|
11
|
+
* `error` thrown as Git's errors are at a Promise surface, with it as the `cause`, as the store's
|
|
12
|
+
* `thrownError` throws them: the engine sits below the store, so it makes its own.
|
|
13
|
+
*/
|
|
14
|
+
const failedWith = (error) => new Error(error.message, { cause: error });
|
|
15
|
+
/**
|
|
16
|
+
* A batch read's refusal past a call bound, thrown: a spent request stops whole, so the walk
|
|
17
|
+
* never falls back to reading each tree on its own, which would make more calls past it.
|
|
18
|
+
*/
|
|
19
|
+
const stopIfSpent = (error) => {
|
|
20
|
+
if (spentAt(error) !== void 0) throw failedWith(error);
|
|
21
|
+
};
|
|
22
|
+
/** A walk stopped by its allotment's refusal, which its caller answers. */
|
|
23
|
+
var WalkRefused = class extends Error {
|
|
24
|
+
refusal;
|
|
25
|
+
constructor(refusal) {
|
|
26
|
+
super(refusal.message);
|
|
27
|
+
this.refusal = refusal;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The ref's refusal: the walk's code, message, hint and context, built field by field, so the
|
|
31
|
+
* error's `cause`, such as an infra error under a grow, never reaches a `Rejected` that's logged,
|
|
32
|
+
* stored or sent.
|
|
33
|
+
*/
|
|
34
|
+
get rejected() {
|
|
35
|
+
const { code, message, hint, context } = this.refusal;
|
|
36
|
+
const input = {
|
|
37
|
+
code,
|
|
38
|
+
message
|
|
39
|
+
};
|
|
40
|
+
if (hint !== void 0) input.hint = hint;
|
|
41
|
+
if (context !== void 0) input.context = context;
|
|
42
|
+
return reject(input);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
/** A mode's type bits, as Git's `canon_mode` reads them: a folder's are `040000` whatever follows. */
|
|
46
|
+
const typeBits = 61440;
|
|
47
|
+
const folderType = 16384;
|
|
48
|
+
/** An entry's ID as hex, made only for an entry the walk keeps or descends into. */
|
|
49
|
+
const idOf = (entry) => hexOf(entry.bytes.subarray(entry.at, entry.at + 20));
|
|
50
|
+
/** Whether two entries name one object, their IDs compared in place. */
|
|
51
|
+
const sameId = (a, b) => {
|
|
52
|
+
for (let at = 0; at < 20; at += 1) if (a.bytes[a.at + at] !== b.bytes[b.at + at]) return false;
|
|
53
|
+
return true;
|
|
54
|
+
};
|
|
55
|
+
const sameEntry = (a, b) => a !== void 0 && a.mode === b.mode && sameId(a, b);
|
|
56
|
+
/** The entry at `at` in a tree's bytes, and where the next one starts. */
|
|
57
|
+
const entryAt = (bytes, at) => {
|
|
58
|
+
const space = bytes.indexOf(32, at);
|
|
59
|
+
const nul = bytes.indexOf(0, space + 1);
|
|
60
|
+
let mode = 0;
|
|
61
|
+
for (let digit = at; digit < space; digit += 1) mode = mode * 8 + ((bytes[digit] ?? 48) - 48);
|
|
62
|
+
return {
|
|
63
|
+
entry: {
|
|
64
|
+
mode,
|
|
65
|
+
name: bytes.subarray(space + 1, nul),
|
|
66
|
+
bytes,
|
|
67
|
+
at: nul + 1
|
|
68
|
+
},
|
|
69
|
+
end: nul + 21
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* A pass over a tree's entries: over those parsed and kept, else read from its bytes as it moves,
|
|
74
|
+
* which is what a walk keeps of a tree it has open, its bytes and where it's at in them. Told to
|
|
75
|
+
* let go of its parsed entries, it reads on from its bytes where it stands.
|
|
76
|
+
*/
|
|
77
|
+
var TreeCursor = class {
|
|
78
|
+
#bytes;
|
|
79
|
+
#entries;
|
|
80
|
+
#index = 0;
|
|
81
|
+
/** Where the entry after `current` starts in the tree's bytes. */
|
|
82
|
+
#end = 0;
|
|
83
|
+
current;
|
|
84
|
+
constructor(tree) {
|
|
85
|
+
this.#bytes = tree.bytes;
|
|
86
|
+
this.#entries = tree.entries;
|
|
87
|
+
if (tree.entries === void 0) this.next();
|
|
88
|
+
else this.#at(tree.entries[0]);
|
|
89
|
+
}
|
|
90
|
+
#at(entry) {
|
|
91
|
+
this.current = entry;
|
|
92
|
+
this.#end = entry === void 0 ? this.#bytes.length : entry.at + 20;
|
|
93
|
+
}
|
|
94
|
+
next() {
|
|
95
|
+
if (this.#entries !== void 0) {
|
|
96
|
+
this.#index += 1;
|
|
97
|
+
this.#at(this.#entries[this.#index]);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (this.#end >= this.#bytes.length) {
|
|
101
|
+
this.current = void 0;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const { entry, end } = entryAt(this.#bytes, this.#end);
|
|
105
|
+
this.current = entry;
|
|
106
|
+
this.#end = end;
|
|
107
|
+
}
|
|
108
|
+
/** Reads on from the tree's bytes, its parsed entries let go of. */
|
|
109
|
+
letGo() {
|
|
110
|
+
this.#entries = void 0;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
/** Every entry of a tree's bytes, in order. */
|
|
114
|
+
const parsedOf = (bytes) => {
|
|
115
|
+
const entries = [];
|
|
116
|
+
for (let at = 0; at < bytes.length;) {
|
|
117
|
+
const { entry, end } = entryAt(bytes, at);
|
|
118
|
+
entries.push(entry);
|
|
119
|
+
at = end;
|
|
120
|
+
}
|
|
121
|
+
return entries;
|
|
122
|
+
};
|
|
123
|
+
const emptyOne = {
|
|
124
|
+
bytes: /* @__PURE__ */ new Uint8Array(),
|
|
125
|
+
entries: [],
|
|
126
|
+
charged: 0
|
|
127
|
+
};
|
|
128
|
+
/** A pass over `tree`'s entries: over those parsed when it keeps them, else from its bytes. */
|
|
129
|
+
const cursorOf = (tree) => new TreeCursor(tree);
|
|
130
|
+
/** What `tree`'s parsed entries are charged, beside its bytes: none when it keeps none. */
|
|
131
|
+
const parseCost = (tree) => (tree.entries?.length ?? 0) * 128;
|
|
132
|
+
/**
|
|
133
|
+
* The parsed entries the trees open on the depth walk's path keep, each folder's held while it's
|
|
134
|
+
* open. Before the walk refuses a tree it must open, it lets go of them all, each tree read from
|
|
135
|
+
* its bytes from then on, so the walk is refused only when the open path's bytes and the tree's
|
|
136
|
+
* can't fit, as Q730 says, never for its parses.
|
|
137
|
+
*/
|
|
138
|
+
var OpenParses = class {
|
|
139
|
+
#folders = /* @__PURE__ */ new Set();
|
|
140
|
+
/** A folder's `letGo`, which answers the bytes it gave back: held until the returned call. */
|
|
141
|
+
hold(letGo) {
|
|
142
|
+
this.#folders.add(letGo);
|
|
143
|
+
return () => void this.#folders.delete(letGo);
|
|
144
|
+
}
|
|
145
|
+
/** Lets go of every open folder's parsed entries: the bytes given back. */
|
|
146
|
+
letGo() {
|
|
147
|
+
let freed = 0;
|
|
148
|
+
for (const folder of this.#folders) freed += folder();
|
|
149
|
+
return freed;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* `tree` with its entries parsed and kept, once `allotment` grows for them, so the walk parses
|
|
154
|
+
* it once: when it won't, the tree as it was, its entries read from its bytes on each pass, and
|
|
155
|
+
* the walk never refused for them.
|
|
156
|
+
*/
|
|
157
|
+
const keptParsed = async (tree, allotment) => {
|
|
158
|
+
if (tree.entries !== void 0) return tree;
|
|
159
|
+
const entries = parsedOf(tree.bytes);
|
|
160
|
+
const cost = entries.length * 128;
|
|
161
|
+
const answer = allotment.grow(cost);
|
|
162
|
+
if ((answer instanceof Promise ? await answer : answer) !== void 0) return tree;
|
|
163
|
+
return {
|
|
164
|
+
bytes: tree.bytes,
|
|
165
|
+
entries,
|
|
166
|
+
charged: tree.charged + cost
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Whether an entry is a folder, by its mode's type bits, as Git and receive's fsck read it: a
|
|
171
|
+
* folder written `40755` is one, and its files are walked.
|
|
172
|
+
*/
|
|
173
|
+
const isFolder = (entry) => entry !== void 0 && (entry.mode & typeBits) === folderType;
|
|
174
|
+
/** A tree's bytes, the empty tree's none: `DATA_LOSS` for one the repo doesn't have. */
|
|
175
|
+
const treeBytes = async (read, oid, signal) => {
|
|
176
|
+
if (oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904") return /* @__PURE__ */ new Uint8Array();
|
|
177
|
+
const found = await read({
|
|
178
|
+
oid,
|
|
179
|
+
signal
|
|
180
|
+
});
|
|
181
|
+
if (found.kind === "error") throw failedWith(found.error);
|
|
182
|
+
const object = found.value;
|
|
183
|
+
if (object?.type !== "tree") {
|
|
184
|
+
await object?.bytes.cancel().catch(() => void 0);
|
|
185
|
+
throw failedWith({
|
|
186
|
+
code: "DATA_LOSS",
|
|
187
|
+
message: `${oid} isn't a tree in the repo`
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return new Uint8Array(await new Response(object.bytes).bytes());
|
|
191
|
+
};
|
|
192
|
+
const decoder = new TextDecoder("utf-8", {
|
|
193
|
+
fatal: true,
|
|
194
|
+
ignoreBOM: true
|
|
195
|
+
});
|
|
196
|
+
/** A walked path as a change names it: its text, and its own bytes when they aren't UTF-8. */
|
|
197
|
+
const changeOf = (path, entry, added) => {
|
|
198
|
+
const now = {
|
|
199
|
+
mode: entry.mode.toString(8).padStart(6, "0"),
|
|
200
|
+
oid: idOf(entry)
|
|
201
|
+
};
|
|
202
|
+
try {
|
|
203
|
+
return {
|
|
204
|
+
status: added ? "A" : "M",
|
|
205
|
+
path: decoder.decode(path),
|
|
206
|
+
new: now
|
|
207
|
+
};
|
|
208
|
+
} catch {
|
|
209
|
+
const text = new TextDecoder("utf-8", {
|
|
210
|
+
fatal: false,
|
|
211
|
+
ignoreBOM: true
|
|
212
|
+
}).decode(path);
|
|
213
|
+
return {
|
|
214
|
+
status: added ? "A" : "M",
|
|
215
|
+
path: text,
|
|
216
|
+
pathBytes: path.slice(),
|
|
217
|
+
new: now
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
const joined = (prefix, name) => {
|
|
222
|
+
if (prefix === void 0) return name;
|
|
223
|
+
const path = new Uint8Array(prefix.length + 1 + name.length);
|
|
224
|
+
path.set(prefix);
|
|
225
|
+
path[prefix.length] = 47;
|
|
226
|
+
path.set(name, prefix.length + 1);
|
|
227
|
+
return path;
|
|
228
|
+
};
|
|
229
|
+
/** The entry of `side` whose name, as Git orders a tree, is `entry`'s, moving `side` up to it. */
|
|
230
|
+
const entryBeside = (side, entry) => {
|
|
231
|
+
for (;;) {
|
|
232
|
+
const at = side.current;
|
|
233
|
+
if (at === void 0) return void 0;
|
|
234
|
+
const order = compareNames(at.name, isFolder(at), entry.name, isFolder(entry));
|
|
235
|
+
if (order > 0) return void 0;
|
|
236
|
+
if (order === 0) return at;
|
|
237
|
+
side.next();
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* What a folder the read ahead keeps for later holds, charged beside the trees it read: about
|
|
242
|
+
* what V8 keeps for the folder and its IDs, one string of 40 hex digits each.
|
|
243
|
+
*/
|
|
244
|
+
const folderBytes = (folder) => 64 + 56 * (1 + folder.parents.length);
|
|
245
|
+
/** A folder's trees as one key: its own and each parent's, in order. */
|
|
246
|
+
const keyOf = (folder) => `${folder.head}:${folder.parents.join(",")}`;
|
|
247
|
+
/** The folders one folder's walk opens, its changed subfolders, in the walk's order. */
|
|
248
|
+
const foldersOf = (own, sides) => {
|
|
249
|
+
const ahead = cursorOf(own);
|
|
250
|
+
const beside = sides.map(cursorOf);
|
|
251
|
+
const folders = [];
|
|
252
|
+
for (; ahead.current !== void 0; ahead.next()) {
|
|
253
|
+
const entry = ahead.current;
|
|
254
|
+
const others = beside.map((side) => entryBeside(side, entry));
|
|
255
|
+
if (!isFolder(entry) || others.some((other) => sameEntry(other, entry))) continue;
|
|
256
|
+
const parents = others.map((other) => isFolder(other) && other !== void 0 ? idOf(other) : emptyTree);
|
|
257
|
+
folders.push({
|
|
258
|
+
head: idOf(entry),
|
|
259
|
+
parents
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return folders;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* The trees the walk read ahead, each charged until it's opened or the walk ends. As a folder
|
|
266
|
+
* opens, the folders below it are read a level at a time, one batch a level, as far as
|
|
267
|
+
* `aheadMost` holds them, so a walk down a deep or a wide tree reads it in few batches while it
|
|
268
|
+
* still lists each path in Git's order as it comes to it.
|
|
269
|
+
*/
|
|
270
|
+
var Ahead = class {
|
|
271
|
+
#input;
|
|
272
|
+
#held = /* @__PURE__ */ new Map();
|
|
273
|
+
#bytes = 0;
|
|
274
|
+
/** Whether the last batch found no more room: none is read until the walk opens a tree. */
|
|
275
|
+
#full = false;
|
|
276
|
+
/**
|
|
277
|
+
* Each folder read ahead whose own folders are known, by its tree and its parents', so none is
|
|
278
|
+
* parsed twice: one tree at two paths, beside other parents' trees, has other folders below.
|
|
279
|
+
*/
|
|
280
|
+
#below = /* @__PURE__ */ new Map();
|
|
281
|
+
constructor(input) {
|
|
282
|
+
this.#input = input;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Reads `oids` ahead, those not held already, as many as fit `aheadMost` beside what's held.
|
|
286
|
+
* A batch that fails, past that bound or past the allotment, reads nothing more ahead: each
|
|
287
|
+
* tree is read on its own when the walk opens it, which answers any error of the tree's own.
|
|
288
|
+
*/
|
|
289
|
+
async read(oids) {
|
|
290
|
+
const { objects, signal, allotment } = this.#input;
|
|
291
|
+
if (objects === void 0 || this.#full) return;
|
|
292
|
+
const asked = [...new Set(oids.filter((oid) => oid !== "4b825dc642cb6eb9a060e54bf8d69288fbee4904" && !this.#held.has(oid)))].slice(0, objectsReadMost);
|
|
293
|
+
if (asked.length === 0) return;
|
|
294
|
+
const within = this.#within(allotment);
|
|
295
|
+
const read = await objects({
|
|
296
|
+
oids: asked,
|
|
297
|
+
bytes: within,
|
|
298
|
+
signal
|
|
299
|
+
});
|
|
300
|
+
if (read.kind === "error") {
|
|
301
|
+
stopIfSpent(read.error);
|
|
302
|
+
this.#full = true;
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (read.value.left.length > 0) this.#full = true;
|
|
306
|
+
for (const object of read.value.objects.values()) if (object.type === "tree") this.#held.set(object.oid, {
|
|
307
|
+
bytes: object.bytes,
|
|
308
|
+
charged: object.bytes.byteLength
|
|
309
|
+
});
|
|
310
|
+
else within.shrink(object.bytes.byteLength);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The walk's allotment within what's left of `aheadMost`: a bound inside the walk's allotment,
|
|
314
|
+
* never in its place, which passes every grant and shrink on to it. A refusal of a batch's
|
|
315
|
+
* first answers nothing, the read's failure, which reads nothing ahead, and a refusal of a parse
|
|
316
|
+
* keeps the tree unparsed.
|
|
317
|
+
*/
|
|
318
|
+
#within(allotment) {
|
|
319
|
+
return {
|
|
320
|
+
grow: (bytes) => {
|
|
321
|
+
if (this.#bytes + bytes > aheadMost) return aheadFull;
|
|
322
|
+
const answer = allotment.grow(bytes);
|
|
323
|
+
const granted = (refused) => {
|
|
324
|
+
if (refused === void 0) this.#bytes += bytes;
|
|
325
|
+
return refused;
|
|
326
|
+
};
|
|
327
|
+
return answer instanceof Promise ? answer.then(granted) : granted(answer);
|
|
328
|
+
},
|
|
329
|
+
shrink: (bytes) => {
|
|
330
|
+
this.#bytes -= bytes;
|
|
331
|
+
allotment.shrink(bytes);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
/** The held tree `oid`, its entries parsed and kept within `aheadMost` when there's room. */
|
|
336
|
+
async #parsed(oid) {
|
|
337
|
+
if (oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904") return emptyOne;
|
|
338
|
+
const held = this.#held.get(oid);
|
|
339
|
+
if (held === void 0) return void 0;
|
|
340
|
+
const kept = await keptParsed(held, this.#within(this.#input.allotment));
|
|
341
|
+
this.#held.set(oid, kept);
|
|
342
|
+
return kept;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Reads the folders below `folders` ahead, a level at a time, each level's trees in one batch,
|
|
346
|
+
* until a level is read or `aheadMost` is full: a folder whose trees didn't all come is left
|
|
347
|
+
* for the walk to read when it opens it.
|
|
348
|
+
*/
|
|
349
|
+
async below(folders) {
|
|
350
|
+
if (this.#input.objects === void 0) return;
|
|
351
|
+
const once = (into, seen, folder) => {
|
|
352
|
+
const key = keyOf(folder);
|
|
353
|
+
if (seen.has(key)) return;
|
|
354
|
+
seen.add(key);
|
|
355
|
+
into.push(folder);
|
|
356
|
+
};
|
|
357
|
+
let level = [];
|
|
358
|
+
const first = /* @__PURE__ */ new Set();
|
|
359
|
+
for (const folder of folders) once(level, first, folder);
|
|
360
|
+
while (level.length > 0 && !this.#full) {
|
|
361
|
+
await this.read(level.flatMap((folder) => [folder.head, ...folder.parents]));
|
|
362
|
+
const next = [];
|
|
363
|
+
const seen = /* @__PURE__ */ new Set();
|
|
364
|
+
for (const folder of level) {
|
|
365
|
+
const known = this.#below.get(keyOf(folder));
|
|
366
|
+
if (known !== void 0) {
|
|
367
|
+
for (const below of known.folders) once(next, seen, below);
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
const own = await this.#parsed(folder.head);
|
|
371
|
+
const sides = [];
|
|
372
|
+
for (const parent of folder.parents) {
|
|
373
|
+
const side = await this.#parsed(parent);
|
|
374
|
+
if (side !== void 0) sides.push(side);
|
|
375
|
+
}
|
|
376
|
+
if (own === void 0 || sides.length < folder.parents.length) continue;
|
|
377
|
+
const below = foldersOf(own, sides);
|
|
378
|
+
const charged = below.reduce((sum, each) => sum + folderBytes(each), 0);
|
|
379
|
+
const answer = this.#within(this.#input.allotment).grow(charged);
|
|
380
|
+
if ((answer instanceof Promise ? await answer : answer) !== void 0) {
|
|
381
|
+
this.#full = true;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
this.#below.set(keyOf(folder), {
|
|
385
|
+
folders: below,
|
|
386
|
+
charged
|
|
387
|
+
});
|
|
388
|
+
for (const each of below) once(next, seen, each);
|
|
389
|
+
}
|
|
390
|
+
level = next;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* The tree `oid`, read ahead, moved from what's held ahead to what the walk has open: its bytes
|
|
395
|
+
* and its parsed entries stay charged to the allotment, for the walk to release as it closes
|
|
396
|
+
* the tree, and there's room to read ahead again.
|
|
397
|
+
*/
|
|
398
|
+
take(oid) {
|
|
399
|
+
const tree = this.#held.get(oid);
|
|
400
|
+
if (tree === void 0) return void 0;
|
|
401
|
+
this.#held.delete(oid);
|
|
402
|
+
this.#bytes -= tree.charged;
|
|
403
|
+
this.#full = false;
|
|
404
|
+
return tree;
|
|
405
|
+
}
|
|
406
|
+
/** The folders below `folder`, if a read ahead knew them, let go of as the walk opens it. */
|
|
407
|
+
foldersBelow(folder) {
|
|
408
|
+
const key = keyOf(folder);
|
|
409
|
+
const known = this.#below.get(key);
|
|
410
|
+
if (known === void 0) return void 0;
|
|
411
|
+
this.#below.delete(key);
|
|
412
|
+
this.#bytes -= known.charged;
|
|
413
|
+
this.#input.allotment.shrink(known.charged);
|
|
414
|
+
this.#full = false;
|
|
415
|
+
return known.folders;
|
|
416
|
+
}
|
|
417
|
+
/** Whether the read ahead holds anything it could let go of to make room. */
|
|
418
|
+
holds() {
|
|
419
|
+
return this.#held.size > 0 || this.#below.size > 0;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Releases every tree read ahead and never opened, and every folder kept below one, as the walk
|
|
423
|
+
* ends, or to make room for a tree the walk must open, which then reads ahead again.
|
|
424
|
+
*/
|
|
425
|
+
release() {
|
|
426
|
+
for (const tree of this.#held.values()) this.#input.allotment.shrink(tree.charged);
|
|
427
|
+
for (const known of this.#below.values()) this.#input.allotment.shrink(known.charged);
|
|
428
|
+
this.#held.clear();
|
|
429
|
+
this.#below.clear();
|
|
430
|
+
this.#bytes = 0;
|
|
431
|
+
this.#full = false;
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
/** A read ahead's refusal past `aheadMost`, which reads nothing ahead. */
|
|
435
|
+
const aheadFull = {
|
|
436
|
+
code: "RESOURCE_EXHAUSTED",
|
|
437
|
+
message: "The walk's trees read ahead pass their bound",
|
|
438
|
+
context: { reason: "diff-limit" }
|
|
439
|
+
};
|
|
440
|
+
/** Each path under `head` differing from every one of `parents`', as `CombinedInput` says. */
|
|
441
|
+
async function* combinedPaths(input) {
|
|
442
|
+
if (input.order === "level") {
|
|
443
|
+
yield* levelPaths(input);
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const ahead = new Ahead(input);
|
|
447
|
+
const parses = new OpenParses();
|
|
448
|
+
try {
|
|
449
|
+
await ahead.read([input.head, ...input.parents]);
|
|
450
|
+
yield* differing(input, {
|
|
451
|
+
ahead,
|
|
452
|
+
parses
|
|
453
|
+
}, input.head, input.parents, void 0);
|
|
454
|
+
} finally {
|
|
455
|
+
ahead.release();
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
/** The paths under one folder's trees, the commit's and each parent's, opened as it starts. */
|
|
459
|
+
async function* differing(input, walking, head, parents, prefix) {
|
|
460
|
+
const { allotment, read, signal } = input;
|
|
461
|
+
const { ahead, parses } = walking;
|
|
462
|
+
let taken = 0;
|
|
463
|
+
const trees = [];
|
|
464
|
+
const cursors = [];
|
|
465
|
+
const unhold = parses.hold(() => {
|
|
466
|
+
let freed = 0;
|
|
467
|
+
for (const [at, tree] of trees.entries()) {
|
|
468
|
+
const cost = parseCost(tree);
|
|
469
|
+
if (cost === 0) continue;
|
|
470
|
+
trees[at] = {
|
|
471
|
+
bytes: tree.bytes,
|
|
472
|
+
charged: tree.charged - cost
|
|
473
|
+
};
|
|
474
|
+
cursors[at]?.letGo();
|
|
475
|
+
allotment.shrink(cost);
|
|
476
|
+
taken -= cost;
|
|
477
|
+
freed += cost;
|
|
478
|
+
}
|
|
479
|
+
return freed;
|
|
480
|
+
});
|
|
481
|
+
const opened = async (oid) => {
|
|
482
|
+
if (oid === "4b825dc642cb6eb9a060e54bf8d69288fbee4904") return emptyOne;
|
|
483
|
+
const held = ahead.take(oid);
|
|
484
|
+
if (held !== void 0) {
|
|
485
|
+
taken += held.charged;
|
|
486
|
+
return held;
|
|
487
|
+
}
|
|
488
|
+
const bytes = await treeBytes(read, oid, signal);
|
|
489
|
+
const asked = allotment.grow(bytes.length);
|
|
490
|
+
let refused = asked instanceof Promise ? await asked : asked;
|
|
491
|
+
if (refused !== void 0) {
|
|
492
|
+
const readAhead = ahead.holds();
|
|
493
|
+
ahead.release();
|
|
494
|
+
if (parses.letGo() > 0 || readAhead) {
|
|
495
|
+
const again = allotment.grow(bytes.length);
|
|
496
|
+
refused = again instanceof Promise ? await again : again;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (refused !== void 0) throw new WalkRefused(refused);
|
|
500
|
+
taken += bytes.length;
|
|
501
|
+
const tree = await keptParsed({
|
|
502
|
+
bytes,
|
|
503
|
+
charged: bytes.length
|
|
504
|
+
}, allotment);
|
|
505
|
+
taken += tree.charged - bytes.length;
|
|
506
|
+
return tree;
|
|
507
|
+
};
|
|
508
|
+
try {
|
|
509
|
+
trees.push(await opened(head));
|
|
510
|
+
for (const parent of parents) trees.push(await opened(parent));
|
|
511
|
+
const [own = emptyOne, ...sides] = trees;
|
|
512
|
+
await ahead.below(ahead.foldersBelow({
|
|
513
|
+
head,
|
|
514
|
+
parents
|
|
515
|
+
}) ?? foldersOf(own, sides));
|
|
516
|
+
for (const tree of trees) cursors.push(cursorOf(tree));
|
|
517
|
+
const [ownCursor, ...sideCursors] = cursors;
|
|
518
|
+
if (ownCursor !== void 0) yield* differingIn(input, walking, ownCursor, sideCursors, prefix);
|
|
519
|
+
} finally {
|
|
520
|
+
unhold();
|
|
521
|
+
allotment.shrink(taken);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* The steps of one folder, its trees open, the commit's and each parent's beside it, one at a
|
|
526
|
+
* time: what both orders walk, `depth` as each comes and `level` a level at a time.
|
|
527
|
+
*/
|
|
528
|
+
function* stepsIn(own, sides, prefix) {
|
|
529
|
+
for (; own.current !== void 0; own.next()) {
|
|
530
|
+
const entry = own.current;
|
|
531
|
+
const beside = sides.map((side) => entryBeside(side, entry));
|
|
532
|
+
if (beside.some((other) => sameEntry(other, entry))) continue;
|
|
533
|
+
const path = joined(prefix, entry.name);
|
|
534
|
+
if (isFolder(entry)) {
|
|
535
|
+
const parents = beside.map((other) => isFolder(other) && other !== void 0 ? idOf(other) : emptyTree);
|
|
536
|
+
yield {
|
|
537
|
+
folder: {
|
|
538
|
+
head: idOf(entry),
|
|
539
|
+
parents
|
|
540
|
+
},
|
|
541
|
+
path
|
|
542
|
+
};
|
|
543
|
+
} else yield { change: changeOf(path, entry, beside[0] === void 0 || isFolder(beside[0])) };
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
/** `differing`'s walk of one folder, depth first: each path as it comes, each folder in turn. */
|
|
547
|
+
async function* differingIn(input, walking, own, sides, prefix) {
|
|
548
|
+
for (const step of stepsIn(own, sides, prefix)) if ("change" in step) yield step.change;
|
|
549
|
+
else yield* differing(input, walking, step.folder.head, step.folder.parents, step.path);
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* What a path the level walk holds until it ends takes, charged to its allotment: about what V8
|
|
553
|
+
* keeps for the change, its mode, its ID and its path's text.
|
|
554
|
+
*/
|
|
555
|
+
const changeBytes = (change) => 192 + 2 * change.path.length;
|
|
556
|
+
function* flattened(slot) {
|
|
557
|
+
for (const item of slot.items) if ("items" in item) yield* flattened(item);
|
|
558
|
+
else yield item;
|
|
559
|
+
}
|
|
560
|
+
/** `bytes` more of `allotment`, or the walk refused as it answers. */
|
|
561
|
+
const grownOrRefused = async (allotment, bytes) => {
|
|
562
|
+
const answer = allotment.grow(bytes);
|
|
563
|
+
const refused = answer instanceof Promise ? await answer : answer;
|
|
564
|
+
if (refused !== void 0) throw new WalkRefused(refused);
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* The trees of one level, its folders' and their parents', read in batches as far as the
|
|
568
|
+
* allotment holds them, then one at a time, each charged: refused only for a tree that won't fit
|
|
569
|
+
* on its own beside what the walk holds.
|
|
570
|
+
*/
|
|
571
|
+
const levelTrees = async (input, oids) => {
|
|
572
|
+
const { allotment, objects, read, signal } = input;
|
|
573
|
+
const trees = /* @__PURE__ */ new Map([[emptyTree, emptyOne]]);
|
|
574
|
+
const asked = [...new Set(oids.filter((oid) => oid !== emptyTree))];
|
|
575
|
+
let left = asked;
|
|
576
|
+
while (objects !== void 0 && left.length > 0) {
|
|
577
|
+
const answer = await objects({
|
|
578
|
+
oids: left.slice(0, objectsReadMost),
|
|
579
|
+
bytes: allotment,
|
|
580
|
+
signal
|
|
581
|
+
});
|
|
582
|
+
if (answer.kind === "error") {
|
|
583
|
+
stopIfSpent(answer.error);
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
for (const object of answer.value.objects.values()) trees.set(object.oid, {
|
|
587
|
+
bytes: object.bytes,
|
|
588
|
+
charged: object.bytes.byteLength
|
|
589
|
+
});
|
|
590
|
+
left = [...answer.value.left, ...left.slice(objectsReadMost)];
|
|
591
|
+
if (answer.value.objects.size === 0) break;
|
|
592
|
+
}
|
|
593
|
+
for (const oid of asked) {
|
|
594
|
+
if (trees.has(oid)) continue;
|
|
595
|
+
const bytes = await treeBytes(read, oid, signal);
|
|
596
|
+
await grownOrRefused(allotment, bytes.length);
|
|
597
|
+
trees.set(oid, {
|
|
598
|
+
bytes,
|
|
599
|
+
charged: bytes.length
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
return trees;
|
|
603
|
+
};
|
|
604
|
+
/** `combinedPaths` a level at a time, as `CombinedInput.order` says. */
|
|
605
|
+
async function* levelPaths(input) {
|
|
606
|
+
const { allotment } = input;
|
|
607
|
+
const root = { items: [] };
|
|
608
|
+
let level = [{
|
|
609
|
+
folder: {
|
|
610
|
+
head: input.head,
|
|
611
|
+
parents: input.parents
|
|
612
|
+
},
|
|
613
|
+
prefix: void 0,
|
|
614
|
+
slot: root
|
|
615
|
+
}];
|
|
616
|
+
let held = 0;
|
|
617
|
+
const hold = async (bytes) => {
|
|
618
|
+
await grownOrRefused(allotment, bytes);
|
|
619
|
+
held += bytes;
|
|
620
|
+
};
|
|
621
|
+
try {
|
|
622
|
+
while (level.length > 0) {
|
|
623
|
+
const trees = await levelTrees(input, level.flatMap(({ folder }) => [folder.head, ...folder.parents]));
|
|
624
|
+
const next = [];
|
|
625
|
+
try {
|
|
626
|
+
for (const { folder, prefix, slot } of level) {
|
|
627
|
+
const own = trees.get(folder.head) ?? emptyOne;
|
|
628
|
+
const sides = folder.parents.map((oid) => trees.get(oid) ?? emptyOne);
|
|
629
|
+
for (const step of stepsIn(cursorOf(own), sides.map(cursorOf), prefix)) if ("change" in step) {
|
|
630
|
+
await hold(changeBytes(step.change));
|
|
631
|
+
slot.items.push(step.change);
|
|
632
|
+
} else {
|
|
633
|
+
await hold(folderBytes(step.folder));
|
|
634
|
+
const below = { items: [] };
|
|
635
|
+
slot.items.push(below);
|
|
636
|
+
next.push({
|
|
637
|
+
folder: step.folder,
|
|
638
|
+
prefix: step.path,
|
|
639
|
+
slot: below
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
} finally {
|
|
644
|
+
for (const tree of trees.values()) allotment.shrink(tree.charged);
|
|
645
|
+
}
|
|
646
|
+
level = next;
|
|
647
|
+
}
|
|
648
|
+
yield* flattened(root);
|
|
649
|
+
} finally {
|
|
650
|
+
allotment.shrink(held);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
export { WalkRefused, changeBytes, combinedPaths, folderBytes };
|