Skip to content

Commit

Permalink
Automation: main-next integrate
Browse files Browse the repository at this point in the history
  • Loading branch information
msfluid-bot committed Dec 12, 2023
2 parents 7ef2cca + c83db8d commit dd87880
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -451,27 +451,15 @@ function amendComposeI<TNodeChange>(
moveEffects: MoveEffectTable<TNodeChange>,
): MarkList<TNodeChange> {
const factory = new MarkListFactory<TNodeChange>();
const queue = new MarkQueue(
marks,
undefined,
moveEffects,
true,
fakeIdAllocator,
// TODO: Should pass in revision for new changes
(a, b) => composeChildChanges(a, b, composeChild),
const queue = new MarkQueue(marks, undefined, moveEffects, true, fakeIdAllocator, (a, b) =>
composeChildChanges(a, b, composeChild),
);

while (!queue.isEmpty()) {
let mark = queue.dequeue();
switch (mark.type) {
case "Placeholder": {
const modifyAfter = getModifyAfter(moveEffects, mark.revision, mark.id, mark.count);
if (modifyAfter !== undefined) {
const changes = composeChildChanges(mark.changes, modifyAfter, composeChild);
mark = createNoopMark(mark.count, changes);
} else {
mark = createNoopMark(mark.count, mark.changes);
}
mark = createNoopMark(mark.count, mark.changes);
}
default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { assert, unreachableCase } from "@fluidframework/core-utils";
import { ChangeAtomId, RevisionTag, TaggedChange } from "../../core";
import { CrossFieldManager, CrossFieldTarget } from "../modular-schema";
import { RangeQueryResult, brand } from "../../util";
import { CellMark, Mark, MarkEffect, MoveId, MoveIn, MoveOut } from "./types";
import { CellMark, Mark, MarkEffect, MoveId, MoveIn, MoveOut, MovePlaceholder } from "./types";
import { areEqualCellIds, cloneMark, isAttachAndDetachEffect, splitMark } from "./utils";
import { MoveMarkEffect } from "./helperTypes";

Expand Down Expand Up @@ -150,7 +150,7 @@ function applyMoveEffectsToDest(
}

function applyMoveEffectsToSource<T>(
mark: CellMark<MoveOut, T>,
mark: CellMark<MoveOut | MovePlaceholder, T>,
revision: RevisionTag | undefined,
effects: MoveEffectTable<T>,
consumeEffect: boolean,
Expand All @@ -173,7 +173,9 @@ function applyMoveEffectsToSource<T>(
}

const newMark = cloneMark(mark);
applySourceEffects(newMark, mark.count, revision, effects, consumeEffect);
if (isMoveOut(newMark)) {
applySourceEffects(newMark, mark.count, revision, effects, consumeEffect);
}

if (nodeChange !== undefined) {
newMark.changes = nodeChange;
Expand Down Expand Up @@ -359,9 +361,10 @@ export function applyMoveEffectsToMark<T>(

return [newMark];
}
} else if (isMoveMark(mark)) {
} else if (isMoveMark(mark) || mark.type === "Placeholder") {
const type = mark.type;
switch (type) {
case "Placeholder":
case "MoveOut": {
const effect = getMoveEffect(
effects,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/

import { strict as assert } from "assert";
// eslint-disable-next-line import/no-internal-modules
import { MarkQueue } from "../../../feature-libraries/sequence-field/markQueue";
// eslint-disable-next-line import/no-internal-modules
import { MoveEffect, MoveEffectTable } from "../../../feature-libraries/sequence-field";
import {
CellMark,
MarkList,
MoveId,
MovePlaceholder,
// eslint-disable-next-line import/no-internal-modules
} from "../../../feature-libraries/sequence-field/types";
import { CrossFieldTarget, SequenceField as SF } from "../../../feature-libraries";
import { brand, idAllocatorFromMaxId } from "../../../util";
import { TestChange } from "../../testChange";
import { TaggedChange, mintRevisionTag, tagChange } from "../../../core";

const tag1 = mintRevisionTag();
const tag2 = mintRevisionTag();

describe("SequenceField - MarkQueue", () => {
it("applies effects to Placeholder marks", () => {
const idAllocator = idAllocatorFromMaxId();
const changes = TestChange.mint([], 1);
const moveEffects = SF.newCrossFieldTable() as MoveEffectTable<TestChange>;
const effect: MoveEffect<TestChange> & { basis: MoveId } = {
modifyAfter: tagChange(changes, tag2),
basis: brand(0),
};
moveEffects.set(CrossFieldTarget.Source, tag1, brand(1), 1, effect, false);
const placeholder: CellMark<MovePlaceholder, TestChange> = {
type: "Placeholder",
revision: tag1,
id: brand(0),
count: 2,
};
const queue = new MarkQueue<TestChange>(
[placeholder],
undefined,
moveEffects,
true,
idAllocator,
(a: TestChange | undefined, b: TaggedChange<TestChange>) => {
assert.equal(a, undefined);
assert.equal(b.revision, tag2);
assert.equal(b.change, changes);
return changes;
},
);
const actual = [];
while (!queue.isEmpty()) {
actual.push(queue.dequeue());
}

const expected: MarkList<TestChange> = [
{
type: "Placeholder",
revision: tag1,
id: brand(0),
count: 1,
},
{
type: "Placeholder",
revision: tag1,
id: brand(1),
count: 1,
changes,
},
];
assert.deepEqual(actual, expected);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ describe("Fuzz - Top-Level", () => {
maxNumberOfClients: 3,
},
reconnectProbability: 0,
skip: [26],
};
createDDSFuzzSuite(model, options);
});
Expand Down

0 comments on commit dd87880

Please sign in to comment.