Last modified: Nov 20, 2013
Version control (a.k.a. version management is concerned with the management of change in the software artifacts being developed.
The issues addressed by version control are:
ed
One of the earliest Unix text editors, ed applies a series of editing commands like ‘a’ to append to th end of a file, ‘i’ to insert a line at the current location, ‘d’ to delete the current line, etc.
diff
diff compares two files line by line, listing the differences between them.
Can emit differences as ed commands:
diff --ed file1 file2 > file12.diff
echo w file2 >> file12.diff
ed file1 < file12.diff
would “rebuild” file2 from file2 and the diff.
patch
patch takes a slightly more sophisticated approach to the idea of applying a diff output to a file
diff file1 file2 > file12.diff
⋮
patch file1 file12.diff
Allows a variety of different diff variants
Suppose that we have two patch files created from the same base file file1
patch -o file2a file1 patchA
patch -o file2b file1 patchB
Change integration is the problem of combining both sets of changes to form a desired file file2.
Two-way Change Integration
patch -o file2a file1 patchA
patch -o file2b file1 patchB
Three-way Change Integration
Takes the base file into account as well as the two changed files.
patch -o file2a file1 patchA
patch -o file2b file1 patchB
Version Control Systems
If we could extend patch multiple files at once, we could, in theory, patch an entire software system to move it from version 1 to version 2, then patch it again to move to version 3, etc.
Approaches and Tools
Centralized version control systems keep the system history at a centralized location accessible via the network.
Developers check out a copy of the current (or a desired older) version of the software onto their own machines.
Distributed version control systems allow developers to keep the full system history on their own machines.
A central location may hold a base copy for management/distribution purposes, but this is not required.