[darcs-users] [Solved] Recovering from an "unrecord all"

Daniel Déchelotte boite_a_spam at club-internet.fr
Fri Apr 21 00:05:52 UTC 2006


Jamie Webb a écrit :
> 
> That's what 'darcs repair' does. Reconstructing the inventory is the
> hard part. Pulling the header out of each patch should work in the
> simplest case, but things get harder once you start using any of
> Darcs' patch-shuffling features. Expect to have to tweak which patches
> are included and in which order.
> 
> You'll also need to delete the 'pending' patch.

Well, this is very concise and spot on. For future reference, in case
an other unfortunate darcs-newbie like me inadvertently unrecord
everything, I am going to describe a bit how I recovered everything.

0) After "unrecord all", you are left with an empty current and an empty
inventory. Fortunately, all the patches are still here.

1) Start over with an empty folder (~/recovery). Copy the "broken"
_darcs directory into it.

2) Remove the patches/pending file.

3) Now, on to reconstructing the inventory. The basic idea is:
for i in patches/*.gz ; do
  zcat $i \
  | awk '/\] {/ {sub("] {", "]", $0); print; exit } {print}' \
  >> inventory
done
except that, in my case, it didn't work right away (because of
some patches I unrecorded, I presume). I was lucky to have a
pretty recent backup of the inventory, so I only had to manually
add the header of one patch.

4) run darcs repair.
If it fails with "Cannot apply patch" or the like, go back to step 3.
If it succeeds, the current folder is now rebuilt.

5) run darcs revert
to populate ~/recovery with all the files managed with darcs.

6) diff -rq ~/work_dir ~/recovery
should only show differences in _darcs/current/*,
_darcs/patches/pending and _darcs/inventory. If so, replace
~/work_dir/_darcs with the "recovery" version, and everything is back
into place. :)

Thanks very much, Tomasz and Jamie, for the help.

I will conclude with a feature request: would it make sense to
_disable_ the answer "all" to "darcs unrecord"? Or am I
overreacting? ;-)

-- 
Daniel Déchelotte
                  http://yo.dan.free.fr/




More information about the darcs-users mailing list