From c77c46d107a017b188f0ff6b9310cc0d61f2733a Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sun, 14 Sep 2014 18:46:07 +0200 Subject: WIP --- github.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'github.js') diff --git a/github.js b/github.js index cf41e8b..6fabfac 100644 --- a/github.js +++ b/github.js @@ -175,15 +175,20 @@ GitHubBackend.prototype.saveProject = function (commitMessage, parentCommitSha, var parentCode = atob(parentCodeFile.content), parentNotes = atob(parentNotesFile.content); var headCode = atob(headCodeFile.content), headNotes = atob(headNoteFile.content); var dmp = new diff_match_patch(); - dmp.Match_Threshold = 0.1; - var codeDiff, noteDiff; + //dmp.Match_Threshold = 0.1; + var codeDiff, codeDiffs; var codePatch, notePatch; // diff parent <-> local - codeDiff = dmp.diff_main(parentCode, localCode); - noteDiff = dmp.diff_main(parentNotes, localNotes); - codePatch = dmp.patch_make(codeDiff); - notePatch = dmp.patch_make(noteDiff); + codeDiff = dmp.diff_linesToChars_(parentCode, localCode); + console.log('converted ' + JSON.stringify(codeDiff));//DEBUG + codeDiffs = dmp.diff_main(codeDiff.chars1, codeDiff.chars2, false); + console.log('diffed');//DEBUG + dmp.diff_charsToLines_(codeDiffs, codeDiff.lineArray); + console.log('creating patch');//DEBUG + codePatch = dmp.patch_make(codeDiffs); + + notePatch = dmp.patch_make(parentNotes, localNotes); console.log(JSON.stringify(codePatch));//DEBUG // patch (parent<->local) => head localCode = dmp.patch_apply(codePatch, headCode); -- cgit v1.3.1