[darcs-users] Replaying patches from a darcs repository

Alan Bram alan.bram at oracle.com
Wed Nov 21 23:04:13 UTC 2007


> Essentially, what I want to be able to do is pull the repository one patch
> at a time from first to last.
> After each pull, I want to be able to capture the changed working tree with
> another DVCS (probably git).

I decided I wanted to do basically this same thing.  But, as you said,
darcs did not seem to be able to do that.

Here's how I solved the problem for myself:

- I looked at the darcs patch files in my repo, to learn the format;

- I wrote a little C program which reads a patch file, applies the
  changes to files in an existing working-copy, and then finally
  records (or "checks in") the changed files in another VCS.  I used
  Subversion, so I was doing "svn commit", but I imagine it could be
  changed to work with any other VCS.

- then I made a chronological list of all the patch files in my darcs
  repo, and fed them to my C program one at a time.  (This is easy to
  do, since darcs names the patch files with a timestamp.)

This has worked great for me, although there may be parts of the patch
file format that I didn't discover, just because I never encountered
them.  Basically, I wrote the C program to be as careful as possible:
if anything at all didn't look exactly perfect, I would abort.  That
way, when I came across something new in a patch file, I could go back
and enhance the C program to handle the additional case.  And then
simply try again.  The fact that Subversion uses a
transaction-protected database engine makes it easy to abort, and
revert, a pending change.

If you wanted to try this, I could give you a copy of the C program.


Cheers,
 - arb


More information about the darcs-users mailing list