Version Control

Steven J Zeil

Last modified: Nov 20, 2013

Contents:
1. Issues in Version Control
2. Background - Changing the Code Base
2.1 Integrating Changes
3. Approaches and Tools

Version control (a.k.a. version management is concerned with the management of change in the software artifacts being developed.

1. Issues in Version Control

The issues addressed by version control are:

2. Background - Changing the Code Base


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.

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

2.1 Integrating Changes

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

  1. Compare file2a and file2b
  2. Wherever the two are different, prompt the human to select the desired change.

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

  1. Compare file1 and file2a, then file1 and file2b
  2. Any lines that differ from file1 in only one of the two other files can be applied automatically.
  3. Wherever both file2a and file2b are different from file1, prompt the human to select the desired change.

3. Approaches and Tools


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