Version Control on Mac OS X, Part 2
Pages: 1, 2, 3
As you perform CVS operations such as committing and adding files, this column reflects the file status. For example, if you modify a file in your working copy, Project Builder displays an M next to the file, indicating that you've modified the local file and that it is different from the head version in CVS.
Take a quick look at Project Builder’s CVS preferences by choosing Preferences
from the Project Builder menu and clicking on the CVS icon. Most of
the options are straightforward, but an interesting one is the Tool
for Comparisons pop-up menu. This menu enables you to choose the program
that Project Builder uses to display the differences between local files
and files in the repository. Currently, you can select Apple’s FileMerge
program, BBEdit’s file differences feature, or a different diff tool.
FileMerge, a GUI-based file comparison and merging program located in
the /Developer/Applications folder, is implemented as a GUI application
that uses the UNIX diff command, outputting its result to an ed script.
|
|
Project Builder enables access to CVS commands through its CVS menu. Let’s look at the commands Project Builder supports and their meaning.
- CVS > Refresh Status - Updates the CVS status information for the selected item.
- CVS > Update To
- CVS > Update To > Latest, Merge w/Local – Merges the head version from CVS into the selected file.
- CVS > Update To > Latest, Replace Local – Overwrites the working copy of the selected file with the head version.
- CVS > Update To > Previous – Removes your local changes to the selected file and returns the originally-checked-out version.
- CVS > Update To > Revision… - Removes your local changes to the selected file and uses a past version; Project Builder prompts you to select the version number from a list.
- CVS > Update To > Specific Revision - Removes your local changes to the selected file and uses a past version; you are prompted to enter the version number.
- CVS > Compare With
- CVS > Compare With > Latest – Compares the selected file (working copy) with the head version in the repository.
- CVS > Compare With > File… - Compares the selected file (working copy) with a file on disk; Project Builder prompts you to select a file.
- CVS > Compare With > Previous… - Compares the selected file (working copy) with the version you checked out.
- CVS > Compare With > Revision… - Compares the selected file (working copy) with a specific version in the CVS repository; Project Builder prompts you to select the version number from a list.
- CVS > Compare With > Specific Revision - Compares the selected file (working copy) with a specific version in the CVS repository; Project Builder prompts you to enter the version number.
- CVS > Add to repository… - Adds, or enrolls, the selected file (working copy) into the CVS records; you must commit the file (CVS > Commit Change) to add it to the repository.
- CVS > Commit Changes… - Adds, or publishes, the selected file's changes to the CVS repository.
- CVS > Show CVS – Shows a table of all files in the project with status information.
- CVS > Cancel Pending CVS Operation – Stops a running CVS operation.
- CVS > Disable CVS Integration – Temporarily turns off CVS support.
A common operation, not listed in the CVS menu, is removing files from the repository. To remove a file, select the file you wish to remove, press the Delete key, and follow the on-screen instructions. Another useful action is to get status information for a file. To accomplish this, choose a file from the file list, select Project > Show Info, and select the CVS tab.
Using CVS within Project Builder
Let’s look
at how to use CVS and Project Builder with the sample program. To start,
build MyPing (Build > Build) and run it a few times. Try pinging some
sites to get a feel for how the program works.
The first change we will make is to display a default host name in the
Host text field. First, click on, and open, the Classes disclosure triangle
(under Files & Groups), select PingController.m, and locate the init
method. This method uses three setValue messages to set the initial
host name and the displayed menu items. As you can see, these messages
currently set the host name to an empty string and the menu items to
position 2 and 1 –- using magic numbers.
[param setValue:@"-c":@"2"];
[param setValue:@"-i":@"1"];
[param setValue:@"-host":@""];
Let’s modify this by adding three constants and setting the values to these constant values. Update the code at the beginning of PingController.m to the following code snippet (the added code is marked in bold).
#import "PingController.h"
#import "AppSupport.h"
NSString *PING_CMD = @"/sbin/ping";
NSString *PING_BUTTON_IDLE = @"Ping";
NSString *PING_BUTTON_RUNNING = @"Stop";
NSString *DEFAULT_NUM_PINGS_POS = @"2";
NSString *DEFAULT_SECS_BETWEEN_PINGS = @"1";
NSString *DEFAULT_HOST = @"localhost";
@implementation PingController
- (id) init {
self = [super init];
param = [[PingParameters alloc] init];
directory = NSHomeDirectory();
pingInProgress = NO;
[param setValue:@"-c":DEFAULT_NUM_PINGS_POS];
[param setValue:@"-i":DEFAULT_SECS_BETWEEN_PINGS];
[param setValue:@"-host":DEFAULT_HOST];
return self;
}
Note that after saving the file, Project Builder displays an M in the CVS column. This indicates that you've modified the file. Rebuild the program and run. Now the new host name, "localhost," appears in the Host text field.
Since you added a new feature to the program, you should to record, or commit, your change into the CVS repository. To do this, select the modified file, PingController.m, from the file list, choose CVS > Commit Changes, enter a description of the change, and click the Commit button. Project Builder adds your changes to the CVS repository. Note that project Builder has removed the M from the CVS column and updated the ID tag at the top of the file.
Another common operation is to compare two versions of a file to see what has changed between revisions. For example, to compare what has changed between the two versions of PingController.m, select PingController.m from the file list and select CVS > Compare With > Previous. Project Builder uses the tool specified in its CVS preferences to compare the files, in this case FileMerge.
Another common action is to view status information on a file. Once again, select PingController.m from the file list, choose Project > Show Info, and select the CVS tab.
|
|
At this point, take some time to explore Project Builder’s other CVS commands. For example, try reverting to the original version of the PingController.m file by selecting it from the file list, choosing CVS > Update To > Revision, selecting version 1.1, and clicking on Update button. Remember, your changes are not lost; they are still in CVS as the head version of the file. This command just modifies your working copy.
Final Thoughts
This concludes our brief look at using CVS under Project Builder. As you have seen, Project Builder uses CVS as its default version control system, which means if you develop under Project Builder, you owe it to yourself to learn CVS. In spite of the fact that Project Builder only supports a subset of CVS commands, it does include enough functionally to make it very useful.
In the next article, we will add a few features to MyPing and create
a release using the CVS tag and branch commands. In addition, we will
look at other Mac OS X GUI-based interfaces to CVS, including BBEdit
and Concurrent Versions Librarian.
Kevin O'Malley is a long time Macintosh and UNIX developer. His articles have appeared in Dr. Dobb's Journal, IEEE Internet Computing, and The Perl Journal, and he is the author of Programming Mac OS X: A Guide for UNIX Developers.
Return to MacDevCenter.com
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 12 of 12.
-
XCode anyone?
2003-11-14 11:09:52 anonymous2 [Reply | View]
Hi,,
I tried 'open /Developer/Applications/Xcode.app /path/to/my/project' in order to open the checked out project with Xcode but Xcode refuses every password i put. There is an option for ssh (instead of rsh) but i couldin't get it to work either.. any help?
thank all
-
SSH Tunneling
2003-08-28 16:07:00 cochella [Reply | View]
Great article.
You offer two solutions on page two for launching/integrating PB with CVS via SSH:
1. Command line it all.
2. Use SSHKeys
It seems as though SSH tunneling would work quite well. Could you comment on this. If it would work well, would you mind posting an addendum for this third option in the context of your current steps.
Thanks in advance.
-
step 3. addendum
2003-08-22 07:12:02 effort [Reply | View]
change this :
setenv CVSROOT :ext:omalley@
cvshost.somedomain.edu:/Users/omalley/cvs-repository
to this (one-line):
setenv CVSROOT :ext:omalley@cvshost.somedomain.edu:/Users/omalley/cvs-repository
-
LinCVS for Mac OS X
2003-08-22 03:53:57 anonymous2 [Reply | View]
BTW, there are some graphical frontends to cvs for people who don't want using cvs via ProjectBuilder or want to use more cvs functions as are provided by ProjectBuilder.
One of these frontends is LinCVS. The next release of LinCVS (1.3.0, should be available in 08/2003) will support Mac OS X. A full functionally snapshot is available.
For further informations see here:
http://www.lincvs.org
Best regards, Tilo Riemer
-
MAC OS X 10.3
2003-08-13 08:43:49 anonymous2 [Reply | View]
Possibly a bit of a cheap option but iDisk on 10.3 will allow for constant backup of your dev folders over the web. Thus you would not stricktly have versioning but more like code-guard. To be honest versioning in Java dev should be more a matter of evolution of classes through additional methods, inheritance etc. and therefore there should be less of a need to revert to old versions of code. In the enterprise if you find that the same module or object is being repeatedly hit, you are in severe danger of causing collateral damage and should therefore be considering modularising that object. In any case it should be possible to ring-fence a single object for a single enterprise code release, which means once again that single point code-guard is a simple viable option in preference to proper version control.
TAPW124
-
what about binary files
2003-08-11 17:52:01 anonymous2 [Reply | View]
It would be great if you could walk through a tutorial to allow one to use binary files (especially nib files) with CVS. Also, a walk through for a local repository would be good. -
what about binary files
2004-02-24 18:21:48 narf_tm [Reply | View]
There is a replacement for the default cvswrappers file included with Xcode "/Developer/Tools/cvswrappers". Replace the one in your CVSROOT with it. It has many definition for handling binaries correctly. It also defines scripts for CVS to use to wrap and unwrap .nib files on the fly for you. -
what about binary files
2003-08-27 05:47:04 sboisson [Reply | View]
I add some lines to config files in CVSROOT module.
In "cvsignore" (to avoid putting PB backups and Finder files in repository):
.DS*
*~.*
In "cvswrappers" (to treat IB/standard OS X binary files the right way):
objects.nib -k 'b'
keyedobjects.nib -k 'b'
*.tiff -k 'b'
*.gif -k 'b'
*.pdf -k 'b'
-
what about binary files
2003-08-13 05:59:52 kom_14 [Reply | View]
To set up CVS for local access, do the following:
1. Open the Terminal application (located in /Applications/Utilities) and create a local directory to hold the CVS repository for your project.
2. Set the CVS environment variable CVSROOT to the location of the local repository (the directory you just created). Doing so enables CVS commands to locate files under version control. The following command sets the CVSROOT environment variable to the correct location (for the tcsh shell).
% setenv CVSROOT /Users/omalley/cvs-repository
3. From the Terminal, run the CVS initialization command to create the CVS administrative files in the repository:
% cvs -d /Users/omalley/cvs-repository init
You only need to run the cvs init command once, before anyone on the system uses the new repository.
For convenience, add the environment variable to your startup file. Doing so prevents you from entering it each time you open a shell. For tcsh shell, add them to your .cshrc file.
I do not set CVSROOT in .cshrc. Instead, I have a file called .alias that is source by my .cshrc. This files contains all my aliases, including setting the repository location for different projects:
alias cvs-proj1 'setenv CVSROOT /Users/omalley/proj1'
alias cvs-proj2 'setenv CVSROOT /Users/omalley/proj2'
This approach enables me to manually switch between multiple project repositories, something I do at work all the time.
Hope this helps.
-
Perforce is better but it isn't free
2003-08-11 08:53:17 anonymous2 [Reply | View]
CVS is free* and that's very important if you are developing commercial or shareware software on a shoestring budget. And this article does a great job describing how to use CVS. But if you have some cash and want a more powerful and robust version control system, Perforce is the better way to go. And as a bonus, the Apple claims XCode will also have support for Perforce in addition to CVS.
I don't work for Perforce, I just use it.
* Perforce is free if you are developing open source software. Take a look at http://www.perforce.com/perforce/price.html -
Perforce is better but it isn't free
2003-08-24 12:55:58 juanjose [Reply | View]
Would you PLEASE stop bugging us about Perforce? We're trying to learn about CVS. Why don't you wait until an article about Perforce comes out?
Besides, better is a subjective term that requires further clarification.
Why don't YOU write an article comparing the two, or as many products as you'd like? Do something useful, instead of sniping in the wrong direction.









For the time being everything I tried results in... nothing. Xcode does not get it source that has been added are already in cvs.
The nitty-gritty of what I tried is: checkout my source (C++), lots of them, the whole tree. Create a C++ tool project in Xcode and add the whole tree to the newly created project, activate SCM in Xcode and watch it does not work. Any idea, what is missing?