The create_version method

The create_version method is invoked when a checkin command is entered. The create_version method of the z_whole_copy type manager does the following operations:
  1. Compresses the data in the checked-out version
  2. Stores the compressed data in a data container located in a source storage pool
  3. Returns to the calling process an exit status that indicates what to do with the new data container

The file versionvault-home-dir/lib/mgrs/mgr_info.h lists the arguments passed to the method from the calling program (usually cleartool or File Browser):

 * create_version
 * Store the data for a new version.
 * Store the version's data in the supplied new container, combining it
 * with the predecessor's data if desired (e.g for incremental deltas).
 * Command line:
 *  create_version create_time new_branch_oid new_ver_oid new_ver_num
 *                new_container_pname pred_branch_oid pred_ver_oid
 *                pred_ver_num pred_container_pname data_pname

The only arguments that require special attention are new_container_pname (fifth argument), which specifies the path of the new data container, and data_pname (tenth argument), which specifies the path of the checked-out file.

The file versionvault-home-dir/lib/mgrs/ lists the appropriate exit statuses and provides a symbolic name for the create_version method:

# Any unexpected value is treated as failure

# Return Values for store operations
The following example is the code that implements the create_version method:
shift 1
if [ -s $4 ] ; then
echo '$0: error: new file is not of length 0!’
if $gzip < $9 > $4 ; ret=$? ; then : ; fi
if [ "$ret" = "2" -o "$ret" = "0" ] ; then

The Bourne shell allows only nine command-line arguments. The shift 1 in Line 1 discards the first argument (create_time), which is unneeded. Thus, the path of the checked-out version (data_pname), originally the tenth argument, becomes $9.

In Line 6, the contents of data_pname are compressed, then appended to the new, empty data container: new_container_pname, originally the fifth argument, but shifted to become $4. (Lines 2 through 5 verify that the new data container is, indeed, empty.)

Finally, the exit status of the gzip command is checked, and the appropriate value is returned (Lines 7 through 11). The exit status of the create_version method indicates that both the old data container (which contains the predecessor version) and the new data container (which contains the new version) are to be kept.