[darcs-devel] darcs patch: refactor Repository to allow truly atomi... (and 15 more)

Juliusz Chroboczek Juliusz.Chroboczek at pps.jussieu.fr
Thu Aug 31 13:03:35 PDT 2006


Here's a quick summary of what David's changes do.

In July 2005, I remodularised many commands to go through a common
abstraction layer, implemented in Repository.lhs.  My conversion had
the flaw of only touching the ``safe'' commands -- the ones that add
patches at the end of a repository, and not the ones such as unrecord
or optimize that remove or reorder patches.

David's bundle makes all (?) the commands go through the abstraction
layer.  In the process, he has changed all (?) commands to be atomic.

The way this is done is that there are three new exported functions in
Repository:

  tentativelyAddPatch
  tentativelyRemovePatch
  finalizeRepositoryChanges

tAP and tRP add and remove, respectively, a patch from the repository,
but don't actually modify the inventory and pristine tree: they record
the changes in two files ``tentative_inventory'' and ``tentative_pristine''.
The function fRP will then be used to atomically overwrite the
inventory with ``tentative_inventory'' and then (non-atomically)
update the pristine tree.

I can see two benefits to David's changes.  The first is that the code
is much cleaner: as there no longer are any commands that side-step
the abstraction layer, the modularity of Darcs is much improved.  The
second is that if your system crashes during an ``unsafe'' command
such as optimize, ``darcs repair'' is guaranteed to bring you back to
the initial state.  (This assuming you're using a filesystem with
decent atomicity guarantees -- <digression deleted>.)

It goes without saying that I'm enthusiastic about this change.

                                        Juliusz




More information about the darcs-devel mailing list