[Unison-hackers] Stasher code...
Benjamin Pierce
bcpierce at cis.upenn.edu
Wed Jun 10 21:53:28 EDT 2009
Hi Jerome,
> I'm trying to understand the stasher code, but I'm a bit puzzled.
I've never been completely satisfied with the stasher stuff. It would
be great to get it cleaned up.
> In files.ml, we have the following piece of code:
>
> let deleteLocal (fspath, (workingDirOpt, path)) =
> [...]
> Stasher.backup fspath path `AndRemove
> [...]
>
> If "path" contains a followed link, this will backup and delete the
> *link*, not the link target as expected. Stasher.backup should call
> Fspath.findWorkingDir to get the right file to rename or delete.
Right.
> Again in file.ml, we have the following:
>
> let make_backup =
> (* Perform (asynchronously) a backup of the destination files *)
> Update.updateArchive rootTo pathTo uiTo id
>
> The function Update.updateArchive calls the function
> Stasher.stashCurrentVersion, but only after the destination has been
> updated (the call is in the archive commit action)...
>
>
> Still, the destination files are backed-up by the call to
> Stasher.backup in Files.renameLocal.
This seems right.
> There is also a call to Stasher.stashCurrentVersion in
> Update.replaceArchive, which is supposed to perform backups using the
> temporary files before they replace the destination files, but perform
> backups afterwards. So it does nothing (this is somewhat coherent
> with the implementation of stashCurrentVersion which does not support
> recursive traversal of a temporary directory).
>
> Stasher.stashCurrentVersion is also called from transport.ml, on both
> replicas, after updates.
>
> As a summary, as far as I can see, Stasher.stashCurrentVersion is
> called twice on the source files: once from Update.updateArchive
> (called from File.copy) and then once from Transport.doAction. It is
> also called twice on the destination files once modified, from the
> same functions. It is called once on an empty location from
> Update.replaceArchive. Finally, destination files are backed-up
> before modification through the call to Stasher.backup in
> Files.rename.
>
> If this analysis is correct, I suspect we can safely remove all calls
> to Stasher.stashCurrentVersion from file update.ml.
I'm not completely confident that I've correctly re-understood how all
this is supposed to work, but in any case failing to stash the current
version is less serious than failing to back up the old version -- it
will only result in late merge
Best,
- Benjamin
>
> -- Jerome
> _______________________________________________
> Unison-hackers mailing list
> Unison-hackers at lists.seas.upenn.edu
> http://lists.seas.upenn.edu/mailman/listinfo/unison-hackers
More information about the Unison-hackers
mailing list