Mike Schilli's Friendly Neighborhood Perl Shop

Home
USArundbrief.com
Resume
CPAN Modules
Articles in English
Articles in German
Mike's Script Archive
English-Japanese Translation Trainer
Adventures with O'Reilly's Safari
10 Easy Steps to Become a California Driver
Unofficial perlmonks.com IRC Channel
My Collection of Outage Pages
Prisma (Computer Club Deutschland)
The Mike Schilli Monologues
Mike's Monologues

Safe CVS Patch

cvs-1.11.22-safe-patch.txt

This patch for cvs-1.11.22 prevents CVS from nuking your private workspace data when you're talking to an unreliable CVS server.

None of the problems described below will happen if the CVS server is reliable. However, if you're hosting with companies like dreamhost.com, you need to prepare for disaster (I lost data this way, that's why I wrote the patch).

To enable the patch, compile the cvs source with it:

    $ tar zxf cvs-1.11.22.tar.gz
    $ cd cvs-1.11.22
    $ patch -p1 <../cvs-1.11.22-safe-patch.txt
    $ ./configure
    $ make
    $ sudo make install

By default, the patch will be disabled, to enable it, modify your ~/.cvsrc file and add the new --safe-mode option:

    ### ~/.cvsrc
    cvs --safe-mode

There's two horror scenarios in which CVS will lose data on the client side if the server provides false information:

  • The server version of a file gets accidentally deleted. Now your only chance is the local copy. But you have no idea that the server information got lost and run 'cvs update', which causes CVS to remove the file in your local workspace, nuking the last valid copy.

    With the --safe-mode option enabled in ~/.cvsrc, CVS will protect your local workspace data:

        $ cvs upd
        cvs update: Updating .
        cvs update: `abc' is no longer in the repository
        *SAFE MODE*
        Protecting against removing abc
        Copying abc to abc.cvsbak

  • The server version of a CVS file gets reset to a previous revision. This can happen if a careless server administrator resets the server to a previous backup baseline without telling the clients. If the unsuspecting client then runs 'cvs update', CVS will nuke the local copy (given that it was checked in) and replace it by the outdated server copy.

    With the --safe-mode option enabled, CVS will protect your local workspace data:

        $ cvs upd
        cvs update: Updating .
        U abc
        *SAFE MODE*
        Protecting against renaming .new.abc to abc
        Copying abc to abc.cvsbak

With the --safe-mode option enabled, CVS will save your local data in both cases in backup files with the .cvsbak extension. In a pinch, you can use them to restore your updated/deleted local files. If they're no longer needed, they can be safely deleted.

If you need to disable safe mode temporarily for one command although by default it is enabled in ~/.cvsrc, use the -F option:

    cvs -F upd

and CVS will override --safe-mode and remove the safety net.

Author

Mike Schilli, 2007, m@perlmeister.com


Latest update: 20-Oct-2013