5

I have a few different darcs repos and I would like to write a script to automatically push changes from these repos at the end of the day. I read at this thread that the "right" way to script darcs is using the library. But here http://darcs.net/Library it says that "it is very much a work in progress" and lacks a stable API. What is the "right" way to script darcs.

tripleee
  • 175,061
  • 34
  • 275
  • 318
cwitte
  • 140
  • 4
  • 2
    For that sort of simple script, I don't think writing a Haskell program should be necessary. I just use simple shell scripts, although I try to take care to use the XML output from Darcs rather than the human-readble version (but the XML bit me in the rear a number of times; it's not completely regular, let alone documented, as far as I could find at the time). – tripleee Aug 06 '12 at 15:43
  • 1
    Running darcs and parsing its XML output was OK for the [trac+darcs](http://progetti.arstecnica.it/trac+darcs/) plugin (darcs integration into Trac, with complete repo browsing capabilities). I agree with tripleee, start with this approach. – Helgi Aug 06 '12 at 15:51
  • 1
    Hey @tripleee, thanks for the comments about darcs XML! (something we need to fix). Any chance we could get bug reports out of you? We do also need to work on documenting things. Slowly getting there. – kowey Aug 07 '12 at 15:27
  • 1
    I'm sure you already have a TODO note to document undocumented things. I got something working by trial and error, but when I had been running it in production for a while, there were more errors, and new trials. How added files, added directories, removed ditto, and amends show up in XML would be valuable information, even if it were simply a DTD. – tripleee Aug 07 '12 at 15:55

1 Answers1

5

It's perfectly fine to script everyday darcs commands, like any other command-line program. It's also fine to script interactive darcs commands, but that's where it gets fragile, because those interactive prompts get refined and changed quite often in new darcs releases. So if at all possible, make the command non-interactive, eg using the -a/--all flag. Push and pull is easy, here's a regular pull that I run from /etc/crontab:

*/15 * * * * darcsden  cd /home/darcsden/darcs/darcs-reviewed; darcs pull -a http://darcs.net/reviewed >/dev/null # 2>&1

but watch out for things that can prevent a successful non-interactive push or pull:

  • conflicts, especially with unrecorded changes
  • wrong user/file ownership/file permissions
  • stray _darcs/lock file left over from an abnormal termination
Simon Michael
  • 2,278
  • 1
  • 18
  • 21