@ref0/git 0.8.0 → 0.9.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/contracts/calls-spent.d.mts +2 -12
- package/dist/contracts/calls-spent.mjs +4 -5
- package/dist/contracts/events.d.mts +70 -4
- package/dist/contracts/events.mjs +27 -3
- package/dist/contracts/git.d.mts +13 -3
- package/dist/contracts/objects.d.mts +18 -0
- package/dist/contracts/queue.d.mts +3 -2
- package/dist/contracts/queue.mjs +4 -2
- package/dist/core/ancestry.mjs +5 -4
- package/dist/core/index-job.mjs +23 -1
- package/dist/core/index-lost.d.mts +11 -0
- package/dist/core/index-lost.mjs +55 -0
- package/dist/core/objects/commit-writes.mjs +1 -1
- package/dist/core/objects/commits.mjs +10 -9
- package/dist/core/objects/merges.mjs +1 -1
- package/dist/core/objects/reading.mjs +28 -13
- package/dist/core/objects/trees.mjs +1 -1
- package/dist/core/parts.d.mts +7 -0
- package/dist/core/publish.mjs +9 -5
- package/dist/core/purge.mjs +16 -3
- package/dist/core/push.mjs +27 -11
- package/dist/core/repack.mjs +36 -14
- package/dist/core/view.d.mts +10 -1
- package/dist/core/view.mjs +15 -6
- package/dist/effect.d.mts +2 -3
- package/dist/effect.mjs +2 -3
- package/dist/engine/commits.mjs +4 -3
- package/dist/engine/merge-bases.mjs +5 -3
- package/dist/engine/merge.mjs +4 -3
- package/dist/engine/parts.d.mts +1 -0
- package/dist/engine/parts.mjs +1 -1
- package/dist/engine/walk.mjs +15 -11
- package/dist/http/core-parts.mjs +17 -8
- package/dist/index.d.mts +2 -2
- package/dist/lfs/objects.mjs +7 -4
- package/dist/lfs/upkeep.mjs +6 -5
- package/dist/lfs/upload-most.mjs +7 -1
- package/dist/protocol/bytes/streams.mjs +84 -2
- package/dist/protocol/diff/read.d.mts +1 -0
- package/dist/protocol/diff/read.mjs +5 -2
- package/dist/protocol/objects/commit.d.mts +7 -0
- package/dist/protocol/objects/commit.mjs +5 -1
- package/dist/queue/advance.mjs +39 -10
- package/dist/queue/host.d.mts +4 -0
- package/dist/queue/layer.mjs +4 -2
- package/dist/queue/limits.mjs +18 -2
- package/dist/queue/rows.mjs +2 -1
- package/dist/queue/trim.mjs +2 -2
- package/dist/rest/commits.d.mts +238 -238
- package/dist/rest/forks.d.mts +71 -71
- package/dist/rest/refs.d.mts +143 -143
- package/dist/rest/repos.d.mts +81 -81
- package/dist/rest/topics.d.mts +112 -112
- package/dist/rest/trees.d.mts +77 -77
- package/dist/rest/wire.d.mts +19 -1
- package/dist/rest/work.d.mts +39 -39
- package/dist/server/joined.d.mts +11 -5
- package/dist/server/joined.mjs +3 -2
- package/dist/server/registry.mjs +11 -5
- package/dist/server/server.mjs +16 -4
- package/dist/storage/index-bitmaps.mjs +16 -10
- package/dist/storage/index-build.mjs +61 -13
- package/dist/storage/index-graph.d.mts +1 -0
- package/dist/storage/index-graph.mjs +29 -5
- package/dist/storage/index-layers.d.mts +1 -0
- package/dist/storage/index-layers.mjs +5 -2
- package/dist/storage/index-reach.mjs +7 -5
- package/dist/storage/index-remap.mjs +5 -5
- package/dist/storage/index-visible.mjs +16 -5
- package/dist/storage/links.mjs +3 -3
- package/dist/storage/pack-order.d.mts +1 -0
- package/dist/storage/pack-order.mjs +18 -1
- package/dist/storage/prune-walk.mjs +5 -2
- package/dist/storage/prune.mjs +107 -37
- package/dist/storage/receive-bounds.mjs +3 -2
- package/dist/storage/visible.mjs +3 -2
- package/dist/storage/walk.d.mts +1 -0
- package/dist/storage/walk.mjs +9 -5
- package/dist/storage/wants.mjs +17 -11
- package/dist/store/call-count.d.mts +8 -0
- package/dist/store/call-count.mjs +15 -7
- package/dist/store/errors.d.mts +7 -1
- package/dist/store/errors.mjs +7 -1
- package/dist/store/job-try.mjs +3 -1
- package/dist/store/records.mjs +17 -2
- package/dist/store/repo-record.mjs +9 -2
- package/dist/store/scopes.mjs +10 -2
- package/dist/sync/bound.d.mts +1 -1
- package/dist/sync/import.mjs +1 -1
- package/dist/sync/layer.mjs +4 -7
- package/dist/sync/mirror.mjs +1 -1
- package/dist/topics/advance.mjs +4 -4
- package/dist/topics/layer.mjs +1 -1
- package/package.json +3 -3
|
@@ -3,9 +3,9 @@ import { isOid } from "../../protocol/bytes/text.mjs";
|
|
|
3
3
|
import { badCursor, deadlineOf, inputDigest, readThrough } from "../../engine/reads.mjs";
|
|
4
4
|
import { DiffReader, ReadTally } from "../../protocol/diff/read.mjs";
|
|
5
5
|
import { decodePacks } from "../../store/git-store.mjs";
|
|
6
|
-
import { readRecord } from "../../store/repo-record.mjs";
|
|
6
|
+
import { readRecord, rootsOf } from "../../store/repo-record.mjs";
|
|
7
7
|
import { WholeRepo } from "../../store/ref-rows.mjs";
|
|
8
|
-
import { collections } from "../../store/scopes.mjs";
|
|
8
|
+
import { collections, repoRootsKey } from "../../store/scopes.mjs";
|
|
9
9
|
import { indexRowKey } from "../../storage/layout.mjs";
|
|
10
10
|
import { isVisibleTooLong } from "../../storage/visible.mjs";
|
|
11
11
|
import { heldOf as heldOf$1 } from "../../storage/wants.mjs";
|
|
@@ -54,6 +54,8 @@ const refReads = (names) => names.map((id) => ({
|
|
|
54
54
|
}));
|
|
55
55
|
const packsRead = { collection: collections.packs };
|
|
56
56
|
const everyRef = { collection: collections.refs };
|
|
57
|
+
/** The reads every open makes first, at fixed places: the packs, then the repo's roots. */
|
|
58
|
+
const openReads = [packsRead, repoRootsKey];
|
|
57
59
|
/**
|
|
58
60
|
* The repo `repo` names, opened for `caller` to read, with `revisions` resolved: each a full ID as
|
|
59
61
|
* it is, `HEAD` the default branch's tip, and a ref name the first of its refs held. A revision
|
|
@@ -88,10 +90,10 @@ const openKeyedRead = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo,
|
|
|
88
90
|
reads
|
|
89
91
|
}, opened);
|
|
90
92
|
});
|
|
91
|
-
/** The refs each revision may name, and the reads of them
|
|
93
|
+
/** The refs each revision may name, and the reads of them, the packs and roots a repo opens with. */
|
|
92
94
|
const readsOf = (revisions) => Effect.map(askedOf(revisions), (asked) => ({
|
|
93
95
|
asked,
|
|
94
|
-
reads: [
|
|
96
|
+
reads: [...openReads, ...refReads([...new Set(asked.flat())])]
|
|
95
97
|
}));
|
|
96
98
|
/** `listed`'s objects a batch at a time, with no walk: each batch `objectsOnce`, in `scope`. */
|
|
97
99
|
const oneShotObjects = (seen, listed, scope) => {
|
|
@@ -112,23 +114,30 @@ const readOpened = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, re
|
|
|
112
114
|
let index;
|
|
113
115
|
const view = yield* viewOf(caller, opened);
|
|
114
116
|
const every = yield* view.narrowed;
|
|
117
|
+
const roots = yield* rootsOf(results[1]);
|
|
118
|
+
let refsAt = openReads.length;
|
|
115
119
|
if (revisions.includes("HEAD") || every) {
|
|
116
120
|
const again = yield* readRecord(core.store, opened.internalId, every ? [
|
|
117
121
|
packsRead,
|
|
118
122
|
everyRef,
|
|
119
123
|
indexRowKey
|
|
120
|
-
] : [
|
|
124
|
+
] : [
|
|
125
|
+
packsRead,
|
|
126
|
+
...reads.slice(openReads.length),
|
|
127
|
+
...refReads([record.defaultBranch])
|
|
128
|
+
]);
|
|
121
129
|
if (again.record === void 0 || again.record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${repo}'`);
|
|
122
130
|
record = again.record;
|
|
123
131
|
results = again.snapshot.results.slice(1);
|
|
124
132
|
version = again.snapshot.version;
|
|
133
|
+
refsAt = 1;
|
|
125
134
|
if (every) {
|
|
126
135
|
index = results[2]?.[0]?.value;
|
|
127
136
|
results = results.slice(0, 2);
|
|
128
137
|
}
|
|
129
138
|
}
|
|
130
139
|
const packs = yield* decodePacks(results[0] ?? []);
|
|
131
|
-
const held = yield* view.refs(results.slice(
|
|
140
|
+
const held = yield* view.refs(results.slice(refsAt).flat());
|
|
132
141
|
const listed = {
|
|
133
142
|
repo: opened.internalId,
|
|
134
143
|
version,
|
|
@@ -139,7 +148,8 @@ const readOpened = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, re
|
|
|
139
148
|
at: {
|
|
140
149
|
listed,
|
|
141
150
|
refs: held,
|
|
142
|
-
index
|
|
151
|
+
index,
|
|
152
|
+
roots
|
|
143
153
|
}
|
|
144
154
|
});
|
|
145
155
|
const starting = (prefix) => startingOnce(objectsFace(objects), listed, {
|
|
@@ -180,7 +190,8 @@ const readOpened = /* @__PURE__ */ Effect.fnUntraced(function* (caller, repo, re
|
|
|
180
190
|
allotment,
|
|
181
191
|
scoped: reader !== void 0,
|
|
182
192
|
oids,
|
|
183
|
-
objects
|
|
193
|
+
objects,
|
|
194
|
+
roots
|
|
184
195
|
};
|
|
185
196
|
});
|
|
186
197
|
/** A short ID, as `git rev-parse` reads one: 4 hex digits, Git's least, up to one short of whole. */
|
|
@@ -228,7 +239,8 @@ const noObject = "0".repeat(40);
|
|
|
228
239
|
/**
|
|
229
240
|
* Which of `oids` the refs `caller` sees of `resolved` reach, or `undefined` when its view isn't
|
|
230
241
|
* narrowed, so it reads every object and nothing is read here. Else one read of the repo's packs,
|
|
231
|
-
* every ref
|
|
242
|
+
* every ref, its `index` row and its roots at one version, as `readOpened` makes for a narrowed
|
|
243
|
+
* view, and
|
|
232
244
|
* one lookup of them all beside `noObject`, so where an index covers the listing the lookup's reads
|
|
233
245
|
* are the same whichever of them the repo holds. Where none does, as with Git's reads by ID, an ID
|
|
234
246
|
* the repo holds walks the caller's history and a missing one doesn't, so the reads differ, and
|
|
@@ -244,11 +256,13 @@ const seenIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, oi
|
|
|
244
256
|
const { record, snapshot } = yield* readRecord(core.store, resolved.internalId, [
|
|
245
257
|
packsRead,
|
|
246
258
|
everyRef,
|
|
247
|
-
indexRowKey
|
|
259
|
+
indexRowKey,
|
|
260
|
+
repoRootsKey
|
|
248
261
|
]);
|
|
249
262
|
if (record === void 0 || record.deleted === true) return yield* fail("NOT_FOUND", `No repo '${resolved.name}'`);
|
|
250
|
-
const [, packRows = [], refRows = [], indexRows = []] = snapshot.results;
|
|
263
|
+
const [, packRows = [], refRows = [], indexRows = [], rootRows] = snapshot.results;
|
|
251
264
|
const packs = yield* decodePacks(packRows);
|
|
265
|
+
const roots = yield* rootsOf(rootRows);
|
|
252
266
|
const listed = {
|
|
253
267
|
repo: resolved.internalId,
|
|
254
268
|
version: snapshot.version,
|
|
@@ -258,7 +272,8 @@ const seenIn = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, oi
|
|
|
258
272
|
listed,
|
|
259
273
|
refs: yield* view.refs(refRows),
|
|
260
274
|
refRows,
|
|
261
|
-
index: indexRows[0]?.value
|
|
275
|
+
index: indexRows[0]?.value,
|
|
276
|
+
roots
|
|
262
277
|
};
|
|
263
278
|
const objects = yield* read({
|
|
264
279
|
view,
|
|
@@ -416,7 +431,7 @@ const readerOf = (opened, limits, reason) => Effect.map(deadlineOf(limits.millis
|
|
|
416
431
|
deadline
|
|
417
432
|
};
|
|
418
433
|
return {
|
|
419
|
-
reader: new DiffReader(readThrough(opened.read, deadline), limits.reads, call.tally),
|
|
434
|
+
reader: new DiffReader(readThrough(opened.read, deadline), limits.reads, call.tally, void 0, opened.roots),
|
|
420
435
|
deadline,
|
|
421
436
|
call
|
|
422
437
|
};
|
|
@@ -186,7 +186,7 @@ const treeCalls = (bound) => {
|
|
|
186
186
|
theirs
|
|
187
187
|
],
|
|
188
188
|
make: Effect.fnUntraced(function* (opened, made) {
|
|
189
|
-
const merged = yield* (yield* mergePartsOrOff).mergeTrees(opened.read, mergeInput(input), callAllot(opened));
|
|
189
|
+
const merged = yield* (yield* mergePartsOrOff).mergeTrees(opened.read, mergeInput(input), callAllot(opened), void 0, opened.roots);
|
|
190
190
|
yield* takeWrites(made, merged.objects);
|
|
191
191
|
const { renamesSkipped } = merged;
|
|
192
192
|
return renamesSkipped === void 0 ? { oid: merged.tree } : {
|
package/dist/core/parts.d.mts
CHANGED
|
@@ -8,6 +8,7 @@ import { HeldGrants } from "../auth/grants.mjs";
|
|
|
8
8
|
import { CursorSeal } from "../store/cursor-seal.mjs";
|
|
9
9
|
import { EventLog } from "../contracts/events.mjs";
|
|
10
10
|
import { HiddenRefs } from "../protocol/wire/lines.mjs";
|
|
11
|
+
import { IndexLost } from "./index-lost.mjs";
|
|
11
12
|
import { PushChecks } from "./access.mjs";
|
|
12
13
|
import { RefIndex } from "./ref-index.mjs";
|
|
13
14
|
import { SealedObjects } from "./view.mjs";
|
|
@@ -76,6 +77,12 @@ export interface CoreFields {
|
|
|
76
77
|
* objects keep no index, as `loose()`'s don't.
|
|
77
78
|
*/
|
|
78
79
|
readonly indexJobRow?: (round: number | 'deleted') => JobInput;
|
|
80
|
+
/**
|
|
81
|
+
* A read's ask for the rebuild of an `index` row whose files fail their own checks: the row's
|
|
82
|
+
* `git.index` round, added once a row while the server runs (`indexLostAsk`). None where the
|
|
83
|
+
* objects keep no index.
|
|
84
|
+
*/
|
|
85
|
+
readonly indexLost?: IndexLost;
|
|
79
86
|
/**
|
|
80
87
|
* The repo's `git.purge` row for its delete at `at` to save, due once a fetch begun before it has
|
|
81
88
|
* had its `fetchLimits` time, as a `leaving` row waits (Q265). None on a client, which runs no jobs.
|
package/dist/core/publish.mjs
CHANGED
|
@@ -38,9 +38,10 @@ const publishesRead = (ref, count, from, pattern) => gitError("NOT_ALLOWED", `Mo
|
|
|
38
38
|
const publishesUnread = (ref) => gitError("NOT_ALLOWED", `Moving ${shortRef(ref)} would publish commits you may not publish`, { hint: "Ask the repo's owner" });
|
|
39
39
|
/**
|
|
40
40
|
* The commits `tip` reaches that `audience` doesn't, read through `objects`: a walk from the tip
|
|
41
|
-
* down to the first commits the audience reaches, the push's own new commits among them
|
|
41
|
+
* down to the first commits the audience reaches, the push's own new commits among them, and
|
|
42
|
+
* through no parent of `roots`.
|
|
42
43
|
*/
|
|
43
|
-
const exposedFrom = /* @__PURE__ */ Effect.fnUntraced(function* (objects, listed, tip, audience, signal) {
|
|
44
|
+
const exposedFrom = /* @__PURE__ */ Effect.fnUntraced(function* (objects, listed, tip, audience, roots, signal) {
|
|
44
45
|
const call = signal === void 0 ? {} : { signal };
|
|
45
46
|
const exposed = [];
|
|
46
47
|
const passed = /* @__PURE__ */ new Set([tip]);
|
|
@@ -58,7 +59,7 @@ const exposedFrom = /* @__PURE__ */ Effect.fnUntraced(function* (objects, listed
|
|
|
58
59
|
for (const object of found) {
|
|
59
60
|
if (object === void 0) continue;
|
|
60
61
|
if (object.type === "commit") exposed.push(object.oid);
|
|
61
|
-
const steps = yield* stepsOf(object, false);
|
|
62
|
+
const steps = yield* stepsOf(object, false, roots);
|
|
62
63
|
for (const oid of onward(steps)) {
|
|
63
64
|
if (passed.has(oid)) continue;
|
|
64
65
|
passed.add(oid);
|
|
@@ -108,7 +109,10 @@ const unpublished = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
108
109
|
most: ancestryLimit,
|
|
109
110
|
commits: true
|
|
110
111
|
};
|
|
111
|
-
const walkOf = (tips) => walkedVisible(input.objects, input.listed, {
|
|
112
|
+
const walkOf = (tips) => walkedVisible(input.objects, input.listed, {
|
|
113
|
+
tips,
|
|
114
|
+
roots: input.roots
|
|
115
|
+
}, bound);
|
|
112
116
|
const reach = (tips) => input.visible === void 0 ? walkOf(tips) : input.visible(tips, () => walkOf(tips));
|
|
113
117
|
const named = [...refs].toSorted(([one], [other]) => one < other ? -1 : 1);
|
|
114
118
|
const tipsOf = (keep) => named.flatMap(([ref, oid]) => keep(access.patternOf(ref)) ? [oid] : []);
|
|
@@ -123,7 +127,7 @@ const unpublished = /* @__PURE__ */ Effect.fnUntraced(function* (input) {
|
|
|
123
127
|
const own = access.patternOf(edit.ref);
|
|
124
128
|
const audience = audiences.get(own) ?? reach(tipsOf((one) => one === void 0 || one === own));
|
|
125
129
|
audiences.set(own, audience);
|
|
126
|
-
let left = yield* exposedFrom(input.pushed, input.pushedListed, to, audience, input.signal);
|
|
130
|
+
let left = yield* exposedFrom(input.pushed, input.pushedListed, to, audience, input.roots, input.signal);
|
|
127
131
|
for (const [pattern, set] of walked) {
|
|
128
132
|
if (left.length === 0) break;
|
|
129
133
|
if (pattern === own || !publishable(refView, pattern)) continue;
|
package/dist/core/purge.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { forkedFrom, reconcile, releaseHold } from "../store/catalogue.mjs";
|
|
|
5
5
|
import { storeCall } from "../store/errors.mjs";
|
|
6
6
|
import { gitJob, repoTry } from "../store/job-try.mjs";
|
|
7
7
|
import { outboxCollections } from "../store/outbox.mjs";
|
|
8
|
+
import { keyKept } from "../store/records.mjs";
|
|
8
9
|
import { readRecord } from "../store/repo-record.mjs";
|
|
9
10
|
import { collections, newChangeId, repoScope } from "../store/scopes.mjs";
|
|
10
11
|
import { isDeliverJob, sentThrough } from "./events/deliver.mjs";
|
|
@@ -216,7 +217,8 @@ const dropScopes = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
216
217
|
});
|
|
217
218
|
/**
|
|
218
219
|
* One step in the repo's scope: none for a repo that isn't deleted. It waits until its delete's
|
|
219
|
-
* `fetchLimits` has passed,
|
|
220
|
+
* `fetchLimits` has passed, nor while a receipt it holds still answers, `keyKept` past the delete;
|
|
221
|
+
* then while a drain job or a drained row stands, or a fork holds the
|
|
220
222
|
* repo, each wait till its own time to look again; else each part's step, then a page of
|
|
221
223
|
* `purgeCollections`, then the fork's hold on its source, then the record, then the drops. A repo
|
|
222
224
|
* with no record is one whose record this purge deleted, since only a delete queues it: its
|
|
@@ -228,7 +230,11 @@ const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, int
|
|
|
228
230
|
collection,
|
|
229
231
|
limit: 1
|
|
230
232
|
}));
|
|
231
|
-
const
|
|
233
|
+
const receiptRead = {
|
|
234
|
+
collection: collections.receiptIndex,
|
|
235
|
+
limit: 1
|
|
236
|
+
};
|
|
237
|
+
const { record, snapshot } = yield* readRecord(store, internalId, [...drainedReads, receiptRead]);
|
|
232
238
|
if (record === void 0) return yield* dropScopes(parts, store, internalId);
|
|
233
239
|
if (record.deleted !== true) return void 0;
|
|
234
240
|
const at = yield* parts.now;
|
|
@@ -237,6 +243,13 @@ const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, int
|
|
|
237
243
|
...again,
|
|
238
244
|
at: guard
|
|
239
245
|
};
|
|
246
|
+
const drained = snapshot.results.slice(1, 1 + drainedReads.length);
|
|
247
|
+
const receipts = snapshot.results[1 + drainedReads.length] ?? [];
|
|
248
|
+
const answering = record.changedAt + keyKept;
|
|
249
|
+
if (receipts.length > 0 && at < answering) return {
|
|
250
|
+
...again,
|
|
251
|
+
at: answering
|
|
252
|
+
};
|
|
240
253
|
const backstop = {
|
|
241
254
|
...again,
|
|
242
255
|
at: at + purgeBackstop
|
|
@@ -247,7 +260,7 @@ const purgeStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, int
|
|
|
247
260
|
...again,
|
|
248
261
|
at: drain
|
|
249
262
|
};
|
|
250
|
-
if (
|
|
263
|
+
if (drained.some((rows) => rows.length > 0)) return backstop;
|
|
251
264
|
if (yield* forkedFrom(store, internalId)) return backstop;
|
|
252
265
|
for (const part of parts.parts) {
|
|
253
266
|
const step = yield* part(store, internalId);
|
package/dist/core/push.mjs
CHANGED
|
@@ -27,11 +27,11 @@ import { appendEvents, decodeOutbox, firstSeq, outboxReads, repoEnvelope } from
|
|
|
27
27
|
import { rowsAtCommit } from "./loose-tally.mjs";
|
|
28
28
|
import { MirrorRow } from "./mirror-rows.mjs";
|
|
29
29
|
import { PrunedMark, mirrorJobName } from "../store/records.mjs";
|
|
30
|
-
import { decodeStats, looseRows, readRecord, repoStats, timeRow } from "../store/repo-record.mjs";
|
|
30
|
+
import { decodeStats, looseRows, readRecord, repoStats, rootsOf, timeRow } from "../store/repo-record.mjs";
|
|
31
31
|
import { advanceRow } from "../store/queue-jobs.mjs";
|
|
32
32
|
import { liveReservations, reservedTarget } from "../store/reservations.mjs";
|
|
33
33
|
import { settleName } from "../store/settle.mjs";
|
|
34
|
-
import { collections, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoScope } from "../store/scopes.mjs";
|
|
34
|
+
import { collections, newChangeId, prunedKey, pushedKey, pushedUnder, reachedKey, repoRootsKey, repoScope } from "../store/scopes.mjs";
|
|
35
35
|
import { headOf, indexJobs, openKeyed, openRepo, refIndexJobs, repoAccess } from "./access.mjs";
|
|
36
36
|
import { kindsOf } from "./ancestry.mjs";
|
|
37
37
|
import { isRefName } from "./names.mjs";
|
|
@@ -197,12 +197,20 @@ const markOf = (rows) => {
|
|
|
197
197
|
const firstRead = (caller, operation, internalId) => openRepo(caller, {
|
|
198
198
|
kind: "read",
|
|
199
199
|
repo: operation.repo
|
|
200
|
-
}, [
|
|
200
|
+
}, [
|
|
201
|
+
packsRead,
|
|
202
|
+
prunedKey,
|
|
203
|
+
repoRootsKey
|
|
204
|
+
], internalId, "skip");
|
|
201
205
|
/** `firstRead` for a keyed push: `undefined` once `missed`'s repo moved, as `openKeyed` says. */
|
|
202
206
|
const keyedRead = (caller, operation, missed, internalId) => openKeyed(caller, {
|
|
203
207
|
kind: "read",
|
|
204
208
|
repo: operation.repo
|
|
205
|
-
}, [
|
|
209
|
+
}, [
|
|
210
|
+
packsRead,
|
|
211
|
+
prunedKey,
|
|
212
|
+
repoRootsKey
|
|
213
|
+
], missed, internalId, "skip");
|
|
206
214
|
/**
|
|
207
215
|
* The first read's repo once `authorize` lets the caller push to it: its list, for the pack to be
|
|
208
216
|
* received against, its default branch, whose move rebuilds the ready shallow pack, and its
|
|
@@ -223,12 +231,14 @@ const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operatio
|
|
|
223
231
|
packs
|
|
224
232
|
};
|
|
225
233
|
const mark = yield* markOf(resolved.snapshot.results[2] ?? []);
|
|
234
|
+
const roots = yield* rootsOf(resolved.snapshot.results[3]);
|
|
226
235
|
const views = yield* Effect.forEach(decidingFor(request), (one) => viewOf(one, resolved, request.as));
|
|
227
236
|
const [view = yield* viewOf(caller, resolved, request.as)] = views;
|
|
228
237
|
return {
|
|
229
238
|
listed,
|
|
230
239
|
defaultBranch: headOf(resolved.record.defaultBranch),
|
|
231
240
|
mark,
|
|
241
|
+
roots,
|
|
232
242
|
repo,
|
|
233
243
|
view,
|
|
234
244
|
views
|
|
@@ -238,13 +248,15 @@ const listedFor = /* @__PURE__ */ Effect.fnUntraced(function* (request, operatio
|
|
|
238
248
|
* The refs a push's objects follow, for its view: none read when the view's objects are whole, as
|
|
239
249
|
* for a caller who sees every ref of a repo that isn't a fork under `access`; else every ref the
|
|
240
250
|
* caller sees, read after `authorize` let the caller in, at a version of their own, which the
|
|
241
|
-
* push's objects read at too.
|
|
251
|
+
* push's objects read at too. `roots` are the first read's: only an import's landing writes them,
|
|
252
|
+
* before any ref moves.
|
|
242
253
|
*/
|
|
243
|
-
const seenRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (view, listed) {
|
|
254
|
+
const seenRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (view, listed, roots) {
|
|
244
255
|
const core = yield* CoreParts;
|
|
245
256
|
if (!(yield* view.narrowed)) return {
|
|
246
257
|
listed,
|
|
247
|
-
refs: /* @__PURE__ */ new Map()
|
|
258
|
+
refs: /* @__PURE__ */ new Map(),
|
|
259
|
+
roots
|
|
248
260
|
};
|
|
249
261
|
const { snapshot } = yield* readRecord(core.store, listed.repo, [
|
|
250
262
|
refsRead,
|
|
@@ -261,7 +273,8 @@ const seenRefsOf = /* @__PURE__ */ Effect.fnUntraced(function* (view, listed) {
|
|
|
261
273
|
packs
|
|
262
274
|
},
|
|
263
275
|
refs,
|
|
264
|
-
index: indexRows[0]?.value
|
|
276
|
+
index: indexRows[0]?.value,
|
|
277
|
+
roots
|
|
265
278
|
};
|
|
266
279
|
});
|
|
267
280
|
/**
|
|
@@ -826,14 +839,14 @@ const lists = (body, pack) => body.delete.some((key) => key.collection === objec
|
|
|
826
839
|
* only, refused as the commit would be, its `writes` or none, and answered before it, for
|
|
827
840
|
* `checkPush`: nothing before that point writes, reserves or enqueues, with no pack.
|
|
828
841
|
*/
|
|
829
|
-
const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, view, views }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
|
|
842
|
+
const pushOnto = (request, { listed, defaultBranch, mark, roots, repo: checkedRepo, view, views }, key, answers, checking = false) => Effect.scoped(Effect.gen(function* () {
|
|
830
843
|
const core = yield* CoreParts;
|
|
831
844
|
const { objects: sealed } = yield* ObjectsParts;
|
|
832
845
|
const authorize = yield* Authorize;
|
|
833
846
|
const { store } = core;
|
|
834
847
|
const { caller, repo, signal } = request;
|
|
835
848
|
const call = signal === void 0 ? {} : { signal };
|
|
836
|
-
const seen = yield* seenRefsOf(view, listed);
|
|
849
|
+
const seen = yield* seenRefsOf(view, listed, roots);
|
|
837
850
|
const { received, rooted } = yield* receive(yield* read({
|
|
838
851
|
view,
|
|
839
852
|
at: seen
|
|
@@ -863,6 +876,7 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
863
876
|
listed: pushedListed,
|
|
864
877
|
pushed,
|
|
865
878
|
edits: request.edits,
|
|
879
|
+
roots,
|
|
866
880
|
...call
|
|
867
881
|
};
|
|
868
882
|
if (rooted !== void 0) kindsInput.missing = rooted;
|
|
@@ -901,9 +915,11 @@ const pushOnto = (request, { listed, defaultBranch, mark, repo: checkedRepo, vie
|
|
|
901
915
|
refs: publishedRefs(refs),
|
|
902
916
|
objects: whole,
|
|
903
917
|
listed: at,
|
|
918
|
+
roots,
|
|
904
919
|
visible: (tips, fallback) => SealedObjects.visibleWhole(sealed, pushWhole, at, {
|
|
905
920
|
tips,
|
|
906
|
-
row: index?.value
|
|
921
|
+
row: index?.value,
|
|
922
|
+
roots
|
|
907
923
|
}, fallback),
|
|
908
924
|
pushed: wholePushed,
|
|
909
925
|
pushedListed: withReceived(at, received),
|
package/dist/core/repack.mjs
CHANGED
|
@@ -35,10 +35,10 @@ const upkeepWhole = /* @__PURE__ */ WholeRepo.mint();
|
|
|
35
35
|
* `upkeeps` as one, in order: the first that did some answers `more`, so a step stays short;
|
|
36
36
|
* else the soonest any is due.
|
|
37
37
|
*/
|
|
38
|
-
const upkeepsOf = (upkeeps) => Effect.fnUntraced(function* (store, repo, at) {
|
|
38
|
+
const upkeepsOf = (upkeeps) => Effect.fnUntraced(function* (store, repo, at, deleted) {
|
|
39
39
|
let due;
|
|
40
40
|
for (const upkeep of upkeeps) {
|
|
41
|
-
const step = yield* upkeep(store, repo, at);
|
|
41
|
+
const step = yield* upkeep(store, repo, at, deleted);
|
|
42
42
|
if (step.more) return step;
|
|
43
43
|
if (step.due !== void 0) due = due === void 0 ? step.due : Math.min(due, step.due);
|
|
44
44
|
}
|
|
@@ -98,23 +98,44 @@ const packsAfter = (packs, change) => {
|
|
|
98
98
|
added: sizeOf(added)
|
|
99
99
|
};
|
|
100
100
|
};
|
|
101
|
+
/** `repo.work.failed` for a prune pass that pushes have kept waiting `periods` periods in a row. */
|
|
102
|
+
const busyEvent = (repo, periods) => ({
|
|
103
|
+
type: "repo.work.failed",
|
|
104
|
+
...repoEnvelope(void 0, repo),
|
|
105
|
+
name: "git.repack",
|
|
106
|
+
key: "prune",
|
|
107
|
+
refused: "busy",
|
|
108
|
+
periods,
|
|
109
|
+
error: `Pushes undid every prune pass for ${periods} periods; unreachable objects stay until a quiet period`
|
|
110
|
+
});
|
|
101
111
|
/**
|
|
102
112
|
* The rows a step adds to its commit to report its run: the run's row while it goes on, and at
|
|
103
|
-
* its last step the row deleted and `repo.maintained`, unless the run changed nothing.
|
|
113
|
+
* its last step the row deleted and `repo.maintained`, unless the run changed nothing. A step
|
|
114
|
+
* that writes the prune pass's wait for pushes, `prunePeriodsMost` periods in a row or more, sends
|
|
115
|
+
* `repo.work.failed` with `refused: 'busy'`, whichever step it is.
|
|
104
116
|
*/
|
|
105
117
|
const reportRun = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read, run, after, step) {
|
|
106
118
|
const added = run.added + after.added;
|
|
107
|
-
|
|
108
|
-
|
|
119
|
+
const busy = step.busy !== void 0 && step.busy >= 3 ? [busyEvent(read.name, step.busy)] : [];
|
|
120
|
+
if (!step.last) {
|
|
121
|
+
const put = after.added === 0 && step.saved ? [] : [{
|
|
109
122
|
...maintenanceRunKey,
|
|
110
123
|
value: {
|
|
111
124
|
...run,
|
|
112
125
|
added
|
|
113
126
|
}
|
|
114
|
-
}]
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
127
|
+
}];
|
|
128
|
+
const told = yield* appendEvents(parts.events, read.outbox, busy, {
|
|
129
|
+
scope: read.scope,
|
|
130
|
+
at: step.at,
|
|
131
|
+
exempt: true
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
put: [...put, ...told.put],
|
|
135
|
+
delete: told.delete,
|
|
136
|
+
jobs: told.jobs
|
|
137
|
+
};
|
|
138
|
+
}
|
|
118
139
|
const removed = step.saved ? [maintenanceRunKey] : [];
|
|
119
140
|
const { fenced } = step;
|
|
120
141
|
const changed = added > 0 || run.packs !== after.packs || run.bytes !== after.bytes || fenced.length > 0;
|
|
@@ -135,7 +156,7 @@ const reportRun = /* @__PURE__ */ Effect.fnUntraced(function* (parts, read, run,
|
|
|
135
156
|
...report,
|
|
136
157
|
fenced
|
|
137
158
|
} : report;
|
|
138
|
-
const appended = yield* appendEvents(parts.events, read.outbox, changed ? [maintained] : [], {
|
|
159
|
+
const appended = yield* appendEvents(parts.events, read.outbox, [...busy, ...changed ? [maintained] : []], {
|
|
139
160
|
scope: read.scope,
|
|
140
161
|
at: step.at,
|
|
141
162
|
exempt: true
|
|
@@ -268,7 +289,7 @@ const readStep = /* @__PURE__ */ Effect.fnUntraced(function* (store, internalId,
|
|
|
268
289
|
const [runRow] = runRows;
|
|
269
290
|
const saved = runRow === void 0 ? void 0 : yield* decodeRow(MaintenanceRun, runRow, "The repack run");
|
|
270
291
|
const deleted = record.deleted === true;
|
|
271
|
-
const sweep = (at) => bothSwept(sweepOf(receipts, at), ownSweepOf(own, at,
|
|
292
|
+
const sweep = (at) => deleted ? ownSweepOf(own, at, true) : bothSwept(sweepOf(receipts, at), ownSweepOf(own, at, false));
|
|
272
293
|
const [index] = indexRows;
|
|
273
294
|
const [apartRow] = apartRows;
|
|
274
295
|
const apart = apartRow === void 0 ? void 0 : yield* decodeRow(ApartRow, apartRow, "The packs found apart");
|
|
@@ -334,7 +355,8 @@ const commitStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
334
355
|
last: step?.more !== true,
|
|
335
356
|
saved: read.saved !== void 0,
|
|
336
357
|
at,
|
|
337
|
-
fenced
|
|
358
|
+
fenced,
|
|
359
|
+
busy: step?.busy
|
|
338
360
|
});
|
|
339
361
|
const mark = step?.drops === true ? [{
|
|
340
362
|
...prunedKey,
|
|
@@ -443,7 +465,7 @@ const reviveParked = /* @__PURE__ */ Effect.fnUntraced(function* (store, interna
|
|
|
443
465
|
* objects for a step, with the default branch's tip and the tags, and commits its change at that
|
|
444
466
|
* version, fenced by the try's claim, as `commitStep` says. After `dropTries` or more `missed`
|
|
445
467
|
* dropping commits in a row, it asks for a step that drops none. A deleted repo's step, once no page
|
|
446
|
-
* of its
|
|
468
|
+
* of its own writes is left to sweep now, moves its packs out of the list, a page at a time, and asks the objects
|
|
447
469
|
* nothing until none are listed; then, with no tip and no tags, its ready shallow pack is let go.
|
|
448
470
|
* A step that finds the version moved reads again, up to `writeTries` times, the rows
|
|
449
471
|
* `rereadKeys` names, and commits at the new version while `stillTakes` holds: a step with its
|
|
@@ -471,7 +493,7 @@ const repackStep = /* @__PURE__ */ Effect.fnUntraced(function* (parts, store, in
|
|
|
471
493
|
if (steps === "prune" && first.record.deleted === true) return void 0;
|
|
472
494
|
if (yield* settles(parts, store, internalId, first)) return again;
|
|
473
495
|
const at = yield* parts.now;
|
|
474
|
-
const upkept = parts.upkeep === void 0 || steps === "prune" ? void 0 : yield* untilAborted(parts.upkeep(store, internalId, at), signal);
|
|
496
|
+
const upkept = parts.upkeep === void 0 || steps === "prune" ? void 0 : yield* untilAborted(parts.upkeep(store, internalId, at, first.record.deleted === true), signal);
|
|
475
497
|
if (upkept?.more === true) return again;
|
|
476
498
|
const listed = {
|
|
477
499
|
repo: internalId,
|
package/dist/core/view.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import "../contracts/actors.mjs";
|
|
|
3
3
|
import { Oid, RefName } from "../contracts/ids.mjs";
|
|
4
4
|
import "../contracts/git.mjs";
|
|
5
5
|
import "../contracts/repos.mjs";
|
|
6
|
+
import { RepoRoots } from "../protocol/objects/commit.mjs";
|
|
6
7
|
import { GitObjects, IndexCalls, IndexedObjects, Quarantine, VisibleInput, VisibleSet } from "../contracts/objects.mjs";
|
|
7
8
|
import { Listed } from "../contracts/store.mjs";
|
|
8
9
|
import { GitError } from "../contracts/result.mjs";
|
|
@@ -94,7 +95,10 @@ export interface RepoView {
|
|
|
94
95
|
*/
|
|
95
96
|
readonly narrowed: Effect.Effect<boolean, GitError>;
|
|
96
97
|
}
|
|
97
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* One read of a repo, which a view's objects follow: its listing, its refs, its `index` row and its
|
|
100
|
+
* roots.
|
|
101
|
+
*/
|
|
98
102
|
export interface ViewRead {
|
|
99
103
|
readonly listed: Listed;
|
|
100
104
|
/** What `RepoView.refs` answered for the same read. */
|
|
@@ -103,6 +107,11 @@ export interface ViewRead {
|
|
|
103
107
|
readonly refRows?: readonly Row[];
|
|
104
108
|
/** The repo's `index` row's value, read with the refs. */
|
|
105
109
|
readonly index?: unknown;
|
|
110
|
+
/**
|
|
111
|
+
* The repo's roots, from the open's read: a narrowed view's set follows none's parents, so a
|
|
112
|
+
* commit only a root's stored parent reaches answers as one the repo lacks.
|
|
113
|
+
*/
|
|
114
|
+
readonly roots: RepoRoots;
|
|
106
115
|
/** A push's own receive, whose packs the caller sent: their objects are read too. */
|
|
107
116
|
readonly pushed?: Quarantine;
|
|
108
117
|
}
|
package/dist/core/view.mjs
CHANGED
|
@@ -4,6 +4,8 @@ import { upstreamOf } from "../store/catalogue.mjs";
|
|
|
4
4
|
import { collections } from "../store/scopes.mjs";
|
|
5
5
|
import { answeredBy, effectWithin, objectsFace, scopedReader } from "../storage/calls.mjs";
|
|
6
6
|
import { callScope, inCallScope } from "../store/call-count.mjs";
|
|
7
|
+
import { askingOnLost } from "../storage/index-visible.mjs";
|
|
8
|
+
import { indexRowKey } from "../storage/layout.mjs";
|
|
7
9
|
import { withPushed } from "../storage/visible.mjs";
|
|
8
10
|
import { WholeRepo, storedPeel, storesPeel, wholeRefs } from "../store/ref-rows.mjs";
|
|
9
11
|
import { openRepo, repoAccess } from "./access.mjs";
|
|
@@ -213,10 +215,16 @@ const viewOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, ow
|
|
|
213
215
|
const peeled = row === void 0 ? void 0 : yield* storedPeel(row);
|
|
214
216
|
if (peeled !== void 0) ordered.push(peeled);
|
|
215
217
|
}
|
|
216
|
-
const
|
|
218
|
+
const lost = core.indexLost === void 0 || at.index === void 0 ? void 0 : core.indexLost(resolved.internalId, {
|
|
219
|
+
...indexRowKey,
|
|
220
|
+
value: at.index
|
|
221
|
+
}, at.listed);
|
|
222
|
+
const asking = (input) => lost === void 0 ? input : askingOnLost(input, lost);
|
|
223
|
+
const tips = asking({
|
|
217
224
|
tips: [...new Set(ordered)],
|
|
218
|
-
row: at.index
|
|
219
|
-
|
|
225
|
+
row: at.index,
|
|
226
|
+
roots: at.roots
|
|
227
|
+
});
|
|
220
228
|
const read = at.pushed === void 0 ? `${at.listed.version}` : `${at.listed.version}+${at.pushed.id}`;
|
|
221
229
|
const reach = options.ownWrites === false ? `${read}:refs` : read;
|
|
222
230
|
const key = owner === void 0 ? reach : `${reach}:${owner.prefix}`;
|
|
@@ -240,10 +248,11 @@ const viewOf = /* @__PURE__ */ Effect.fnUntraced(function* (caller, resolved, ow
|
|
|
240
248
|
const above = yield* parentTips(caller, resolved);
|
|
241
249
|
const both = [.../* @__PURE__ */ new Set([...tips.tips, ...above])];
|
|
242
250
|
if (both.length === tips.tips.length) return void 0;
|
|
243
|
-
const asked = {
|
|
251
|
+
const asked = asking({
|
|
244
252
|
tips: both,
|
|
245
|
-
row: at.index
|
|
246
|
-
|
|
253
|
+
row: at.index,
|
|
254
|
+
roots: at.roots
|
|
255
|
+
});
|
|
247
256
|
let parted;
|
|
248
257
|
const part = (pick) => () => {
|
|
249
258
|
parted ??= SealedObjects.parted(sealed, viewWhole, at.listed, asked, at.pushed);
|
package/dist/effect.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { EffectCalls, GitCaller, GitStore } from "./contracts/services.mjs";
|
|
2
2
|
import { IndexCalls, IndexReachInput, IndexReached, IndexStatus, IndexTip, IndexTry, IndexTryInput } from "./contracts/objects.mjs";
|
|
3
3
|
import { CallAllowance, CallBudget, CallBudgetOptions } from "./store/call-count.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { storeCall } from "./store/errors.mjs";
|
|
4
|
+
import { commitCallsMost, storeCall } from "./store/errors.mjs";
|
|
6
5
|
import { bucketCall } from "./storage/calls.mjs";
|
|
7
6
|
import { GitRestApi } from "./rest/api.mjs";
|
|
8
7
|
import { GitCallerMiddleware, GitRestServices, RestServerSeam } from "./rest/caller.mjs";
|
|
@@ -14,4 +13,4 @@ import { ReposApiGroup } from "./rest/repos.mjs";
|
|
|
14
13
|
import { TokensApiGroup } from "./rest/tokens.mjs";
|
|
15
14
|
import { WorkApiGroup } from "./rest/work.mjs";
|
|
16
15
|
import { SeamAuthorizeInput, TokenRevokeCheck } from "./core/seam.mjs";
|
|
17
|
-
export { type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, MeApiGroup, RefsApiGroup, ReposApiGroup, type RestServerSeam, type SeamAuthorizeInput, type TokenRevokeCheck, TokensApiGroup, WorkApiGroup, bucketCall,
|
|
16
|
+
export { type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, MeApiGroup, RefsApiGroup, ReposApiGroup, type RestServerSeam, type SeamAuthorizeInput, type TokenRevokeCheck, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
|
package/dist/effect.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GitCaller, GitStore } from "./contracts/services.mjs";
|
|
2
2
|
import { CallBudget } from "./store/call-count.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { storeCall } from "./store/errors.mjs";
|
|
3
|
+
import { commitCallsMost, storeCall } from "./store/errors.mjs";
|
|
5
4
|
import { bucketCall } from "./storage/calls.mjs";
|
|
6
5
|
import { GitRestApi } from "./rest/api.mjs";
|
|
7
6
|
import { GitCallerMiddleware, GitRestServices } from "./rest/caller.mjs";
|
|
@@ -12,4 +11,4 @@ import { RefsApiGroup } from "./rest/refs.mjs";
|
|
|
12
11
|
import { ReposApiGroup } from "./rest/repos.mjs";
|
|
13
12
|
import { TokensApiGroup } from "./rest/tokens.mjs";
|
|
14
13
|
import { WorkApiGroup } from "./rest/work.mjs";
|
|
15
|
-
export { CallBudget, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, MeApiGroup, RefsApiGroup, ReposApiGroup, TokensApiGroup, WorkApiGroup, bucketCall,
|
|
14
|
+
export { CallBudget, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, MeApiGroup, RefsApiGroup, ReposApiGroup, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
|
package/dist/engine/commits.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fail } from "../contracts/result.mjs";
|
|
2
2
|
import { drained } from "../protocol/diff/read.mjs";
|
|
3
|
-
import { decodeCommit } from "../protocol/objects/commit.mjs";
|
|
3
|
+
import { decodeCommit, parentsWithin } from "../protocol/objects/commit.mjs";
|
|
4
4
|
import { decodeTag } from "../protocol/objects/tag.mjs";
|
|
5
5
|
import { fromDiff } from "./failures.mjs";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
@@ -11,14 +11,15 @@ const unreadable = (oid, decoded) => Effect.catch(decoded, (error) => fail("DATA
|
|
|
11
11
|
/**
|
|
12
12
|
* A commit decoded from `bytes`, which the reader charged already, its subject charged too: a
|
|
13
13
|
* string beside the message, two bytes a character at most, which a walk holds as long as the
|
|
14
|
-
* commit.
|
|
14
|
+
* commit. One of the reader's roots has no parents, so no walk reads past it.
|
|
15
15
|
*/
|
|
16
16
|
const decodedAt = /* @__PURE__ */ Effect.fnUntraced(function* (reader, oid, bytes) {
|
|
17
17
|
const commit = yield* unreadable(oid, decodeCommit(bytes));
|
|
18
18
|
yield* Effect.mapError(reader.charge(commit.subject.length * 2), asWalk);
|
|
19
19
|
return {
|
|
20
20
|
oid,
|
|
21
|
-
...commit
|
|
21
|
+
...commit,
|
|
22
|
+
parents: parentsWithin(reader.roots, oid, commit.parents)
|
|
22
23
|
};
|
|
23
24
|
});
|
|
24
25
|
/** A parent, or a commit a walk reaches: a commit, or `DATA_LOSS`. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fail } from "../contracts/result.mjs";
|
|
2
2
|
import { DiffReader } from "../protocol/diff/read.mjs";
|
|
3
|
+
import { noRepoRoots } from "../protocol/objects/commit.mjs";
|
|
3
4
|
import { namedCommit, walkedThrough } from "./commits.mjs";
|
|
4
5
|
import { mergeBasesOf } from "./merge-base-walk.mjs";
|
|
5
6
|
import { limitsOf, readThrough, stepDeadline, timed } from "./reads.mjs";
|
|
@@ -9,15 +10,16 @@ import * as Effect from "effect/Effect";
|
|
|
9
10
|
* `merge-base --all <first> <rest>...`: the best common ancestors of the first commit and any of
|
|
10
11
|
* the rest, newest first, or none for unrelated histories. Each commit named is peeled through
|
|
11
12
|
* its tags. The walk reads each commit as it reaches it, within the call's limits, and stops at
|
|
12
|
-
* the bases, so a deep history below them is never read
|
|
13
|
+
* the bases, so a deep history below them is never read, and at each of `roots`, which reads with
|
|
14
|
+
* no parents.
|
|
13
15
|
*/
|
|
14
|
-
const mergeBases = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, call) {
|
|
16
|
+
const mergeBases = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, call, roots = noRepoRoots) {
|
|
15
17
|
const limits = yield* limitsOf(input.limits);
|
|
16
18
|
const [first, ...rest] = input.commits;
|
|
17
19
|
if (first === void 0 || rest.length === 0) return yield* fail("INVALID_ARGUMENT", "A merge base needs two commits or more");
|
|
18
20
|
const deadline = yield* stepDeadline(limits.milliseconds, "walk-limit", call);
|
|
19
21
|
const run = Effect.gen(function* () {
|
|
20
|
-
const reader = new DiffReader(readThrough(read, deadline), limits.reads, call?.tally);
|
|
22
|
+
const reader = new DiffReader(readThrough(read, deadline), limits.reads, call?.tally, void 0, roots);
|
|
21
23
|
const one = yield* namedCommit(reader, first);
|
|
22
24
|
const twos = yield* Effect.forEach(rest, (oid) => namedCommit(reader, oid));
|
|
23
25
|
const commits = walkedThrough(reader, [one, ...twos]);
|