GNU Info

Info Node: (cvsbook.info)cvslock -- Lock Repositories For Atomicity

(cvsbook.info)cvslock -- Lock Repositories For Atomicity


Next: cvsq -- Queue CVS Commands For Later Connection Prev: cvs2cl -- Generate GNU-Style ChangeLogs Up: Third-Party Tools
Enter node , (file) or (file)node

cvslock - Lock Repositories For Atomicity
=========================================

Depends on: C compiler for installation; nothing for runtime

URL: `ftp://riemann.iam.uni-bonn.de/pub/users/roessler/cvslock/'

This program locks a CVS repository (either for reading or writing) in
the same way that CVS does, so that CVS will honor the locks.  This can
be useful when, for example, you need to make a copy of the whole
repository and want to avoid catching parts of commits or other people's
lockfiles.

The cvslock distribution is packaged extremely well and can be installed
according to the usual GNU procedures.  Here's a transcript of an
install session:

     floss$ zcat cvslock-0.1.tar.gz | tar xvf -
     cvslock-0.1/
     cvslock-0.1/Makefile.in
     cvslock-0.1/README
     cvslock-0.1/COPYING
     cvslock-0.1/Makefile.am
     cvslock-0.1/acconfig.h
     cvslock-0.1/aclocal.m4
     cvslock-0.1/config.h.in
     cvslock-0.1/configure
     cvslock-0.1/configure.in
     cvslock-0.1/install-sh
     cvslock-0.1/missing
     cvslock-0.1/mkinstalldirs
     cvslock-0.1/stamp-h.in
     cvslock-0.1/cvslock.c
     cvslock-0.1/cvslock.1
     cvslock-0.1/snprintf.c
     cvslock-0.1/cvslssh
     cvslock-0.1/VERSION
     floss$ cd cvslock-0.1
     floss$ ./configure
      ...
     floss$ make
     gcc -DHAVE_CONFIG_H -I. -I. -I.   -g -O2 -c cvslock.c
     gcc -g -O2  -o cvslock  cvslock.o
     floss$ make install
      ...
     floss$

(Note that you may have to do the make install step as root).

Now, cvslock is installed as /usr/local/bin/cvslock.  When you invoke
it, you can specify the repository with -d or via the $CVSROOT
environment variable, just as with CVS itself (the following examples
use -d).  Its only required argument is the name of the directory to
lock, relative to the top of the repository.  That directory and all of
its subdirectories will be locked.  In this example, there are no
subdirectories, so only one lockfile is created:

     floss$ ls /usr/local/newrepos/myproj/b-subdir/
     random.c,v
     floss$ cvslock -d /usr/local/newrepos  myproj/b-subdir
     floss$ ls /usr/local/newrepos/myproj/b-subdir/
     #cvs.rfl.cvslock.floss.27378  random.c,v
     floss$ cvslock -u -p 27378 -d /usr/local/newrepos  myproj/b-subdir
     floss$ ls /usr/local/newrepos/myproj/b-subdir/
     random.c,v
     floss$

Notice that when I cleared the lock (-u for `unlock'), I had to specify
`-p 27378'.  That's because cvslock uses Unix process IDs when creating
lockfile names to ensure that its locks are unique.  When you unlock,
you have to tell cvslock which lock instance to remove, even if there's
only one instance present.  Thus, the -p flag tells cvslock which
previous instance of itself it's cleaning up after (you can use -p with
or without -u, though).

If you're going to be working in the repository for a while, doing
various operations directly in the file system, you can use the -s
option to have cvslock start up a new shell for you.  It then consults
the `$SHELL' environment variable in your current shell to determine
which shell to use:

     floss$ cvslock -s -d /usr/local/newrepos myproj

The locks remain present until you exit the shell, at which time they
are automatically removed.  You can also use the -c option to execute a
command while the repository is locked.  Just as with -s, the locks are
put in place before the command starts and removed when it's finished.
In the following example, we lock the repository just long enough to
display a listing of all of the lockfiles:

     floss$ cvslock -c 'find . -name "*cvslock*" ' -d /usr/local/newrepos myproj
     cvslock: '/usr/local/newrepos/myproj' locked successfully.
     cvslock: Starting 'find . -name "*cvslock*" -print'...
     ./a-subdir/subsubdir/#cvs.rfl.cvslock.floss.27452
     ./a-subdir/#cvs.rfl.cvslock.floss.27452
     ./b-subdir/#cvs.rfl.cvslock.floss.27452
     ./#cvs.rfl.cvslock.floss.27452
     floss$ find /usr/local/newrepos/myproj -name "*cvslock*" -print
     floss$

The command (the argument to the -c option) is run with the specified
repository directory as its working directory.

By default, cvslock creates read-locks.  You can tell it to use
write-locks instead by passing the -W option.  (You can pass -R to
specify read-locks, but that's the default anyway.)  Always remove any
locks when you're finished, so that other users' CVS processes don't
wait needlessly.

Note that cvslock must be run on the machine where the repository
resides - you cannot specify a remote repository.  (For more
information, run `man cvslock', which is a manual page installed when
you ran `make install'.)


automatically generated by info2www version 1.2.2.9