amalgm 0.1.212 → 0.1.213
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/package.json
CHANGED
|
@@ -33,6 +33,7 @@ const {
|
|
|
33
33
|
checkpointValueReady,
|
|
34
34
|
readCheckpointValue,
|
|
35
35
|
revisionOf,
|
|
36
|
+
sameTransition,
|
|
36
37
|
} = require('../workspace/checkpoint');
|
|
37
38
|
|
|
38
39
|
test.after(() => {
|
|
@@ -241,3 +242,31 @@ test('a clean losing commit travels as parked metadata on a no-op checkpoint', (
|
|
|
241
242
|
assert.deepEqual(checkpoint.to, sharedValue);
|
|
242
243
|
assert.deepEqual(checkpoint.parked, parked);
|
|
243
244
|
});
|
|
245
|
+
|
|
246
|
+
test('a server rail number does not turn the same parked checkpoint into new work', () => {
|
|
247
|
+
const value = { revision: null, indexDiff: '', worktreeDiff: '' };
|
|
248
|
+
const checkpoint = {
|
|
249
|
+
branch: 'main',
|
|
250
|
+
baseOid: 'a'.repeat(40),
|
|
251
|
+
from: value,
|
|
252
|
+
to: value,
|
|
253
|
+
parked: [{
|
|
254
|
+
oid: 'b'.repeat(40),
|
|
255
|
+
ref: `refs/amalgm/parked/${'b'.repeat(40)}`,
|
|
256
|
+
objects: { kind: 'bundle', checksum: 'c'.repeat(64) },
|
|
257
|
+
version: 12,
|
|
258
|
+
}],
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
assert.equal(sameTransition(checkpoint, {
|
|
262
|
+
...checkpoint,
|
|
263
|
+
parked: checkpoint.parked.map((entry) => ({ ...entry, version: 37 })),
|
|
264
|
+
}), true);
|
|
265
|
+
assert.equal(sameTransition(checkpoint, {
|
|
266
|
+
...checkpoint,
|
|
267
|
+
parked: checkpoint.parked.map((entry) => ({
|
|
268
|
+
...entry,
|
|
269
|
+
objects: { ...entry.objects, checksum: 'd'.repeat(64) },
|
|
270
|
+
})),
|
|
271
|
+
}), false);
|
|
272
|
+
});
|
|
@@ -96,13 +96,21 @@ function valueIdentity(value) {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
function parkedIdentity(parked) {
|
|
100
|
+
return JSON.stringify((parked || []).map((entry) => {
|
|
101
|
+
const stable = { ...entry };
|
|
102
|
+
delete stable.version;
|
|
103
|
+
return stable;
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
|
|
99
107
|
function sameTransition(left, right) {
|
|
100
108
|
return left
|
|
101
109
|
&& left.baseOid === right.baseOid
|
|
102
110
|
&& left.branch === right.branch
|
|
103
111
|
&& valueIdentity(left.from) === valueIdentity(right.from)
|
|
104
112
|
&& valueIdentity(left.to) === valueIdentity(right.to)
|
|
105
|
-
&&
|
|
113
|
+
&& parkedIdentity(left.parked) === parkedIdentity(right.parked);
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
function checkpointValue(machine, repoKey, baseOid, indexDiff, worktreeDiff) {
|
|
@@ -397,6 +405,7 @@ module.exports = {
|
|
|
397
405
|
readCheckpointValue,
|
|
398
406
|
repoKeyOfCard,
|
|
399
407
|
revisionOf,
|
|
408
|
+
sameTransition,
|
|
400
409
|
startCheckpointService,
|
|
401
410
|
stopCheckpointService,
|
|
402
411
|
};
|
|
@@ -17,7 +17,7 @@ const { AMALGM_DIR } = require('../config');
|
|
|
17
17
|
const { subscribeStateEvents } = require('../state/events');
|
|
18
18
|
const { machineId, userId } = require('./identity');
|
|
19
19
|
const { listRepoCards } = require('./cards');
|
|
20
|
-
const { readCheckpoint, repoKeyOfCard } = require('./checkpoint');
|
|
20
|
+
const { readCheckpoint, repoKeyOfCard, sameTransition } = require('./checkpoint');
|
|
21
21
|
|
|
22
22
|
const WALL_CONTRACT = 'code-project@3';
|
|
23
23
|
const PROJECT_DIR = path.join(AMALGM_DIR, 'state', 'code-projects');
|
|
@@ -209,17 +209,6 @@ function samePosition(left, right) {
|
|
|
209
209
|
&& Boolean(left?.head?.detached) === Boolean(right?.head?.detached);
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
function checkpointIdentity(checkpoint) {
|
|
213
|
-
if (!checkpoint) return null;
|
|
214
|
-
return JSON.stringify({
|
|
215
|
-
baseOid: checkpoint.baseOid,
|
|
216
|
-
branch: checkpoint.branch,
|
|
217
|
-
from: checkpoint.from,
|
|
218
|
-
to: checkpoint.to,
|
|
219
|
-
parked: checkpoint.parked || [],
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
|
|
223
212
|
function oidMap(refs) {
|
|
224
213
|
return new Map((refs || []).map((ref) => [ref.name, ref.oid ?? null]));
|
|
225
214
|
}
|
|
@@ -278,7 +267,7 @@ function hasLocalContribution(card, plan, baseline, checkpoint = null, previousC
|
|
|
278
267
|
const latest = [...(plan.transitions || [])]
|
|
279
268
|
.reverse()
|
|
280
269
|
.find((entry) => entry.machine === checkpoint.machine);
|
|
281
|
-
if (
|
|
270
|
+
if (!sameTransition(latest, checkpoint)) return true;
|
|
282
271
|
}
|
|
283
272
|
return false;
|
|
284
273
|
}
|
|
@@ -444,7 +433,7 @@ function stampCards(cards, previousCards, sharedPlan, baseline, mutationId, proj
|
|
|
444
433
|
: [];
|
|
445
434
|
const last = history.at(-1);
|
|
446
435
|
const checkpoints = currentCheckpoint
|
|
447
|
-
? (
|
|
436
|
+
? (sameTransition(last, currentCheckpoint)
|
|
448
437
|
? history
|
|
449
438
|
: [...history, { ...currentCheckpoint, mutationId }])
|
|
450
439
|
: history;
|