MIT Information Systems

Macintosh Development

[Home] [About Us] [People] [Information Systems]
[Kerberos for Macintosh] [Applications] [Miscellaneous Documentation]


CVS How-to

A guide to using CVS on the Macintosh in MIT I/S

By Miro Jurisic

Contents


Installing CVS utilities

Installing and configuring MacCVS

Installing and configuring CWCVS

Installing MIT Sync Linker

Not related to CVS, you need to get MIT Sync Linker from Pacific Grove and put it in your CodeWarrior Plugins folder, and relaunch the IDE after that.


Getting started

Understanding CVS in general

Coming soon. For now, have a look at CVS manual.

Understanding MacCVS

MacCVS is mostly just CVS wrapped in a user interface. For most commonly used command, MacCVS provides a menu command that executes the CVS command. The correspondence between MacCVS menu commands and equivalent CVS commands is:

MacCVS preferences are treated specially. CVS root, including the authentication method, is used to specify the CVSROOT environment variable (as seen by the CVS library), and is treated accordingly; this means that the only times when this setting is actually used is when there is no other way for CVS to determine what its CVS root is. Under normal operation, CVS gets this information from the folder in which it is operating (specifically from the CVS:Root file), and it ignores the CVS root specified in preferences. The two cases when you must have CVS root set appropriatelly are when you are running a checkout or import command. In all other cases, CVS root will be determined from the files and folders you operate on. This also means that if you check files out of the macdev repository and then change your settings to check something out from macdev_test repository, and then go back to do something with the files from the macdev repository without reverting your settings, MacCVS will do the right thing, and treat the files as being working files for the macdev repository.

The "Checkout read-only" preference corresponds to the CVSREAD environment variable; thus it can be overriden by passing the -w or -r flag to CVS commands. It affects checkout and update commands.

The "Enable TCP/IP compression" preference corresponds to the -z9 flag passed to CVS commands. Likewise, "Prune (remove) empty directories" corresponds to the -P flag.

The "More quiet (less messages)" preference corresponds to the -q option, and turns off most irrelevant messages from MacCVS. In general you can turn this off (although you might want to turn it on if you suspect something is going wrong).

The "Add control" preference, if enabled, will turn on warnings in that are displayed when you add a file to the repository that appears suspicious to MacCVS (you add a text file as binary or vice versa, you add a file containing high-bit characters without ISO conversion on, etc.). You can select which character set conversion MacCVS uses from the popup menu.

The "Use Internet Config" option enables using Internet Config mappings for text files.This is especially useful for .html and other documentation text files that are not CodeWarrior files.

MacCVS handles binary files specially. When creating a working file that is marked as binary in the repository (i.e., keybord substitution option 'b'), and the file is a Binhex file, it will convert it to a Mac file. If the file is not a Binhex file, it uses Internet Config to map the file name to the appropriate creator and type. Because of this, it is important that your Internet Config settings contain some file mappings needed to proprely checkout all files from the macdev repository; see the installation section for instructions on how to do this.

When adding a file to the repository (either via an add command or via an import command), MacCVS uses the standard CVS procedure to determine if the file is a binary file, i.e. it uses the cvswrappers administrative file, supplemented by command flags (-k for the add command, -W for the import command). See the sections on adding binary files and importing projects into CVS below for more information on how to add your files properly. Regardless of whether a file is marked as binary, if it contains a resource fork it is Binhexed on its way into the repository, unless it is specially treated by MacCVS; the files treated specially by MacCVS are files with creator 'TEXT' (text files), 'GIFf' (GIFs), 'JPEG' (JPEGs) and 'MMPr' (CodeWarrior Pro 1 and later project files). Files of type 'TEXT' are not binhexed unless they are marked as binary, in which case they are binhexed and their resources are preserved. Files of types 'GIFf', 'JPEG', and 'MMPr' are never binhexed, and their resource information is discarded. (The list of files for which resources are discarded can be modified by changing the 'bin#' resource with ID 128 in MacCVS.)


Understanding CWCVS

CWCVS is also just a wrapper around CVS &emdash; it maps the CodeWarrior version control commands onto CVS commands. The names of commands in the IDE menus are provided by the IDE; their functionality is provided by CWCVS.

The CodeWarrior version control menu provides four kinds of commands: plain, recursive, project, and other commands.

Plain commands are: Get, Checkout, Undo Checkout, Checkin, History, Status, Difference, Add, and Delete. When a source window is the front window, selecting a plain command will perform the command on the file open in the front window. When a project window is the front window and there are files selected in the project window, selecting a plain command will perform the command on the selected files.

Recursive commands are Get and Checkin. Selecting a recursive command will operate on the directory specified as your local root in the version control preferences; if you followed the instructions for configuring CWCVS, this means that if a project is open a resursive command will apply to the project folder of the default project, and if no project is open a recursive command will apply to the whole Macdev tree.

Project commands are Get, Checkout, Undo Checkout, Checkin, History, Status, Add, and Delete. They apply to the default project file.

Those commands (plain, recursive and project commands) correspond to the following CVS commands:

Other commands are Synchronize Status, Connect, Disconnect, About, and Variables.

The Synchronize Status command makes CW IDE update its internal variables which keep track of the current status of files in a project (i.e., checked in, checked out, writeable, locked, unlocked). The IDE indicates thestatus of a file with an icon in the rightmost coumn in the project file; the status of a project file is indicated with an icon in the bottom left corner of the project file. The possible icons are:

Choosing Connect will cause CWCVS to launch MacCVS if it's not already launched.

Chosing Disconnect does nothing with CWCVS.

Choosing About shows the CWCVS about box.

The Variables command will display MacCVS status of all files in your local root (and it will probably take quite some time to actually do that; you can abort this in CW IDE with command-period, but you cannot abort the processing in MacCVS).


CVS operations

Checking out a copy of the build tree

Since the modules administrative file is not yet properly configured, you should check out the entire tree and later delete parts that you think you don't need.

To checkout the entire tree, create a folder somewhere on your computer in which you want to hold the working files. Run MacCVS, and from Cvs main menu select Checkout module. Select the folder where you want the working files to be created, and give '.' as the name of the module to checkout. Take a 20 minute break.


Preparing to modify working files

MacCVS

Since the files are locked in the Finder, you need to unlock them. If you are using CWCVS, see the CWCVS section below. If you are not using CWCVS, you can unlock the files from the Finder Info window. You may wish to update the files to the most recent repository versions first (especially recommended if they are not text files), in which case you should choose 'Update files' from MacCVS 'Cvs files' menu and select the files to update, before unlocking them in the Finder.

CWCVS

To modify a text file in CodeWarrior, open it in the IDE. Assuming you correctly configured CWCVS, the version control menu will let you perform a checkout on the file. This updates the file to the most recent repository version, and makes it writeable. You can modify the file now, and commit it after you are satisfed with your modifications.

If you want to modify a CodeWarrior project file, you need to open it in the IDE and select Project:Checkout from the version control menu.

To modify a binary file that is not a project file, you need to open the project that contains that file (if the file is not in any project, you'll have to use MacCVS). Select the file in the project and choose Checkout from the version control menu. The file will be updated and made writeable. Modify it and commit the changes when done.

If you want to modify multiple files, select them all in a CodeWarrior project and choose Checkout from the version control menu.


Commiting files to the repository

MacCVS

In MacCVS, select 'Commit files' from 'Cvs files' menu. Add the desired files to the list and click Done. Type a log message, click OK, and the files will be committed. If commit fails because of conflicts, you will see a message to that effect in MacCVS window:

cvs server: Up-to-date check failed for `SillyBalls.c'
cvs [server aborted]: correct above errors first!

In that case you need to update the files and commit the changes again.

If you want to commit all files in a folder, recursively, use the 'Commit folder' command from the 'Cvs Main' menu; only the files in the folder that have been modified will be commited.

CWCVS

To commit a text file in CodeWarrior, open it in the IDE and use the Checkin command from the version control menu. You'll be prompted for a log message. If a file cannot be checked in because of a conflict, you will not be explicitly told so (I am working on getting this fixed). You can determine a file is not committed by checking its status in the version control status column in the project window, or by running the Status command from the version control menu. In the case of a conflict, you need to update the files and commit again.

To commit a project file, open it in the IDE and use the Project:Checkin command from the version control menu. Type a log message and the project will be committed. In the case of a conflict, just like with source files, the indicator in the bottom left conrner of the project window will show that the file has not been committed and you'll need to update the project file.

To commit a binary file that is not a project file, select it in a project that contains it and choose Checkin command from the version control menu. The indicator of success is again the icon in the project window, and if it shows the file has not been committed, you'll have to update the file before committing.

To commit recursively all files in your local root, use the recursive checkin command; only the files that have been modified will be commited.


Adding text files to the repository

MacCVS

From CVS Files menu, choose Add files and select the files you want to add. Click 'Done' and the selected files will be scheduled for addition to the repository. You still need to commit the files to complete the addition to the repository

CWCVS

Add the files to a project and select them in the project window. From the version control menu, choose the Add command. The files will be scheduled for addition to the repository; you need to commit them to complete the addition.


Removing files from the repository

MacCVS

From the CVS Files menu, choose Remove files and select the files to be removed. Click Done, and the selected files will be moved to the trash and scheduled for removal. You need to commit the files before they are actually removed from the repository.

CWCVS

Open a project containing the files. Select the files in the project window and choose the Delete command from the version control menu. The files will be moved to the trash and scheduled for removal, and you still need to commit them before they are removed from the repository. Obviously, you can't commit them by opening them in the IDE anymore, because they are in the Trash; you can commit them by selecting them in a project and using the Delete command from the version control menu, by using the recursive Checkin command, or by commiting the folder(s) containing the files from MacCVS.


Adding binary files to the repository

MacCVS

From CVS Files menu, choose Add binary files and select the files you want to add. Click 'Done' and the selected files will be scheduled for addition to the repository. You still need to commit the files to complete the addition to the repository

CWCVS

Use MacCVS.


Updating working files and resolving conflicts

MacCVS

When you run an update command, either on a folder or on a group of files, you may encounter merge conflicts if you modified a file and a new version was commited to the repository since you last updated it. You will know this because MacCVS will print out something like this (for a text file):

Merging differences between 1.1.1.1 and 1.2 into SillyBalls.c
rcsmerge: warning: conflicts during merge
cvs server: conflicts found in SillyBalls.c
C SillyBalls.c

When this happens, the file you were updating will contain conflict markers, for example:

<<<<<<< SillyBalls.c
BBB
=======
AAA
>>>>>>> 1.2

You then need to resolve the conflict and then commit the file. In case you need to refer to the version of the file you had before you attempted the update, it is saved in the same folder as the file, under a name starting with '.#'.

If you are updating a binary file and have a conflict, you will see a conflict error message like this:

U mit/lib/MITAthena/projects/MITAthenaCore.prj
cvs server: binary file needs merge
cvs server: revision 1.2 from repository is now in mit/lib/MITAthena/projects/MITAthenaCore.prj
cvs server: file from working directory is now in .#MITAthenaCore.prj.1.1

In this case, MacCVS does not attempt to merge the changes between files, and leaves it up to you to deal with it. No conflict markers are inserted in either file.

CWCVS

When you use the CWCVS checkout and get commands, they run MacCVS update command, and so they can exhibit the same behavior as MacCVS update command, namely of having a merge conflict and leaving conflict markers. CWCVS presently gives you no indication of this other than the conflict markers left in the files with a conflict. Since the conflict markers do not compile in any known language, you can always try compiling the files you updated to reveal merge conflicts.


Starting a new project and adding it to the repository

MacCVS

One obvious way to add a new project to the repository is to use the add command to add all files and folders. However, since you can't add files in a folder until you add the folder, this can quickly get tedious for larger projects. Thus, you might want to use the import command.

The first thing to do when importing a project into CVS is to run 'Pre-import stats' from 'Cvs Advanced' menu in MacCVS. It will tell you 4 things:

After you run pre-import stats and make sure that the folder you are about to import contains no extra files, prepare a list of all files that you want to be marked as binary. If you believe some of those belong into the cvswrappers file, edit the cvswrappers file, commit it, and then proceed.

With the list of files you want marked as binary, go to MacCVS command line and type:

cvs import -m <some message> -I ! -W "<file1> -k 'b'" -W "<file2> -k 'b'" <repository path> <project tag> macdev

where <some message> is a log message for your import (enclosed in quotes if it contains spaces), <repository path> is the location in the repository where you want the project imported (for example, mit/appl/MacDiscuss or "third/Internet Config"), <project name> is the name of the project tag (e.g., MacDiscuss, or Internet_Config), and <file1>, <file2>, etc. are the names of the files you want marked as binary (you can enter any number of -W "<file> -k 'b'" options). Because of the way CVS handles -W options, if the filename contains spaces, you will have to replace them with a ?; for example, -W "Silly?Balls.c -k 'b'".

Select the folder containing the project and run the command.


Tagging files

MacCVS

Tagging all files in a folder with a version tag associates a string (the tag) with the working revisions of those files; you can later use that tag to checkout a particular version of the project, or perform other operations on all the files with that tag.

To tag all files (recursively) in a folder, use MacCVS command line to run:

cvs tag <tag>

where <tag> is the tag you want to associate with the files. Valid characters in a tag are uppercase and lowercase letters, digits, hyphen ('-') and underscore ('_'). There are two common cases when you should be tagging files:

  1. Tagging a release of a project
    To tag a release of a project, you should use a tag containing the project name and the version, in the form ProjectName_1_2_3b4. For example, Glacier_1_0_1a1, or MacCVS_3_0b4r2.
  2. Tagging last revision of sources built with a particular version of CodeWarrior
    To tag the last revision of sources before upgrading a project to a new version of CodeWarrior, you should use a tag containing the version of CodeWarrior. It is extremely important these tags are the same for all projects &emdash; and you should therefore verify that you are using the right tag before tagging. These tags are of the form CodeWarrior_Pro_1_Last.


Getting the status of a working file

MacCVS

Use the Status command from the Cvs Files menu to select the files get the status.

CWCVS

Use the Status command from the version control menu in the IDE after selecting the files in the project or opening the files in the IDE.


Getting the history log of a file

MacCVS

Use the Log command from the Cvs Files menu to select the files and get the log.

CWCVS

Use the Status command from the version control menu in the IDE after selecting the files in the project or opening the files in the IDE.


Getting the differences between the working file and the repository

MacCVS

Use the Diff command from the Cvs Files menu to select the files and get the differences.

CWCVS

Use the Difference command from the version control menu in the IDE after selecting the files in the project or opening the files in the IDE.


Starting a new branch

MacCVS

To start a new branch in MacCVS, you need to use the tag command with the -b switch. This will create a new branch using the tag for the symbolic name of the branch, and it will make the tag sticky (i.e., all CVS operations you perform on thus tagged files will refer to the version on the branch, not on the trunk).

To do this, use MacCVS command line:

cvs tag -b <tag>

in the folder you want to branch off.

After doing this, you must update the folder. If you don't do this properly, the files you add to the folder will not be added on the branch, but on the trunk, and you will soon get very very confused. To update the folder properly, run:

cvs update -d -r <tag>

in the folder you just tagged, using the same tag. After this, you can modify and commit the files, and the changes will be commited to the branch.


Getting sources from a branch

MacCVS

To update a folder to the sources in a branch different from the one it currently contains, use the update command:

cvs update -d -r <tag>


Getting sources from the trunk

MacCVS

To update a folder to the sources on the trunk, use the update command:

cvs update -A


Merging sources from a branch into the trunk

MacCVS
  1. Commit the changes to the branch
  2. Get the sources from the trunk
  3. Merge the banch into the trunk:
    cvs update -j <branch tag>
  4. Commit the merged sources into the trunk

Questions or comments? Send mail to macdev@mit.edu
Last updated on $Date: 2003/11/18 21:58:36 $
Last modified by $Author: smcguire $