To avoid these problems, you can use a
version-control
system
(VCS), a suite of programs that automates away most of
the drudgery involved in keeping an annotated history of your
project and avoiding modification conflicts.
Most VCSs share the same basic logic. To use one, you start by
registering
a collection of source files —
that is, telling your VCS to start archive files describing their
change histories. Thereafter, when you want to edit one of these
files, you have to
check out
the file —
assert an exclusive lock on it. When you're done, you
check
in
the file, adding your changes to the archive, releasing
the lock, and entering a change comment explaining what you
did.
The history of the project is not necessarily linear. All VCSs
in common use actually allow you to maintain a tree of variant
versions (for ports to different machines, say) with tools for merging
branches back into the main “trunk” version. This
feature becomes important as the size and dispersion of the
development group increases. It needs to be used with care,
however; multiple active variants of the code base can be
very confusing (just associated bug reports to the right version
are not necessarily easy), and automated merging of branches does
not guaranteed that the combined code works.
Most of the rest of what a VCS does is convenience: labeling,
and reporting features surrounding these basic operations, and tools
which allow you to view differences between versions, or to group a
given set of versions of files as a named
release
that can be examined or reverted to at any time without losing later
changes.
VCSs have their problems. The biggest one is that using a VCS
involves extra steps every time you want to edit a file, steps
that developers in a hurry tend to want to skip if they have to be
done by hand. Near the end of this chapter we'll discuss a way to
solve this problem.
Another problem is that some kinds of natural operations tend to
confuse VCSs. Renaming files is a notorious trouble spot; it's not
easy to automatically ensure that a file's version history will be
carried along with it when it is renamed. Renaming problems are
particularly difficult to resolve when the VCS supports
branching.
Despite these difficulties, VCSs are a huge boon to productivity
and code quality in many ways, even for small single-developer
projects. They automate away many procedures that are just tedious
work. They help a lot in recovering from mistakes. Perhaps most
importantly, they free programmers to experiment by guaranteeing
that reversion to a known-good state will always be easy.
(VCSs, by the way, are not merely good for program code; the
manuscript of this book was maintained as a collection of files
under RCS while it was being written.)
[an error occurred while processing this directive]