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.
-
cvswrappers for file-like directories
2003-08-09 04:14:26 anonymous2 [View]
-
CVL - CVS GUI for Mac OS X
2003-07-22 05:39:16 anonymous2 [View]
-
Subversion
2003-07-22 04:43:05 anonymous2 [View]
-
Subversion on Macs
2005-01-31 07:24:08 mizumitai [View]
-
Directories
2003-07-19 10:54:22 anonymous2 [View]
-
Versions
2003-07-18 14:14:11 maartensneep [View]
-
Versions
2003-10-18 17:00:19 benpoole [View]
-
Combine with Folder Actions
2003-07-18 09:25:00 anonymous2 [View]
-
Unison is based on rsync
2003-07-16 11:20:02 anonymous2 [View]
-
rsync
2003-07-16 01:02:53 anonymous2 [View]
-
Great article
2003-07-15 22:31:32 anonymous2 [View]
-
Check out Unison
2003-07-15 18:02:08 anonymous2 [View]
-
Resource Fork
2003-07-15 17:31:15 anonymous2 [View]


