Version Control with Meta-CVS 1.0-13

Kaz Kylheku

2003-12-31

Contents

1  Introduction

Greetings, reader! You are about to become a user of version control software called Meta-CVS. The primary function of version control software is to store multiple versions of a group of documents, such as the source files of a computer program. As programmers make changes to the program, they generate new versions of source files, which are retained in the version control system. They may also add files, delete files, rename files, reshape the directory structure of the project; the history of these changes is also retained, just are the changes to the contents of the files themselves.

In addition, to be useful, a version control system must not only store file versions but it must be able to identify groups of related versions, so that an old version of the entire project can be retrieved as a unit. For example, when the programmers decide to release the program, they must be able to assign a symbolic name to the release, and that name must be associated with a particular version of every file. This will allow the release to be later retrieved using its symbolic name as a retrieval key.

Secondly, a version control system must allow developers to make changes in parallel to the same line (or stream) of development, and merge their changes. It must identify conflicting changes so that they can be resolved. In must also allow for multiple parallel lines of development—independent version histories known as branches. Branches are useful for stabilizing software prior to the current release, while allowing new development to happen on the next release. They are useful for going back to an old release and fixing errors. They are also useful for isolating risky, experimental work. When such work involves many changes or more than one developer, it can take place on its own branch. A good version control system makes it easy to create branches, and to merge new changes from the branch back to the original stream.

Meta-CVS is not a fully self-contained version control system. It uses another version control system called CVS to store documents, and also to store additional information about documents which allows it to provide useful behaviors that do not exist in CVS. Effectively, Meta-CVS acts as an agent between you and CVS, which is easier to use and more capable than CVS.

I wrote Meta-CVS because I was frustrated by the inability of CVS to treat the directory structures of my projects as a versioned entity. At the same time, I did not want to rewrite everything that already works well in CVS, such as client-server operation, maintaining file version histories, and branching, merging and conflict identification. Instead, I decided to write a software layer which uses CVS as a foundation. That software layer would not only do completely new things, like directory structure versioning, but also to automate certain tedious tasks which are normally performed with great difficulty by the users of CVS.

Meta-CVS does not, and is not intended to, entirely shield you from knowing anything about CVS. Firstly, Meta-CVS requires the CVS software and a CVS repository. Users who want to use Meta-CVS have to know how to obtain and install CVS and create a repository. Moreover, from time to time it is useful or necessary to bypass Meta-CVS and invoke a CVS operation directly. This guide does not teach CVS; you are strongly encouraged to read Version Management with CVS by Per Cederqvist et al.

If you do not have a CVS repository to experiment with, please read enough of the Cederqvist manual to find out how to create one. Set your CVSROOT environment variable to point to your repository and you are ready to explore Meta-CVS.

In this guide, a few typographic conventions are used. Text which is stored into or produced by the computer is written in typewriter font. The first mention of any special terms is italicized. Such terms are, for your convenience, gathered into a glossary in the appendix.

2  Tutorial

In this section, you will learn how to place a directory tree of files under version control, check out that tree to create a working copy (also called a sandbox), make changes in the sandbox and store the changes in the repository. A directory of files independently versioned under Meta-CVS is called a module, because it is represented as a CVS module.1

Meta-CVS has a command line interface which is deliberately similar to that of CVS. The program's name is mcvs. The mcvs program takes a variety of arguments. The first argument is usually a word which specifies a command. Oft used commands have two-letter abbreviations. For example the update command, whose abbreviation is up, causes material in the repository to be integrated into the working copy.

Before the first argument, one may type special options. These are called global options, and they influence the behavior of many commands in a similar way. For example, when communicating with a remote repository over a slow network, the -z option may be used to specify a compression level.

2.1  Creating a Module

The only way to create a module is to start with an existing directory containing files and subdirectories, and invoke the create command. Suppose that your project is a compiler for a scripting language called Blorg, and you want your module to be called blorg. First, change to the directory containing your latest Blorg sources:
    cd blorg-devel
Then, invoke the command:
    mcvs create blorg blorg-initial-version
The create command requires two additional arguments: the name of the module, and a symbolic name which will identify the baseline of newly versioned files. This name is known as a tag: more specificaly, a version tag. Here, we have chosen the tag blorg-initial-version. Tags are very useful when one makes a module from a specific version of an existing program. Suppose that you didn't write Blorg yourself; rather, you have a copy of the Blorg 2.3 sources and would like to begin your own independent stream of development. It would then behoove you, when creating the module, to use a tag like blorg-2-3. This tag could prove to be very important later on; for example, when you want to create a branch from the 2.3 baseline, which will accept a new snapshot from the Blorg developers.

The first action that the create command takes is to scan the current working directory, and, recursively, all of its subdirectories. It forms a list of all regular files and symbolic links, ignoring any other types of files such as sockets, devices, pipes and the like. Having thus gathered a list of the files, it identifies all of their suffixes and collates them to form a list.

If none of the files have suffixes, the creation procedure skips to the next step. Otherwise, a text editor is invoked in order to allow you to make alterations to a specification which tells how files having these various suffixes are to be treated when they are stored into and retrieved from CVS. The specification is written in the Lisp language, and may look something like this:
    (("c" :DEFAULT)
     ("lisp" :DEFAULT)
     ("png" :DEFAULT)
     ("txt" :DEFAULT))
This is the notation for a list of four elements, as indicated by the outermost parentheses which enclose the whole thing. Each of the four elements is itself a list containing a string like "c" and the symbol :DEFAULT. The string represents a file suffix, and the symbol indicates how files having that suffix are to be treated. Above the list, you should see a comment explaining the various keywords which are supported. The greatest concern is to identify what files are binary. For example, in the above definition, the treatment of the suffix .png should be modified to :BINARY because most likely this suffix indicates a computer graphics image in the Portable Network Graphics format, which is a binary format that must not be subject to line ending conversions, nor to keyword expansion. When you are done editing, save and quit; Meta-CVS will then proceed. If you create a syntax error, for example by introducing an unbalanced parenthesis, Meta-CVS will prompt you with an error message, and you will be given an opportunity to correct the error in a new text editing session.

Note that the symbols may be typed in any mixture of upper and lower case—:Binary, :binary, :BiNaRy, and so forth. These all mean the same thing. However, the leading colon is required.2

Finally, Meta-CVS invokes CVS to create a new module in the repository. CVS also starts a text editor. This time you are expected to enter a log message which will be added to version 1.1 of every new document. You are, in fact, interacting with cvs import.

2.2  Checking out a Module

Like CVS, and some other version control systems, Meta-CVS is based on sandbox model. Under this model, documents are copied from a central repository, and users work with copies of documents. Obtaining a copy is called checking out. The Meta-CVS command for checking out is checkout, abbreviated co. It takes one argument. Continuing with our Blorg example:
    mcvs co blorg
After a log of messages scrolls by in the terminal window, there should now exist the subdirectory blorg, and in that subdirectory there should appear the project's source files. This is a working copy, or a sandbox. You can check out more than one sandbox; sometimes that is convenient to do when one needs to work on several completely unrelated tasks in the same project. The CVS repository doesn't know anything about your sandbox; rather, each sandbox contains information which points back to the repository from which it was checked out. It is safe to move the sandbox by applying the mv command to its root directory.

2.3  Anatomy of a Sandbox

In the root directory of the sandbox, as you will probably notice, there is a subdirectory called MCVS. This is where Meta-CVS stores its local administrative files as well as versioned metadata. It is also where your documents are checked out from CVS; effectively, this directory doubles as a CVS sandbox.

All your files have been assigned machine-generated names by Meta-CVS. These names begin with the characters F- followed by thirty-two hexadecimal digits and an optional suffix. In Meta-CVS jargon, they are called F-files. These files are connected to the directory structure of the sandbox through hard links. That is to say, each of the F-files which appears under the MCVS directory also exists in some other directory within your sandbox. This arrangement is possible because your operating system allows a file object to be referenced by more than one directory entry. Directories are nothing more than lists which link names to file objects. The same file can be known as MCVS/F-0AA69D7C8A0A864345D90F45C18B8B58 as well as source/lib/hash.c. In order to delete the file from your filesystem, you have to delete both directory entries.3

When you check out a module, Meta-CVS calls upon CVS to retrieve copies of F-files from the repository. Then it re-creates the directory structure of the sandbox, inserting these files in the appropriate places in that structure under their familiar names. This insertion is not done by copying the F-files, but rather by creating links to them, which is very efficient.

How does Meta-CVS remember the familar names of the F-files so that it can construct the sandbox? This association is recorded in a file called MAP under the MCVS directory, represented in Lisp notation. You are going to have to understand the MAP file sooner or later, because at times it is necessary to manually edit that file. For example, it can happen that several programmers independently change the mapping in a way that creates a conflict. Resolving the conflict means loading the file into a text editor, and manually sorting out the problem.

Why does Meta-CVS assigns its own internal names to files, and stores the user-assigned names in a special versioned document? The reason is to make it possible to perform directory structure versioning, which means that the directory structure of a module is versioned just like the contents of its files. Changing the name or location of a file is effectively just another edit that is commited to the repository.

Symbolic links are represented purely as special entries in the tt MAP file; their contents are not versioned in CVS as independent objects.

2.4  Making Changes

Now that you have a working copy checked out, you are probably eager to make some changes. This is quite easy; simply edit any of the files to your satisfaction. The version control system knows that you have edited the files; when you are ready, you can instruct the software to publish your changes to the repository. Publishing changes is known as committing and is performed using the commit command, abbreviated ci:4
    mcvs ci
A text editor starts up, and you are expected to enter a commit comment. You are interacting with CVS at this point; the procedure is exactly the same as for CVS commits. However, there is one notable difference. The file names you see listed in the usual comment lines which begin with CVS: and which will be removed are the F-file names, rather than the human-readable names. Alas, CVS doesn't know about the mapping, and this text is prepared within the innards of CVS! Meta-CVS has a solution, though not an entirely satisfactory one, in the form of a text filtering command which reads arbitrary text on standard input, and copies it to standard output, filtering F-file names to their human-readable counterparts. This command is filt, abbreviated fi. Decent text editors allow portions of the text to be easily filtered through an external command. For example, in the vi editor, the command :%!mcvs fi command will apply the Meta-CVS filter to the entire edit buffer. It's trivial to bind this this command to a control character, and store this definition in the editor's personal configuration file, so that the action can be repeated by typing one or two keystrokes.

2.5  Adding Files

Some kinds of changes require special steps to inform Meta-CVS of your intent. For example, if you decide to add some files, Meta-CVS will not automatically incorporate them into the module. For obvious reasons, a sandbox is allowed to contain a mixture of local files and versioned files; there is no certain way to tell which local files ought to be versioned. An object file which results from compiling source code almost certainly does not belong under version control, whereas a new source file probably does. Or does it? It may be a temporary module introduced for debugging, or some experimental code. Only the programmer knows whether it ought to be published to the repository. Every file that is added under version control initially starts out as a local file. An explicit add command must be invoked to cause a local file to become versioned. The effect of add is a local change until it is committed to the repository.

The add command requires additional arguments which specify what files are to be added. For exaple, to add the local files macros.lisp and README, issue the command:
    mcvs add macros.lisp README
Unlike CVS, Meta-CVS allows you to add entire subdirectories at a time. The arguments can be any mixture of files and subdirectories; however, subdirectories are only added if the -R option is specified. For example, to add the directories sources, documentation and the file INSTALL.
    mcvs add -R sources documentation INSTALL
Like the create command, the add command scans the files and symbolic links to be added, and computes a list of the suffixes of the files. If any hitherto unknown suffixes are discovered, a text editor will be invoked to allow you to specify the treatment of these files. The effect of mcvs add is local; the files aren't incorporated into the repository until a commit takes place.

2.6  Reviewing Changes

Before committing local changes, one usually wants to review what those changes are; to find out what files have been added, removed, moved or modified, and to view the differences in modified files. The status, or stat command, invoked without any arguments, produces a listing of all modified files in the current directory and its subdirectories. To include the meta-data files such as MAP, use the –meta global option. The output of status contains F-file names, so the filt command comes in handy. And of course the grep utility is useful in reducing the output to include information only about locally modified files:
    mcvs --meta status | grep Modified | mcvs fi         # list modified files
    mcvs status | grep Added | mcvs fi                   # list added files
The status command takes optional filename and directory arguments. The status of a directory means all of the files in its tree.

Another useful command is diff which views differences between revisions, or between the locally modified files and their closest repository revisions. Like stat, diff responds to the –meta global option, works on the current directory by default, and takes optional file name or directory arguments. It supports a large number of options which affect the way the differences are computed and presented. The two most useful are -u which produces a more readable, so-called “unified” diff, and -b which suppresses differences in whitespace, which is particularly useful when a few small coding changes in a program gives rise to a big change in indentation. For example,
    mcvs diff -ub driver.c
shows the modifications in driver.c as a unified diff, treating lines that differ only in the amount of whitespace as identical.

2.7  Error Recovery

The execution of a Meta-CVS command can encounter a problem situation, or error. For example, suppose that one user adds and commits a file called parser.c and then another user performs an update to pull the latest material from the repository. Suppose that the other user already has a local file called parser.c. This is identified by Meta-CVS as a problem. There are at least two ways of dealing with this problem. One is to defer the problem: do nothing at all and just terminate, leaving the effect of the update operation incomplete. The next time mcvs up is invoked, it will run into the problem again, if the local file still exists. The user has a chance to rename the file “out of the way” and re-try the update. A possible resolution is to overwrite the local file with the one from the repository.

Errors are divided into two categories: terminating errors and continuable errors. When a terminating errors occurs, Meta-CVS display as error message, and terminates. Termination is always graceful; if some operation is partially done, the partial effects are undone. A continuable error, by contrast, causes Meta-CVS to prompt the user with a menu of choices.

A  Glossary

baseline
A crosscut through a collection of version-controlled documents, which selects a specific version of each document.

basename
The short name of a file, excluding the full path, if any. For example, the basename of src/lib/lexer.c is lexer.c.

commit
To publish local changes to the repository, thereby permanently integrating them into the project history. Commited changes can be picked up in other sandboxes by update.

CVS
Concurrent Versions System. A popular freeware version control suite widely used by free software projects. CVS started as a set of shell scripts written by Dick Grune, who posted the software to Usenet in 1986. Grune's CVS scripts used RCS; they provided higher-level functionality over RCS, automating and simplifying the use of RCS by for instance applying version control operations such as merging to entire sets of files at once. Eventually, CVS was rewritten in C, and directly incorporated the algorithms from RCS while remaining compatible with the RCS file format.

F-file
A user document stored by Meta-CVS, in CVS, having a machine-generated name consisting of the characters F- followed by thirty-two hexadecimal digits and an optional suffix.

hard link
An association connecting a directory entry to a file object.

Lisp
1. The standard computing language ANSI Common Lisp. 2. Printed notation, conforming to the ANSI Common Lisp syntax, expressing a potentially complex, nested data structure. 3. Program code resulting from the reinterpretation of Lisp data structures as programming language constructs.

module
An independent set of documents managed as a unit using Meta-CVS.

sandbox
The working copy of a module.

stream
An independent line of development, represented in the version control system as an independent history of changes. In Meta-CVS, there is a main history known as the trunk. Secondary histories are called branches.

suffix
The trailing portion of a basename which is separated from the rest of the name by a period (.) character. If there are two or more such characters, then it is the longest such portion. If the basename contains no periods, then it has no suffix. If the basename begins with a period, the rest of that entire name is a suffix. Examples: the suffix of lint.tar.gz is tar.gz; that of .xshell.rc is xshell.rc; the suffix of foo. is the empty string; and neither .clisprc nor README have a suffix.

tag
A symbolic revision which identifies a baseline. Tags are used by disciplined developers, or configuration managers, to label software releases so that it is possible to later retrieve the exact baseline of any given release.

update
In CVS parlance, to retrieve a version of one or more documents from the repository, merge it with local changes made to the sandbox copy, if any, and then replace that copy. Updating is not only used to incorporate the latest changes from the repository into a sandbox, while preserving any outstanding local modifications, but it is also used for “navigating” to old versions and switching among branches.

Index

  • –meta option, 2.6
  • -b option
  • -R option
  • -u option
  • -z option, 2

  • add command, 2.5
    • -R option, 2.5


  • Blorg, 2.1
  • baseline, 2.1, A
  • basename, A
  • :binary, 2.1

  • Cederqvist, 1
  • CVS, A
    • import command, 2.1
  • CVSROOT, 1
  • checkout command, 2.2
  • commands
  • commit command, 2.4
  • create command, 2.1

  • :default, 2.1
  • diff command, 2.6
    • -b option, 2.6
    • -u option, 2.6
  • F-file, 2.3, A
  • filt command, 2.4

  • global options
    • –meta, 2.6
    • -z, 2
  • grep, 2.6

  • hard link, 2.3, A

  • Lisp, 2.1, A

  • MAP file, 2.3, 2.6
  • MCVS subdirectory, 2.3
  • mcvs program, 2
  • module, 2, A
  • moving
    • a sandbox, 2.2


  • png files, 2.1

  • RCS, 2.4
  • renaming, see moving

  • sandbox, 2, A
  • status command, 2.6
  • stream, 1, A
  • suffix, A

  • tag, 2.1, A

  • unlink system function, 2.3

  • working copy, see sandbox

1
But note that unlike CVS, Meta-CVS does not support the model of combining modules.
2
In case you are interested, that colon is a special Lisp notation which indicates that the following name refers to a symbol in the KEYWORD package.
3
This is why the POSIX system function for doing this is called unlink. Deleting a directory entry doesn't necessarily mean that a file is gone, only that a link, possibly not the last remaining link, has been erased.
4
This stands for check in, which means the same thing as commit in the jargon of the RCS version control system. RCS has a ci command, and this abbreviation survived into CVS.

This document was translated from LATEX by HEVEA.