fixed bug (o.right is already gc'd), implemented some test helpers

This commit is contained in:
Kevin Jahns
2015-10-17 17:16:36 +02:00
parent cf365b8902
commit 45814c4e00
4 changed files with 100 additions and 24 deletions

View File

@@ -300,6 +300,7 @@ class Transaction {
* reset origins of all right ops
*/
* garbageCollectOperation (id) {
this.store.addToDebug('yield* this.garbageCollectOperation(', id, ')')
// check to increase the state of the respective user
var state = yield* this.getState(id[0])
if (state.clock === id[1]) {
@@ -371,15 +372,22 @@ class Transaction {
// remove gc'd op from parent, if it exists
var parent = yield* this.getOperation(o.parent)
var setParent = false // whether to save parent to the os
if (Y.utils.compareIds(parent.start, o.id)) {
// gc'd op is the start
setParent = true
parent.start = o.right
}
if (Y.utils.compareIds(parent.end, o.id)) {
// gc'd op is the end
setParent = true
parent.end = o.left
if (o.parentSub != null) {
if (Y.utils.compareIds(parent.map[o.parentSub], o.id)) {
setParent = true
parent.map[o.parentSub] = o.right
}
} else {
if (Y.utils.compareIds(parent.start, o.id)) {
// gc'd op is the start
setParent = true
parent.start = o.right
}
if (Y.utils.compareIds(parent.end, o.id)) {
// gc'd op is the end
setParent = true
parent.end = o.left
}
}
if (setParent) {
yield* this.setOperation(parent)
@@ -570,9 +578,8 @@ class Transaction {
continue
}
var startPos = startSS[user] || 0
var endPos = endState.clock
yield* this.os.iterate(this, [user, startPos], [user, endPos], function * (op) {
yield* this.os.iterate(this, [user, startPos], [user, Number.MAX_VALUE], function * (op) {
ops.push(op)
})
}