In Sync with CVS
Pages: 1, 2, 3
Day to Day Use
Now that we've successfully checked out the repository onto two machines, we're ready to start using CVS for our files. The rest of this section will give you the basic commands you need to work with your files.
Adding Files
Let's say that we want to keep some pictures in the repository. To do so, we'd create a Pictures subdirectory in our checked out copy of the repository, copy the images into them, and then add the files to CVS.
The following commands illustrate how we might do that:
[Mercury:~/tmp] duncan% mkdir Pictures
[Mercury:~/tmp] duncan% cp ~/Pictures/me.jpg Pictures/me.jpg
[Mercury:~/tmp] duncan% cvs add Pictures
Directory /Library/Depot/Pictures added to the repository
[Mercury:~/tmp] duncan% cvs add Pictures/me.jpg
cvs add: scheduling file `Pictures/me.jpg' for addition
cvs add: use 'cvs commit' to add this file permanently
[Mercury:~/tmp] duncan% cvs commit -m "Sync"
cvs commit: Examining .
cvs commit: Examining CVSROOT
cvs commit: Examining Pictures
RCS file: /Library/Depot/Pictures/me1.jpg,v
done
Checking in Pictures/me.jpg;
/Library/Depot/Pictures/me.jpg,v <-- me.jpg
initial revision: 1.1
done
To checkout the file onto the other machine, we would issue the cvs update command as follows:
[Mercury:~/tmp] duncan% cvs update -d
The -d option to the update command tell CVS to check out
any subdirectories that were added since the last time we performed an
update. You should see the following output:
cvs update: Updating .
cvs update: Updating CVSROOT
cvs update: Updating Pictures
U Pictures/me.jpg
Voila! Your data is now mirrored and updated between multiple
machines. Anything you add to one machine will appear on other
machines. All you need to remember to do is to add files to the
repository, and to regularly run the cvs update -d
command.
Removing Files
Occasionally you'll want to remove a file from the repository. To do so, simply remove the file, then issue a cvs delete command. Here's an example:
[Mercury:~/tmp] duncan% rm Pictures/me.jpg
[Mercury:~/tmp] duncan% cvs delete Pictures/me.jpg
cvs remove: scheduling `Pictures/me.jpg' for removal
cvs remove: use 'cvs commit' to remove this file permanently
[Mercury:~/tmp] duncan% cvs commit -s "Sync"
cvs commit: Examining .
cvs commit: Examining CVSROOT
cvs commit: Examining Pictures
Removing Pictures/me.jpg;
/Library/Depot/Pictures/me.jpg,v <-- me.jpg
new revision: delete; previous revision: 1.1
done
Moving files is a pain with CVS. There is no cvs move command, so you have to delete the file from where it was and add it to wherever else you want it to be.
|
Related Reading CVS Pocket Reference |
Applying CVS to our Scenario
So now that we've learned how to use CVS, how should we use it? Well, the answer is "it depends". Everyone's sweet spot will be different, but after using CVS to maintain my data on multiple machines for several years, here's a set of guidelines:
Don't check in your entire home directory into CVS. There's a lot of data there that you don't need to replicate. Instead, focus on just checking in the important things: your documents.
Don't check in applications. Again, it's the data that is important. You can install the same application on multiple machines easily. What CVS is best at is making sure that your data files for those applications are mirrored across all of your machines.
That said, CVS is the perfect place to stash your shell scripts and other goodies that you might have in your
~/bindirectory.Do make sure that you have the appropriate binary flag set in
CVSHOME/cvswrappersbefore checking in a binary file for the first time. If you don't you could have trouble later.
In general, I keep the contents of my ~/Documents folder
in CVS which lets me have all of my documents with me wherever I go. As
well, I keep my ~/bin folder in CVS so that all of my shell
scripts and command line tools stay with me. And, finally, I keep all of
my Code in a ~/Code folder. To keep these updated, I have a
script (in ~/bin that executes the following:
cd ~/Code
cvs update
cd ~/Documents
cvs update
cd ~/bin
cvs update
You'll want to come up with whatever scheme makes the most sense for your usage patterns. Experiment a little bit. See what works. But by starting with these guidelines, you should find your sweet spot faster.
CVS Gotchas
CVS is by no means the perfect tool for the job. People that use Source Code Management (SCM) tools (the fancy term for the task that CVS performs) will tell you all sorts of nits that they have with CVS. These nits usually include the fact that even when you check in three files together, CVS doesn't note that the versions of those three files are related. As well, moving files in CVS is problematic. You have to first delete the file from CVS and then add it in its new location. Not only is this burdensome, but you loose the history of the file.
Even with these faults, CVS is a very useful tool to use when maintaining your data across multiple machines. And looking to the future, there is a successor to CVS in development called Subversion which will ease many of the woes of CVS. You can find more out about Subversion at http://subversion.tigris.org/.
CVS Resources
This article gets you started with using CVS to manage your data. However, at some point you'll probably want to dig deeper into what CVS can do. The following resources can be of help:
CVS Pocket Reference, by Gregor N. Purdy (published 2000 by O'Reilly and Associates, with a 2nd Edition due in August). This small and affordable little guide gives you the complete list of CVS commands and options to those commands.
The CVS site, located at http://www.cvshome.org/. This website contains the source code for CVS, FAQs, and the 184 page "official" user manual for CVS by Per Cederqvist, et al.
James Duncan Davidson is a freelance author, software developer, and consultant focusing on Mac OS X, Java, XML, and open source technologies. He currently resides in San Francisco, California.
Return to the Mac DevCenter.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 17 of 17.
-
CVL - CVS GUI for Mac OS X
2003-07-22 05:39:16 anonymous2 [Reply | View]
Check out CVL, a really good Cocoa GUI front end for CVS:
http://sente.epfl.ch/software/cvl/
-
Subversion
2003-07-22 04:43:05 anonymous2 [Reply | View]
Although not officially "production" ready, I've been using Subversion to back up my system:
http://subversion.tigris.org/
It handles binary diffs and moving files, two of the biggest day-to-day problems I've had with using CVS. It also uses HTTP/WebDAV as its transfer protocol, which makes my company's sys-admin happy. The command line interface is very CVS-like, so it wasn't hard to pick up once I understood the underlying architectural differences
On the down side, it's /much/ more complex than CVS at this point, and took a while to install on my TiBook.
Here’s a good o’reillynet article from last year on subversion if you’re curious:
http://www.onlamp.com/pub/a/onlamp/2002/10/31/subversion.html
-
Subversion on Macs
2005-01-31 07:24:08 mizumitai [Reply | View]
I did the install and set up for Subversion (client) in an hour, including waiting a little on the server admin for my user stuff. But, maybe something has improved from a previous version?
What I did:
1) Install the Subversion 1.1.3 package from Martin Ott of SubEthaEdit fame:
http://www.codingmonkeys.de/mbo/
2) Install svnX:
http://www.lachoseinteractive.net/en/community/subversion/svnx/download/
3) Set up my ssh login: Create my user with the svn group on the server. Add the line "umask 002" to my .bash_profile. Set up password-less login with ssh-keygen by copying my public key to the authorized_keys file in ~/.ssh/ on the server.
4) Get the admin (or someone with sudo) to make the respository folder: "svnadmin create /home/svn//myRespository/"
5) Open svnX. Specify the respository string. If you're using ssh, something like "svn+ssh://username@example.com/myRepository/". Also specify the local checkout directory in the Working Copies window.
6) Check out your respository from the server. Add files and folders to your working copy. Click the Add or Update button as necessary to commit to the server.
7) Check to make sure everything was added properly by clicking Go to Repository.
And that was it...
And, at least for my test cases, Subversion seems to handle resource forks okay...
-
Directories
2003-07-19 10:54:22 anonymous2 [Reply | View]
If you thought moving files between directories was hard, try playing with directories.
CVS is a neat idea for file access, but without a decent UI, at least for most users, it is going to be a hassle. I feel that the article is advertising using CVS as a means to access files on multiple computers (and having a version history is just a nice "Extra"). Why not just use SSH straight up with scp? Or maybe tunneling AFP through SSH. Then you could connect securely over the internet and get to your files using the standard Finder interface.
-
Versions
2003-07-18 14:14:11 maartensneep [Reply | View]
One of the advantages of this system is that you can get older versions back. The disadvantage is the user interface, or lack thereof.
Suggestions for a user interface for CVS (I was thinking about what SourceForge uses: a web based interface (run locally on Apache and perl or PHP). What can you recommend?
Maarten
-
Combine with Folder Actions
2003-07-18 09:25:00 anonymous2 [Reply | View]
What about automating CVS (or one of the other tools mentioned in other comments) with AppleScript folder actions? Seems like it would be pretty easy to set up one that would execute all the cvs add and commit commands whenever you added a new file/folder to your sync'd directory. (I'm not sure how you'd handle an offline condition though, like when you're on the road with a laptop and not connected)
-
Unison is based on rsync
2003-07-16 11:20:02 anonymous2 [Reply | View]
Unison is a "bidirectional rsync" with conflict resolution...
-
rsync
2003-07-16 01:02:53 anonymous2 [Reply | View]
Rsync is much less effort if you can live w/o history.
-
Great article
2003-07-15 22:31:32 anonymous2 [Reply | View]
This is a great article as I think many people would be having this problem. CVS seems like a "good" solution (ie not too much deviation from standard OS X toolset), but in reality is not adequate as pointed out in other comments. (also it leaves CVS folders all over the place - very annoying)
Another great subject for an article would be using OpenLDAP to keep user log-ins/files syncronised between two Mac like this. I have the problem where I want my wife and I to be able to use our two Macs interchangably (one always-on desktop and one laptop). ATM it is too complicated - our files just stay on one or other Mac.
-
Check out Unison
2003-07-15 18:02:08 anonymous2 [Reply | View]
If you don't require file history Unison is probably a better tool. From the homepage:
Unison is a file-synchronization tool for Unix and Windows. (It also works on OSX to some extent, but it does not yet deal with 'resource forks' correctly; more information on OSX usage can be found on the unison-users mailing list archives.) It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other.
See http://www.cis.upenn.edu/~bcpierce/unison/index.html
-
Resource Fork
2003-07-15 17:31:15 anonymous2 [Reply | View]
Will CVS stumble over files with resource forks and other HFS file attributes. It seems likely as most unix tools will. I realize that it is only a problem with apps, but as a developer, I have apps and resource files that I use as documents. -
Resource Fork
2003-07-22 02:19:10 anonymous2 [Reply | View]
So, how CAN I put a library of Applscripts under CVS control? Is there any way to do it? -
Resource Fork
2003-07-15 19:46:49 anonymous2 [Reply | View]
CVS doesn't deal at all with resource forks. -
Resource Fork
2003-07-16 17:28:41 anonymous2 [Reply | View]
Yeah, I found that out the hard way today when I tried to access an AppleScript from my CVS repository. It had been saved as a compiled text and came up blank when checked out of CVS. Argh! We can always hope CVS will be improved to handle these elements too, especially now that I hear that Linux is playing with adding an meta-file implementation using resource forks. While the Mac takes a step backwards, maybe these guys will go forward.







/Developer/Tools/cvswrappers
- Martina