A major feature of versioned object bases is version control. Version control tracks the evolution of source files, derived objects (built files), and directories by creating version trees. A version tree is a hierarchical structure representing the evolution of a single file. Figure 6 shows a typical version tree in ClearCase illustrating some of these features.
The main version of the file, typically the one used in releases, is considered to evolve along the main branch or trunk of the tree. When temporary versions of the file are needed, as in bug fixes, testing, or experimental development, they are branched off the main line to preserve the integrity of the main version. Users provide names for the branches of a tree. A branch begins as a duplicate of a version of the file; from there it can undergo numerous changes without disturbing the main version. There is no limit to the number or nesting levels of branches. Branches can be merged back into the other branches and/or can continue to evolve independently. Users can tag any version with a label; this is useful for special access.
FIGURE 5. Typical Version Tree for a File In Figure 5, the tree has a trunk labeled /main that shows the evolution of the main file from version 0 through version 4. Version 1 of the main line file was branched off to become version 0 of a branch called /bugfix. The use of labels is illustrated by the tags RLS1, RLS1.5, and RLS2, which represent three versions used in releases. Version 1 from the /bugfix branch was merged back into the /main branch to produce /main version 4. Merging of branches can be manual or automatic. Notice that /bugfix version 1 was also used to produce /bugfix version 2, continuing the branch.
Users can also define attributes (or meta-data) associated with objects in the VOB. These attributes provide additional information such as an object's QA status. Users have ready access to any version in the VOB and can perform queries to obtain version- related and attribute information for any object.
A view establishes a mapping between the versions of the files stored in the VOB and the versions that appear in the user's working environment. Let's continue the previous example and assume that there are two views looking at the file named application.c: the "devel" view used by a software developer and the "maint" view used by a maintenance programmer. Figure 6 shows two views looking at the application.c version tree.
FIGURE 6. Two Views of a File Named application.c The filtering of versions in a view is performed on an element-by-element basis in the view configuration specification. The config spec is an ASCII text file containing configuration rules. A configuration rule takes the following form:
objectclass pattern versionselector
where objectclass is a keyword indicating a kind of object (currently limited to the element type); pattern is a filename or pathname possibly with wildcards; and versionselector indicates the version, by version number, version label, attribute value, or a condition defined in the configuration specification language.
Figure 7 demonstrates the effects of looking at the same file through two different views: "devel" and "maint".
FIGURE 7. Two Typical Views The sequence starts from the directory /usr/people/demo/demodir/bounce. First the "devel" view is opened. This is done through the command cleartool setview followed by the name of the view. Then a standard UNIX ls command is performed, followed by cleartool ls, which is the equivalent within the ClearCase environment. In a ClearCase view, cleartool ls indicates the version's location in its version tree. This information appears at the end of the response to cleartool ls. Note the difference between the versions of the app.c file appearing in each view.
The command clearcase catcs (which is short for concatenate config spec) lists the view configuration specification. Observe the differences between the specifications for "devel" and "maint".
% cleartool setview maint % cleartool catcs element * CHECKEDOUT // config rule #1 element * main/bugfix/LATEST // config rule #2 element opt.c RLS2 // config rule #3 element * RLS1 -mkbranch bugfix // config rule #4 element * /main/LATEST // config rule #5The view configuration specification determines which versions of elements in a VOB appear in a user's working environment.
Config rule #1 in the "maint" config spec causes the currently checked out version of an element to appear, if there is one. If there are no checked out elements, then one of the subsequent config rules apply.
Config rule #2 causes the most recent version of an element on the /bugfix branch to be used. The keyword LATEST indicates the newest version on the designated branch. This is a useful technique for maintenance programmers.
Config rule #3 ensures that only the version of the element opt.c with the label RLS2 will be used.
Config rule #4 selects the version labeled RLS1 (if there is one) for elements selected by earlier rules. This rule also has the effect (through mkbranch) that whenever a version selected by this rule is checked out, a /bugfix branch is created for that element. Combined with config rule#2, this rule preserves the integrity of the main (or prior) branch version, ensuring that only versions on the /bugfix branch are checked out.
Config rule #5 is only reached by elements with neither a bugfix branch nor a label RLS1. For these elements, the latest version on the main branch is used. This generally includes most directory elements, since development directories do not generally change from release to release and are usually not labeled.
A configuration specification can be changed by any text editor. The edcs command supplies the current config spec to $EDITOR.
FIGURE 8. Typical Version Description
% cleartool lshistory c_frontend/src/*.c Jul 15 chu opt.c created version /bugfix/2 Jul 15 luke parse.c created version /main/11 (RLS2) Jul 12 chu opt.c created version /main/4 (RLS2) Jul 05 luke opt.c created version /bugfix/1 (RLS1.5) Jun 30 solo parse.c created version /main/10 Jun 27 solo opt.c created version /main/3 May 11 chu opt.c created version /main/2
% cleartool lscheckout -r c_frontend Jul 17 solo src/lex.c checkedout /main/4 (reserved) Jul 16 luke doc/rlsnotes checkedout /main/27 (unreserved) Jul 15 chu src/parse.c checkedout /bugfix/11 (reserved)
Checkout causes a writable copy to appear in-place. No parallel trees or search paths are needed. In most source management systems, elaborate scripts must be built and maintained to support the copying and linking of cleartext copies for the engineering workareas. This method of in-place work allows build scripts to access the correct file versions transparently, eliminating the need for the maintenance of the scripts.
% cleartool checkout c_frontend/src/lex.c % ls -l c_frontend/src/lex.c -rw-rw---- solo r_d 12421 Jun 30 c_frontend/src/lex.c
The clearmake tool also has a parallel build feature that allows large, hierarchical builds to be spread across a local area network, producing a significant savings in build time.
FIGURE 9. Typical Build Configuration Record
FIGURE 10. Comparison of Build Configuration Records
In the ClearCase environment, when the user asks to make a target, clearmake attempts to avoid building by finding an existing derived object that can be reused. Derived objects are initially written to view-private storage, but their configuration record is registered globally with a VOB. The user's views as well as global derived objects are checked. When shared by several views, derived objects are promoted to VOB storage.
In order to be reused, the existing derived object's config record must satisfy the user's current config spec's requests.
% clearmake myproj building target opt.o ... found parse.o built 18-Jul by luke building myprog
Binaries (particularly archives) can be shared by checking them in. This freezes the object and is a prelude to releasing it.
% cleartool checkin backend.a % cleartool mklabel RL2 backend.a