Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 851C7DED2 for ; Tue, 27 Nov 2012 13:59:21 +0000 (UTC) Received: (qmail 76950 invoked by uid 500); 27 Nov 2012 13:59:21 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 76908 invoked by uid 500); 27 Nov 2012 13:59:21 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 76890 invoked by uid 99); 27 Nov 2012 13:59:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Nov 2012 13:59:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Nov 2012 13:59:17 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D48182388A32; Tue, 27 Nov 2012 13:58:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1414190 - /jackrabbit/oak/trunk/doc/jsop-diff.md Date: Tue, 27 Nov 2012 13:58:56 -0000 To: oak-commits@jackrabbit.apache.org From: mduerig@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121127135856.D48182388A32@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mduerig Date: Tue Nov 27 13:58:55 2012 New Revision: 1414190 URL: http://svn.apache.org/viewvc?rev=1414190&view=rev Log: OAK-464: RootImpl.rebase() doesn't handle move operations correctly - correct handling of deleted children - pass trash into recursive call to diffNodes - correct comment for diffNodes Modified: jackrabbit/oak/trunk/doc/jsop-diff.md Modified: jackrabbit/oak/trunk/doc/jsop-diff.md URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/doc/jsop-diff.md?rev=1414190&r1=1414189&r2=1414190&view=diff ============================================================================== --- jackrabbit/oak/trunk/doc/jsop-diff.md (original) +++ jackrabbit/oak/trunk/doc/jsop-diff.md Tue Nov 27 13:58:55 2012 @@ -1,69 +1,68 @@ - // Global variable holding the JSOP journal after the diffTree below returns. - jsop = "" - - /* - Create a JSOP journal, which when applied to tree S will transform - it to tree T. - */ - diffTrees(S, T) { - // Create a location (trash) which will temporarily hold removed nodes. - // This is necessary since these (or child nodes thereof) might still be - // needed in move operations occurring only later in the differencing process. - X = S.addNode(createUniqueName) - - // The main differencing process starts at the roots of the trees and - // progresses recursively level by level. - diffNodes(X, S, T) - - // Remove the trash location and all its content - jsop += "-" + X.path + +// Global variable holding the JSOP journal after the diffTree below returns. +jsop = "" + +/* + Create a JSOP journal, which when applied to tree S will transform + it to tree T. +*/ +diffTrees(S, T) { + // Create a location (trash) which will temporarily hold removed nodes. + // This is necessary since these (or child nodes thereof) might still be + // needed in move operations occurring only later in the differencing process. + X = S.addNode(createUniqueName) + + // The main differencing process starts at the roots of the trees and + // progresses recursively level by level. + diffNodes(X, S, T) + + // Remove the trash location and all its content + jsop += "-" + X.path +} + +/* + Recursively create JSOP operations for the differences of the children + of trees S and T. Tree X serves as trash. +*/ +diffNode(X, S, T) { + deleted = S.childNames \ T.childNames // set difference + added = T.childNames \ S.childNames + + // Need to take care of deleted nodes first in order to avoid + // name clashes when adding new nodes later. + for (d : deleted) { + t = S.child(d) + + // Deleted nodes are moved to trash. + op = ">" + t.path + ":" + X.path + "/" + createUniqueName + jsop += op + S.apply(op) // Transform S according to the single op + } + + for (a : added) { + t = T.child(a) + + // assume we can detect a copied node and know its source node + if (isCopied(t)) { + op = "*" + t.sourceNode.path + ":" + t.path + } + + // assume we can detect a moved node and know its source node + else if (isMoved(t)) { + op = ">" + t.sourceNode.path + ":" + t.path } - - /* - Create JSOP operations for the differences of the immediate children - of trees S and T. Tree X serves as trash. - */ - diffNode(X, S, T) { - deleted = S.childNames \ T.childNames // set difference - added = T.childNames \ S.childNames - - // Need to take care of deleted nodes first in order to avoid - // name clashes when adding new nodes later. - for (d : deleted) { - t = S.child(d) - n = createUniqueName - - // Deleted nodes are moved to trash. - t.moveTo(X, n) // Move node t to parent X with name n - op = ">" + t.sourceNode.path + ":" + t.path - jsop += op - S.apply(op) // Transform S according to the single op - } - - for (a : added) { - t = T.child(a) - - // assume we can detect a copied node and know its source node - if (isCopied(t)) { - op = "*" + t.sourceNode.path + ":" + t.path - } - - // assume we can detect a moved node and know its source node - else if (isMoved(t)) { - op = ">" + t.sourceNode.path + ":" + t.path - } - - // this is an added node - else { - op = "+" + t.path - } - - jsop += op - S.apply(op) // Transform S according to the single op - } - - // assert S.childNames == T.childNames - for (c : T.childNames) { - diffNode(S.child(c), T.child(c)) - } - } \ No newline at end of file + + // this is an added node + else { + op = "+" + t.path + } + + jsop += op + S.apply(op) // Transform S according to the single op + } + + // assert S.childNames == T.childNames + for (c : T.childNames) { + diffNode(X, S.child(c), T.child(c)) + } +}