Showing posts with label vcs. Show all posts
Showing posts with label vcs. Show all posts

Thursday, October 02, 2008

On Version Control "best practices"

Source code management, or version/revision control, is one of the most useful tools that a developer has, especially if this person works with others on a shared code base. However, I've recently realized that some people don't understand what a good "commit"[1] entails. (I'm not naming them, or whether they come from my professional or hobby "spheres of influence".) It doesn't matter whether you're using Subversion, Bazaar, or even CVS. There are a few principles that you should consider when you make a "public" commit (as opposed to a "local" commit, which is supported by distributed version control systems):

  • Limit your commit to one discrete idea. This can be fixing a bug or adding a new feature. Obviously, there is an exception when you happen to fix a bug by creating a new feature, but these instances tend to be rare. The big reason for this principle is that developers are (generally speaking) not infallible. If it turns out that the commit introduced bugs and/or regressions, it is easier to revert an entire revision (through whatever means your SCM provides), than to comb through the differences between the revisions in question for the "tainted" code.
  • Good commit messages are key. Due to the way that most source code repository viewers work, it is considered good practice to summarize the commit in the first line, and then give a more detailed explanation in subsequent lines. This is actually similar to how writing is taught (at least in the US): provide a topic sentence in which you summarize what you're going to write about, and then write your content. In this case, though, you don't need a summary/closing statement at the end.
  • If your project management and/or your SCM software supports it, annotate your commit as much as possible. I'll give two examples as to what I mean:
    1. Bazaar lets you annotate your commit with a couple of metadata flags when you invoke bzr commit: --fixes=[BUG] and --author=[AUTHOR]. The flag --fixes lets you annotate which bug this revision is supposed to fix, and --author lets you specify the author of the code, e.g., if you are just committing a patch for someone else who doesn't have the proper permissions to do it themselves.
    2. There is a post-commit hook for Subversion, distributed with the Trac project management system, that allows tickets to be changed based on the existence of certain key phrases in a commit message. For example, the message Add foo. Addresses #12345 adds a comment to ticket 12345 with that commit message and a link to the revision, whereas the message Add bar (fixes #12345). performs the same task as the "addresses" phrase, plus it sets the ticket status to "closed". In my opinion, putting the "fixes" or "addresses" phrases at the end of the first line is preferable to putting them in the detailed explanation.

Hopefully, this is helpful to those who are new to using version control systems, and those people who are the "gatekeepers" of the repositories. Comments and criticisms are welcome.

1: The difference between a "commit" and a "revision", in my view, is that a revision is a patch that has been committed to a repository, whereas a commit is the process.

Wednesday, March 21, 2007

AWN bzr branch, bazaar overlay

Two announcements tonight: the creation of a bazaar branch for Avant Window Navigator (Awn), and the creation of a bazaar-related gentoo overlay.

First, I really like what njpatel has done with Awn. I've always wanted a bar that looked and functioned like the OSX bar, but the closest I could find was the gDesklets starterbar, and it didn't handle currently running programs. Awn is just plain awesome. Unfortunately, I don't use Gnome on my desktop at home, I use Xfce. So I svn co'd the source and created a patch that uses libxfce4util and thunar-vfs instead of gnome-desktop and gnome-vfs. I submitted that patch to the tracker, where, as of the time of this writing, I haven't gotten a response. We'll see. Next up on my list of modifications, is to use Glib's GKeyFile (read: ini-like file parser) as an alternative to GConf. Because bzr-svn finally doesn't die when I try to checkout a remote repository (as of bzr-svn 0.3.2 and bzr 0.15rc2), I now have a bzr-svn branch that contains all of my changes to Awn.

Speaking of bzr-svn, at the request of the developer of bzr-svn, I have published my modified subversion ebuild that contains the patch listed in the parent post to that comment, in a bzr branch, of all things. This branch also contains the latest releases of paramiko, bzr (0.15rc2), bzrtools, bzr-gtk, and bzr-svn.

[Edit: forgot paramiko]

[Edit: forgot to finish a thought]

[Edit (2007/05/16): Update here]

Thursday, February 08, 2007

Review: Darcs

In short, Darcs irritates me more than any other distributed VCS that I've used so far. And that includes git.


One of the more annoying things about it is that the commands for it are significantly different from most modern VCSs. Examples (based on their equivalents in other systems):

status
darcs whatsnew -s
diff (unified)
darcs diff -u (for the record, I expected darcs whatsnew -u to do the same thing, based on the description in the help text.)
commit (to local tree)
darcs record

On a more positive note, I find the patch-based approach (as opposed to the snapshot-based approach Bazaar uses) to be an interesting method of performing backend operations. However, having to go through each patch "hunk" is rather strange, and doesn't really seem to scale, especially in a command-line interface. It seems that in the prototype GUI, it's a little better, but the usability is still lacking.

Saturday, January 20, 2007

HOWTO compile subversion-1.3.2 so that it works with bzr-svn-0.3

This was written because simply using the patch at the bzr-svn web page is not sufficient for getting it to work with subversion-1.3.2, which I'm using because that's what's stable for Gentoo's x86 ebuilds.

Note 1: I have a Gentoo ebuild that corresponds to these directions. Add a comment if you want it.

Note 2: Where there are instances of lynx -source [url], it can be substituted for wget -O - [url] when lynx is not available.

  1. Unpack the subversion-1.3.2 tarball: tar -xjf subversion-1.3.2.tar.bz2
  2. Change directory to the subversion source directory: cd subversion-1.3.2
  3. Apply this patch to the source (this patch came from the Ubuntu Edgy source diffs, but slightly modified): lynx -source 'http://www.lazymalevolence.com/patches/subversion-1.3.2-debian-x-python-bindings.patch' | patch -p0
  4. Remove some of the generated .swg files, or else the compile will fail: rm subversion/bindings/swig/proxy/*.swg
  5. (This step is for people who have swig 1.3.31 installed; I haven't tested with any other version.) Convert the language typemaps to #ifdefs, to get rid of a bunch of warnings: (cd subversion/bindings/swig && lynx -source 'http://svn.collab.net/viewvc/*checkout*/svn/trunk/subversion/bindings/swig/convert-typemaps-to-ifdef.py?revision=19926&pathrev=19927' | python -)
  6. Regenerate all of the configure files, Makefile.in and the .swg files, among others: ./gen-make.py build.conf; make -f autogen-standalone.mk autogen-swig; (p=`pwd`;for d in . apr{,-util}; do cd $p/$d && autoconf; done)
  7. Proceed normally in the build cycle: ./configure && make all install