CVS Best Practices

From GEOS-5
Revision as of 08:43, 3 January 2013 by Mathomp4 (talk | contribs) (Added categories)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Branch Name Style

We recommend using

b_XYZ_descriptive 

where XYZ are your initials and descriptive is a descriptive name for your branch.

Note: Branches and branch tags are essentially immutable. Once you make one, that branch is there.

Branching files

Note: With GEOS-5 we do not branch the entire model. Rather we branch individual files that are edited. There may be special circumstances when branching an entire directory (say, a leaf Gridded Component) might be correct, but this should only be done with approval.

To branch your modified file on a new branch, assume you've made modifications to file.F90 and want to save these to a new branch of the model. To do so:

Tag the ROOT of your new branch

We recommend that prior to branching your code, you tag where you branched from by running:

cvs tag b_XYZ_descriptive_ROOT file.F90

This can aid in allowing for easy tracing of your modifications to know where you started from.

Create a branch relative to ROOT tag

This says relative to that ROOT, we create a branch of name b_XYZ_descriptive:

cvs tag -r b_XYZ_descriptive_ROOT -b b_XYZ_descriptive file.F90

Update your file to your new branch

We now update to the new branch so we can commit.

cvs update -r b_XYZ_descriptive file.F90

Commit your code

Finally commit your code with:

cvs commit file.F90

This will open up your favorite editor to add an explanatory message. We recommend this message start with your initials (so when doing cvs log we know who added the message:

XYZ: Added new functionality to file.F90
CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS: 
CVS: Committing in .
CVS: 
CVS: Modified Files:
CVS:  Tag: b_XYZ_descriptive
CVS:  file.F90 
CVS: ----------------------------------------------------------------------

Tag your code and update to that tag (optional)

As non-branch tags are easy to remove and change, naming practices are not as strict here. The plus of tagging and then updating to that tag is that you can't commit to a sticky tag, so you have to explicitly update to a branch to figure it out.

cvs tag my-tag-name file.F90
cvs update -r my-tag-name file.F90

Renaming tags

With CVS it is fairly simple to rename a tag that is not a branch tag. Assume you have two tags, a bad_tag name you wish to change to a new good_tag name. First, tag all files that have the old tag with the new tag relative to that tag:

$ cvs tag -r bad_tag good_tag file1.F90 file2.F90 file3.F90
T file1.F90
T file2.F90
T file3.F90

Then remove bad_tag from those files:

$ cvs tag -d bad_tag file1.F90 file2.F90 file3.F90
D file1.F90
D file2.F90
D file3.F90