Repository navigation
state: json() and ptree() key by paths relative to their node - #674
Merged
Merged
Conversation
json()/ptree()/save() keyed each node by its full path from the root,
while json(j)/ptree(pt)/restore() apply keys relative to the node they
are called on, like operator() and every other path a node takes. So a
subtree's document only went back right into the root, and
m.json(n.json()) wrote n's subtree under m.<n's full path>.
They now key each node by its path relative to the node they are
called on ("" for that node itself), so n.json(n.json()) gives n its
subtree back and m.json(n.json()) copies it under m. A document of the
root is unchanged (relative paths there are full names), and the loader
still reads the nested and full-path documents older versions wrote
(load those into the root).
Callers: ariadne's save_state/restore_state follow (state_io.h says so;
its tests restore into the saved node and into a copy); cvc state json
<path> prints paths relative to <path> (CLI guide); the xmlrpc
get_json/set_json help strings say both sides are relative.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
json(),ptree()andsave()keyed every node by its full path from the root. Their loadersjson(j),ptree(pt)andrestore()apply keys relative to the node they are called on, asoperator()and every other path a node takes do. The two halves disagreed:n.json(n.json())re-rootedn's subtree undern.<n's full path>.m.json(n.json())wrote underm.<n's full path>. This is the bugstate_listhit (fixed separately in state_list: shift an element's whole subtree and data on erase/insert #672).state_io.hand the xmlrpc help strings documented it, and its tests restored adocsubtree into the root.What
ptree()/json()/save()key each node by its path relative to the node they're called on, with""for that node itself. The format is otherwise unchanged from state: json, traverse and reset without recursing once per level #668: still one level, pre-order,""values for childless empty nodes.n.json(n.json())givesnits subtree back, andm.json(n.json())copies it underm.state_json/state_from_jsonwork on the root and are unaffected.save_state/restore_statefollowcvc::state.state_io.his updated, and its tests restore into the saved node, plus a new check that restoring into another node copies the subtree.cvc state json <path>now prints paths relative to<path>(camera.x, notscene.camera.x). The CLI guide says so.cvcstate_get_json/cvcstate_set_jsonhelp strings now say both sides are relative to the named object, soset_jsonon the pathget_jsonread restores it. Only strings changed there, and xmlrpc is off in the local build. Removing xmlrpc waits for the FoldHub/F2Dock work, since F2Dock'sF2DockServerbuilds oncvc::xmlrpc.children()andtraverse()still report full names. They name nodes rather than describe a subtree, and nothing here changes them.Tests
StateDeepTree.JsonIsOneLevelOfRelativePaths(was…OfFullPaths) checks:StateDeepTree.JsonRoundTripsADeepTreerestores into the saved node, 1000 deep on a 64 KiB stack.state_test,state_list_test,state_deep_tree_testandariadne_loader_test.test_pycvc_state.py'sstate_jsonround trip. The other two fail as before: the rawiv lock (volume: close the file after a successful rawiv write #663) andtest_pycvc_lod.py's crash at exit.