Vendor Branch Management with Subversion

So, I sometimes hack on FreeBSD and want version control for my local changes. Working with CVS and vendor branches seemed to much of a pain and everyone was talking about how nowadays you’d use Subversion anyways. So I decided to give Subversion a try.

What helped me a lot in getting started with Subversion was the Book “Version Control with Subversion“, which is available online.

So I set up a subversion server and import snapshots of the FreeBSD source tree on a more or less regular basis. Here’s what I do to update the vendor branch.

  • First, I fetch the latest and greatest of the FreeBSD sources, logged into as user svn. I use csup, the CVSup replacement in the base system. I don’t use CVS since it would leave the CVS directories all over the place. It would also be slower and I don’t need its functionality anyways. This is the supfile I use:
    *default base=/var/db
    *default prefix=/usr
    *default release=cvs tag=.
    *default delete use-rel-suffix
    *default compress

    The actual command I run is:

    # csup -L 2 -g ~/supfile
  • Then, I use the Script svn_load_dirs, which can be installed through the devel/svn_load_dirs port. I invoke it as follows:
    $ svn_load_dirs -t tag http://.../repos/freebsd/vendor current /usr/src

    This causes the repository location /repos/freebsd/vendor/current to be updated with the contents of /usr/src. After that, a tag is created at /repos/freebsd/vendor/tag, caused by the parameter -t.

    This whole process takes a while, and every once in a while, something needs to be acknowledged. So unfortunately, it can’t be let run over night. One thing to remember: The command is run as the currently logged in user “svn”, but the repository username is “phs”. So when the script asks for the password, I hit enter. Then a blank line appears where I enter the repository user name. After hitting enter, the scripts asks for the password again, this time for the right user.

  • The next step is to SSH into and go to /usr/devel/src. There, I run

    $ svn up

    After that, I merge the new vendor code with:

    $ svn merge http://…/repos/vendor/freebsd/ http://…/repos/vendor/current .

  • The last step may have produced some conflicts, so I use svn status to detect conflicts.
  • After all conflicts have been resolved, I commit the changes with svn ci and voilà, that’s it.