From 287b5095af3abc98099832a095f7243171ded794 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Tue, 31 Dec 2013 16:18:02 +0100 Subject: [PATCH] it WORKS! happy new year everyone --- src/node/handler/PadMessageHandler.js | 39 ++++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 356767787..4ff30326a 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1259,45 +1259,46 @@ function handleChangesetRequest(client, message) // Assert that the paths are correct var assert = require('assert') - padManager.getPad(message.padId, function(err, pad) { + padManager.getPad(message.padId, function(err, pad) {// <-- so we get the pad if(err) return + start -= 1 var headRev = pad.getHeadRevisionNumber() - , end = start+(granularity*changesetInfo.forwardsChangesets.length)-1 - console.log(changesetInfo) - if(start > headRev || end > headRev) return console.log('Cannot vet from ', start, 'to', end) + , end = start+(granularity*changesetInfo.forwardsChangesets.length)// (-1) ?? let's test that later + if(start < 0) start = 0 - pad.getInternalRevisionAText(start, function(err, atextStart) { + console.log(changesetInfo) + if(start > headRev || end > headRev) return console.log('Cannot vet from ', start, 'to', end) // <-- some sanity checks + pad.getInternalRevisionAText(start, function(err, startRev) { // <-- ok, so here we get revsion `start`. so, this should be (by above definition) correct. ok console.log(start) ERR(err) - pad.getInternalRevisionAText(end, function(err, atextEnd) { + pad.getInternalRevisionAText(end, function(err, endRev) { // <-- here we get the supposed end revision console.log(end) ERR(err) - // check forward console.log('Vetting revision path from ', start, 'to', end) - var atext = atextStart - console.log(atext) - if(changesetInfo.forwardsChangesets.length > headRev-1) changesetInfo.forwardsChangesets.shift() // remove the first changeset, as we already have the first revision. + var atext = startRev + console.log("startRev atext:", atext) + if(start == 0) changesetInfo.forwardsChangesets.shift() // remove the first changeset, as we already have the first revision (rev0 == changeset0.applyOn('\n') changesetInfo.forwardsChangesets.forEach(function(cs) { atext = Changeset.applyToAText(cs, atext) }) - console.log(atext) - console.log(atextEnd) - assert(atext.text == atextEnd.text) + console.log("computed atext:", atext) + console.log("expected endRev atext:", endRev) + assert(atext.text == endRev.text) console.log('OK') // check backward /*/ - console.log('Vetting revision path from ', end, 'to', start) - atext = atextEnd - console.log(atextEnd) - if(changesetInfo.backwardsChangesets.length > headRev-1) changesetInfo.backwardsChangesets.shift() + console.log('Vetting revision path from ', end, 'back to', start) + atext = endRev + console.log(atext) + if(start == 0) changesetInfo.backwardsChangesets.shift() // remove the first changeset, as we already have the first revision. changesetInfo.backwardsChangesets.reverse().forEach(function(cs) { atext = Changeset.applyToAText(cs, atext) }) console.log(atext) - console.log(atextStart) - assert(atext.text == atextStart.text) + console.log(startRev) + assert(atext.text == startRev.text) console.log('OK') })