#!/bin/sh # Sometimes the CVS/Repository files end up not being relative # to the path in CVS/Root. Dunno why, but it breaks things when # you switch CVS/Root. This script fixes that. usage () { cat < [] Change prefix from cwd's CVS/Repository contents cvsrep -r [] Recursively change prefix from CVS/Repository files EOF exit 1 } [ "$1" = '-h' ] && usage if [ $# = 0 ]; then cat CVS/Repository exit 0 fi if [ "$1" = '-r' ] && [ $# = 1 ]; then find . -path '*/CVS/Repository' -print0 | xargs -0 cat exit fi if [ "$1" = '-d' ] && [ $# = 1 ]; then find . -path '*/CVS/Repository' -print0 | perl -w0lne ' s!^\./!!; $width = length if length > ($width || 0); push @files, $_; END { foreach $file (@files) { open(F, $file) or die "open($file): $!\n"; (my $contents = ) =~ s/\n*$//; close(F); printf "%-${width}s %s\n", $file, $contents; } }' exit fi if [ "$1" = '-r' ]; then recursive=yes shift fi old_prefix="$1" new_prefix="$2" if [ -z "$recursive" ]; then perl -pi -e "s,^$old_prefix/?,$new_prefix," CVS/Repository else find . -path '*/CVS/Repository' -print0 | xargs -0 perl -pi -e "s,^$old_prefix(/?),$new_prefix\$1," fi