Advanced Rails - Building Industrial-Strength Web Apps in Record Time

(Tuis.) #1

298 | Chapter 10: Large Projects


One often-cited drawback to CVS is that it does not guaranteeatomic commits.If
interrupted while in process, commits can leave the working copy and repository in
an inconsistent state. Most other version control systems provide an atomicity guar-
antee: commits are applied to the repository either in full or not at all.


In practice, this is more of an annoyance than a critical flaw. Important repositories
should be backed up regularly, regardless of what version control system they are
backed by. Still, this and other limitations make some developers uncomfortable. In
response, many other version control systems have evolved out of the CVS model,
and CVS is not used very much anymore for new projects.


Subversion


Subversion (http://subversion.tigris.org/) is currently the most popular version con-
trol system among Rails developers. It was designed to be a replacement for CVS,
and it has been very successful. Developers used to CVS will feel at home with Sub-
version’s commands.


As a centralized version control system, Subversion uses one primary server that
keeps a master repository. Developers check out a working copy, make their
changes, and check them back in. By default, Subversion uses thecopy-modify-merge
model for concurrent development. Multiple people can check out the same file,
make concurrent changes, and have their work merged. Non-overlapping changes
will be merged automatically; conflicting changes must be merged by hand.


Files that cannot be merged (such as image files) can be locked for serialized access:


$ svn lock images/logo.png -m "Changing header color"
(work with logo.png...)
$ svn ci images/logo.png -m "Changed header to blue"

You can also use thesvn:needs-lockproperty to designate that a file should be
locked before editing. If a file marked with that property is checked out without a
lock, the working copy version will be set as read-only to remind the developer to
lock the file before changing it.


Subversion was designed as a replacement for CVS, and it improves on CVS in many
ways:



  • Subversion has truly atomic commits; interrupted commits are guaranteed to
    leave the repository in a consistent state (though they may leave outstanding
    locks in the working copy).

  • Subversion supports constant-time branching using copy-on-write semantics for
    copies. Branches and tags are simply directories; they are not separate objects as
    in CVS.

  • Directories are tracked independently of the files they contain. Directories and
    files can be moved while retaining their version history.

  • Symbolic links can be stored in the repository and versioned as links.

Free download pdf