Tuesday, January 09, 2007

Bash Alias for Darcs users

I've been using darcs for quite a while. I really love its simplicity and distributed nature. I found myself repeating myself again and again typing basic darcs commands after using the techniques described in this excellent blog. Here are a few additions I added to my ~/.bash_profile to minimize the types I need to make. Explanations in lines.

# Setup editor environment editors to let darcs know.

# My typical patch naming convention is {year-month-date-hour-min-sec}.
# instead of manually making on up every commit, I'd like to automate it.
PATCHNAME=$(date +%Y%m%d%k%M%S)

# 'commit' will tell darcs to record all (-a) changes using the patch name as mentioned above.
# we also tell the darcs command to launch our default EDITOR to let us add a long comment.
# last, we'd like to add a signature to the patch by associated with our email address
alias commit='darcs record -a --patch-name=$PATCHNAME --edit-long-comment --author=alex.dong@you-mail.com'
alias diff='darcs whatsnew | less'


Anonymous said...

You are completely misusing Darcs and version control in general.

(1) Version control is NOT a backup system.

Labeling records by date and recording every change is inappropriate use of the version control system. Records are supposed to be meaningful to the work at hand, not dictated by time.

(2) Darcs allows you be very specific in recording changes.

By-passing that selection process with the "-a" flag every time indicates that you are not recording meaningful changes, but just a potpourri of whatever you happened to do that day.

Every record should have a basis, a unifying rationale, which you can point to and say: "This is why I recorded these changes together." The name summarizes it, the long description allows you to fill in the details.

What you are doing negates half the raison d'etre of Darcs in the first place. In fact, it makes it more pointless than Subversion or CVS.

Mark Stosberg said...

Using the date for the patch name is an odd choice as well, since Darcs automatically includes the current date whenever you make a patch. Using the date again as the name of the patch just duplicates that.

Sam said...

Anonymous: Actually, if you work on the same project on several different computers, which you manually transfer files between, Darcs is quite handy for not accidentally overwriting changes.

I do prefer to give the patches a name that reflects what I've done, but occasionally I find myself recording a miscellaneous patch because I'm too lazy to break it down into meaningful parts.