latest version
parent
0f7fd11880
commit
d19e11772c
|
@ -1255,49 +1255,47 @@ function handleChangesetRequest(client, message)
|
||||||
//build the requested rough changesets and send them back
|
//build the requested rough changesets and send them back
|
||||||
getChangesetInfo(padIds.padId, start, end, granularity, function(err, changesetInfo)
|
getChangesetInfo(padIds.padId, start, end, granularity, function(err, changesetInfo)
|
||||||
{
|
{
|
||||||
ERR(err);
|
if(err) return console.error('Error while handling a changeset request for '+padIds.padId, err, message.data);
|
||||||
|
|
||||||
// Assert that the paths are correct
|
// Assert that the paths are correct
|
||||||
var assert = require('assert')
|
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
|
if(err) return
|
||||||
var headRev = pad.getHeadRevisionNumber()
|
var headRev = pad.getHeadRevisionNumber()
|
||||||
, end = start+(granularity*changesetInfo.forwardsChangesets.length)-1
|
, end = start+(granularity*changesetInfo.forwardsChangesets.length)// (-1) ?? let's test that later
|
||||||
console.log(changesetInfo)
|
|
||||||
if(start > headRev || end > headRev) return console.log('Cannot vet from ', start, 'to', end)
|
|
||||||
|
|
||||||
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)
|
console.log(start)
|
||||||
ERR(err)
|
ERR(err)
|
||||||
pad.getInternalRevisionAText(end, function(err, atextEnd) {
|
pad.getInternalRevisionAText(end, function(err, endRev) { // <-- here we get the supposed end revision
|
||||||
console.log(end)
|
console.log(end)
|
||||||
ERR(err)
|
ERR(err)
|
||||||
|
|
||||||
// check forward
|
// check forward
|
||||||
console.log('Vetting revision path from ', start, 'to', end)
|
console.log('Vetting revision path from ', start, 'to', end)
|
||||||
var atext = atextStart
|
var atext = startRev
|
||||||
console.log(atext)
|
console.log("startRev atext:", atext)
|
||||||
if(changesetInfo.forwardsChangesets.length > headRev-1) changesetInfo.forwardsChangesets.shift() // remove the first changeset, as we already have the first revision.
|
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) {
|
changesetInfo.forwardsChangesets.forEach(function(cs) {
|
||||||
atext = Changeset.applyToAText(cs, atext)
|
atext = Changeset.applyToAText(cs, atext)
|
||||||
})
|
})
|
||||||
console.log(atext)
|
console.log("computed atext:", atext)
|
||||||
console.log(atextEnd)
|
console.log("expected endRev atext:", endRev)
|
||||||
assert(atext.text == atextEnd.text)
|
assert(atext.text == endRev.text)
|
||||||
console.log('OK')
|
console.log('OK')
|
||||||
|
|
||||||
// check backward /*/
|
// check backward /*/
|
||||||
console.log('Vetting revision path from ', end, 'to', start)
|
console.log('Vetting revision path from ', end, 'back to', start)
|
||||||
atext = atextEnd
|
atext = endRev
|
||||||
console.log(atextEnd)
|
console.log(atext)
|
||||||
if(changesetInfo.backwardsChangesets.length > headRev-1) changesetInfo.backwardsChangesets.shift()
|
if(start == 0) changesetInfo.backwardsChangesets.shift() // remove the first changeset, as we already have the first revision.
|
||||||
changesetInfo.backwardsChangesets.reverse().forEach(function(cs) {
|
changesetInfo.backwardsChangesets.reverse().forEach(function(cs) {
|
||||||
atext = Changeset.applyToAText(cs, atext)
|
atext = Changeset.applyToAText(cs, atext)
|
||||||
})
|
})
|
||||||
console.log(atext)
|
console.log(atext)
|
||||||
console.log(atextStart)
|
console.log(startRev)
|
||||||
assert(atext.text == atextStart.text)
|
assert(atext.text == startRev.text)
|
||||||
console.log('OK')
|
console.log('OK')
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue