I had to write quite a bit of code for one of my projects this term. To keep the project manageable, I wanted a simple way to take snapshots of my files at particular milestones, so I could back up and look at previous snapshots if I ever screwed up my code. I ended up doing this with RCS.
RCS is best for situations where a single user is modifying files locally. For remote repositories or when you need to coordinate actions between multiple users, you should use another version control system.
To set up RCS in a directory:
- Create a subdirectory named RCS.
- To manage FILE using RCS, run $ ci -u FILE. Type a description of the file when prompted.
Emacs can deal with RCS-managed files out of the box. Here's a typical workflow:
- Open an RCS-managed file in Emacs. Emacs automatically recognizes that the file is under RCS and displays the version number in the mode line.
- Lock the file for editing with C-x v v.
- Make your changes.
- When you're at a milestone, commit your changes with C-x v v. Emacs prompts you for a commit message. Enter it in the provided buffer and press C-c C-c.
- To continue editing the file, lock it again wih C-x v v and proceed as above.
Now you get to use the other cool features provided by the VC facility in Emacs:
- C-x v = displays a diff between your current version and the previous committed version. C-u C-x v = lets you diff any two previous versions of the file. I like to use unified diffs whenever possible, so I have (setf vc-diff-switches "-u").
- C-x v ~ prompts you for a version number and displays that version of the file in a new buffer.
- C-x v g displays an annotated version of the file showing, for each line, when that line was last modified, and a heat-map displaying older and newer code in different colors.