All version control systems work by keeping a central database, known as a repository, that tracks the entire edit history of each file. Typically, the repository will only store the changed text (the diff) between each version, making it far more efficient than a complete backup of each version. The repository also stores the editor's name, the time, and a log message summarizing the changes. The repository is not supposed to be edited directly, only through version control commands. It should be located somewhere that all editors can access.
To edit a file under version control, you check out files from the repository, make your changes, and check in or commit the new version. You can continue to commit further changes from the same working copy, which contains your copy of the actual files in the repository. Also, you can check out an older revision to examine files at a previous state.
This column will provide a quick introduction on how to set up Subversion for use from Athena. For an excellent reference on the details of Subversion, check out the online Subversion book at svnbook.red-bean.com.
To create your repository, run
athena% svnadmin create --fs-type fsfs /mit/joeuser/myproject-repo
athena% athrun consult fsr sa /mit/joeuser/myproject-repo user1 write user2 write
athena% svn mkdir file:///mit/joeuser/myproject-repo/trunk -m trunk
Replace user1, user2, etc. with the usernames of people
who should be able to contribute to the project, and
/mit/joeuser/myproject-repo
with the path to some (new)
directory in your locker. This will store the repository, not the
working copy.
The last line will create a directory called trunk, with a terse commit message of "trunk". Traditionally, all files in the project are stored within the trunk. This allows you to later create branches (work on the project that is experimental or otherwise should not yet go in the trunk) or tags (checkpoints of the project at a certain state) outside of the trunk.
Each contributor can now check out the repository with
athena% mkdir project
athena% cd project
athena% svn co file:///mit/joeuser/myproject-repo/trunk
cd
to the trunk
directory you just
checked out, and run svn update
to ensure that you have the
latest working copy. Add or edit files as usual. If you've added a file,
run svn add filename
to make sure it goes into the
repository. Then, run the command svn commit
(aka svn
ci
) to commit your changes. This will bring up an editor, by
default Emacs, to record a log message. You should give a descriptive
summary of your changes so others will know what you did. (If you're not
familiar with Emacs, you can hit Ctrl-X Ctrl-C to save and quit.)
svn log filename
. Once you've identified the
revision, you can add the -r
flag to the svn
update
command:
athena% svn update -r10 Foo.java
U Foo.java
Updated to revision 10.
If you just want to see the difference between two versions, you can use
the svn diff
command. Like svn update
, give it
the revision flag and the name of the file. If you want to diff between
two old revisions, rather than your working copy and an old revision,
use syntax such as svn diff -r10:22
. Both svn
update
and svn diff
will operate on the entire
directory if you do not give them a filename.
Another popular option is the Subclipse plugin to Eclipse (subclipse.tigris.org). Eclipse is commonly used for development in Java and other languages. Once you have Subclipse installed, you may need to change the default interface (in Preferences | Team | SVN) to JavaSVN in order for it to work with SSH. Then you can run File | Import to import an existing project from SVN.
In both of these cases, you'll need to use svn+ssh access on your
repository, since you probably don't have AFS installed. Specify the
repository as, e.g.,
svn+ssh://athena.dialup.mit.edu/afs/athena/user/j/o/joeuser/myproject-repo
.