User Tools

Site Tools


docs:tips_n_tricks:rcs.html

Using RCS

Simple usage for config files

Consider you want to have only a local revision control for some single files, e.g. confguration files below /etc. A remote server or centralized storage might be an overhead, so lets do revision control locally in the same director with RCS. This is an example to handle /etc/hosts with RCS. It assumes, that you don't care about locking other users out, as it is only used by root anyway.

To initially create the revision control file inside /etc/RCS/ (i.e. locally) with the current file hosts as initial version.

cd /etc
mkdir RCS
ci -l -d hosts

To checkin further updates, use

ci -l -d hosts

the -l is needed, as RCS by default removes files on checkin. This will keep it checked out and locked (for further editing)

To do a rollback to version 1.3 , use

co -r1.3 -M hosts

To list all versions with changelog information, use

rlog hosts

To compare the current file with the last version checked in, do

rcsdiff hosts

To compare versions 1.2 and 1.4, use

rcsdiff -r1.2 -r1.4 hosts

Recover from errors

rcs: RCS file RCS/XXX,v is in use

After a crash of one of the rcs binaries, the folloing situation might arise:

~ $ rcs -u1.1.1.1 abcd
rcs: RCS file RCS/abce,v is in use
~ $

The cure is to remove a semaphore file:

~ % ls -la RCS
total 8
-r--r--r-- 1 user users    0 Nov 19 14:00 ,abcd,
drwxr-xr-x 2 user users 4096 Nov 19 14:00 ./
drwxr-xr-x 3 user users 4096 Nov 19 13:59 ../
-r--r--r-- 1 user users 2665 Nov 19 14:00 abcd,v
~ $ rm -i RCS/,abcd,
rm: remove regular empty file `RCS/,abcd,'? y
~ $ rcs -u1.1.1.1 grub
RCS file: RCS/abcd,v
1.1.1.1 unlocked
done
~ $

Initial, recursive checkin

mk_rcs_dir.sh
find *pattern* -type d -not -path '*/RCS' -exec mkdir -vp '{}/RCS' ';'
find *pattern* -type f -not -path '*/RCS/*' -exec ci -l -d -i -t- -minitial '{}' ';'
docs/tips_n_tricks/rcs.html.txt · Last modified: 13.01.2024 11:56 CET by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki