I thought this would work too because people said the history is available in the Register, as if whatever state you put it into can be recovered through some iterative procedure.
There are no examples of this however and the only reference to using the MerkleReg for history that I could find points to two methods that can be used to interrogate the tree. In a sense the tree holds the history, but I don’t see how that can be used to step through old states except for a trivial case of a single value (e.g. one file reference, not a directory of entries) without including nodes for each state you wish to mark for recovery. @Anselme says he agrees with this.
I see how that can be done, but it breaks down if you want to do this for subdirectories wrt to parent state and you need this for many reasons.
That could be done too but gets complex. (You’d have to update the register for every parent directory for any change to content of a child directory, which might be ok. I’m not sure.)
So you can come up with a scheme but it’s not trivial, and you can’t do hard links whatever you put in the Register. I’m trying to find a solution that fits the latter so we can support a very wide range of applications using a FUSE drive and/or a std::fs
API.
If you disagree I suggest you work through some example cases (new file, new file, update file, concurrent update file, merge, new file, delete file, etc and the same for a subdirectory) showing the Register structure at each step, and then show how to get the history using the Register API. For example, how to get the set of directory entries at each step back through the history.
I believe that can be done provided you create a structure inside the register that records the state at each step, and update this for all parent directories above a subdirectory when the latter changes.
If you can show how to do this without such structure also being recorded in the Register it would be very helpful and I’ll owe you a pint.
That’s a lot of work but there’s a lot riding on what appears to be a mistaken belief that a Register can be stepped back through it’s history. At the very least we need an example of how to do that for a couple of non trivial cases. That’s what I wanted to demonstrate based on the chat example, in the new example I created, but couldn’t, so I changed it to show the structure instead of the history.
It looks like @bochaco is taking the approach you describe, so maybe he can demonstrate how to do this already? Or maybe like me he just thinks the Register can do this for us and hasn’t yet looked at how.
I keep posting that I’d like to be contradicted on this.