<commit_before><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  -->

An algorithm for creating edit scripts (in JSOP format) from two trees.
See [this GitHub repository](https://github.com/mduerig/json-diff) for a
proof of concept implementation and
[the related discussion on oak-dev@](http://markmail.org/message/lbc3rx2p3sssvqj5)

    // 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<commit_msg>OAK-659 Move purge logic for transient changes below the NodeBuilder interface jsop-diff is not sufficient. Put a not into the documentation<commit_after><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  -->

*Note:* Below algorithms turns out to be not sufficient. The edit script for the
following case is incomplete. Given S constructed from an empty tree

    S = +/s:{} +/t:{}

obtain T from S by

    T = S +/s/a:{} >/s:/t/s

Running below algorithm on S and T will result in an edit script which, when
applied to S, will not create child node a. I.e. it will result in

    S >/s:/t/s

* * *

An algorithm for creating edit scripts (in JSOP format) from two trees.
See [this GitHub repository](https://github.com/mduerig/json-diff) for a
proof of concept implementation and
[the related discussion on oak-dev@](http://markmail.org/message/lbc3rx2p3sssvqj5)

    // 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
{'fraction_non_alphanumeric': 0.06479275845640782, 'fraction_numerical': 0.004525964745116722, 'mean_word_length': 3.0648596321393997, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3463968', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1070, 'n_words': 559}