CVS Branch Management

From PostgreSQL wiki
Jump to navigationJump to search

Warning: the PostgreSQL project is using Git now for version control. See Using Back Branches instead of this document for information about listing and checking out old branches of the code

This was written by Tom Lane - 2001-05-07

If you just do basic "cvs checkout", "cvs update", "cvs commit", then you'll always be dealing with the HEAD version of the files in CVS. That's what you want for development, but if you need to patch past stable releases then you have to be able to access and update the "branch" portions of our CVS repository. We normally fork off a branch for a stable release just before starting the development cycle for the next release.

The first thing you have to know is the branch name for the branch you are interested in getting at. To obtain the list of existing branches, you can use this command:

  cvs status -v

(Thanks to Ian Lance Taylor for pointing out that this is the easiest way to do it.) Typical branch names are:


OK, so how do you do work on a branch? By far the best way is to create a separate checkout tree for the branch and do your work in that. Not only is that the easiest way to deal with CVS, but you really need to have the whole past tree available anyway to test your work. (And you *better* test your work. Never forget that dot-releases tend to go out with very little beta testing --- so whenever you commit an update to a stable branch, you'd better be doubly sure that it's correct.)

Normally, to checkout the head branch, you just cd to the place you want to contain the toplevel "pgsql" directory and say

   cvs ... checkout pgsql

To get a past branch, you cd to wherever you want it and say

   cvs ... checkout -r BRANCHNAME pgsql

For example, just a couple days ago I did

   mkdir ~postgres/REL7_1
   cd ~postgres/REL7_1
   cvs ... checkout -r REL7_1_STABLE pgsql

and now I have a maintenance copy of 7.1.*.

When you've done a checkout in this way, the branch name is "sticky": CVS automatically knows that this directory tree is for the branch, and whenever you do "cvs update" or "cvs commit" in this tree, you'll fetch or store the latest version in the branch, not the head version. Easy as can be.

So, if you have a patch that needs to apply to both the head and a recent stable branch, you have to make the edits and do the commit twice, once in your development tree and once in your stable branch tree. This is kind of a pain, but there is no better way.