CVS Patching Tutorial 1
by Peter Bojanic
Scenario: You customize a file that is under CVS control with some local changes (e.g. hostname, owner) and some common changes (e.g. application logic, host-independent variables). You need to commit some of your changes but not others.
I'm working with a file called BE_config.php. There are some local customizations to make Back-End work on my machine and there are some common changes that need to be check into cvs.
1. First, move the working file out of the way:
$ mv BE_config.php BE_config.php-peter
2. Now, let's get the latest version from cvs:
$ cvs update BE_config.php
h3>3. Find the differences, saving the output to a patch file
$ diff BE_config.php BE_config.php-peter > patchfile
4. Edit the patch file and remove the differences you don't want. In this case I want to remove this particular host-specific change:
97,98c97,98 'en', 'fr');---> $_BE['languagedomains'] = array ('bojanic.ca' => 'en',> 'french-bojanic.ca' => 'fr');
5. Apply the revised patch file to the fresh working copy:
$ patch BE_config.php patchfile
patching file BE_config.php
6. Finally, commit the changes to cvs:
$ cvs commit BE_config.php
new revision: 1.61; previous revision: 1.60
If you need to continue working with the file that contains all of the revisions, just delete the most recent working copy and move your back into place
mv BE_config.php-peter BE_config.php
When other cvs users update their own working copies from the source repository, cvs will patch in the new revisions and leave your own local revisions alone. cvs reminds us that we have local modifiations to this file by showing us the "M" flag in the update log.
cvs server: Updating .
RCS file: /cvsroot/back-end/back-end0.5.x/public_html/BE_config.php,v
retrieving revision 184.108.40.206
retrieving revision 220.127.116.11
Merging differences between 18.104.22.168 and 22.214.171.124 into BE_config.php
If there are any merge conflicts that cvs can't sort out by itself, it will show the "C" status in the update log
About The Author
Mike Gifford is the founder of OpenConcept Consulting Inc, which he started in 1999. Since then, he has been particularly active in developing and extending open source content management systems to allow people to get closer to their content. Before starting OpenConcept, Mike had worked for a number of national NGOs including Oxfam Canada and Friends of the Earth.