3 # cvs2vendor - move revsisions from files in A to files in B
5 # The primary reason for this script is to move deltas from a
6 # non-vendor branched repository onto a fresh vendor branched one,
7 # skipping the initial checkin in assumption that it is the same in
8 # both repositories. This way you can take a project that was moved
9 # into CVS without the benefit of the vendor branch and for all
10 # intents and purposes add the vendor branch underneath the existing
13 # This script is also a decent example of repository maintenance using
14 # raw RCS commands (if I do say so myself! ;-).
18 # The timestamp of the initial vendor branch revision will be adjusted
19 # to be the same as the 1.1 revision of each source file.
21 # Extra branches in the source directory will cause breakage.
23 # Intermediate files are created in the current working directory
24 # where this script is started.
26 # Written by Greg A. Woods <woods@planix.com>, based on rcs2sccs
27 # (retains some of the rlog parsing from it).
29 # The copyright is in the Public Domain.
33 echo USAGE
: $0 srcdir dstdir
39 revfile
=/tmp
/cvs2vendor_$
$_rev
42 commentfile
=/tmp
/cvs2vendor_$
$_comment
45 srcdirs
=`cd $tsrcdir && find . -type d -print | sed 's~^\.[/]*~~'`
47 # the "" is a trick to get $tsrcdir itself without resorting to '.'
48 for ldir
in "" $srcdirs; do
53 # Loop over every RCS file in srcdir
55 for vfile
in $srcdir/*,v
; do
56 # get rid of the ",v" at the end of the name
57 file=`echo $vfile | sed -e 's/,v$//'`
58 bfile
=`basename $file`
60 if [ ! -d $dstdir ]; then
61 echo "making locally added directory $dstdir"
64 if [ ! -f $dstdir/$bfile,v
]; then
65 echo "copying locally added file $dstdir/$bfile ..."
70 # work on each rev of that file in ascending order
71 rlog
$file |
grep "^revision [0-9][0-9]*\." |
awk '{print $2}' |
sed -e 's/\./ /g' |
sort -n -u +0 +1 +2 +3 +4 +5 +6 +7 +8 |
sed -e 's/ /./g' > $revfile
73 for rev in `cat $revfile`; do
77 newdate
=`rlog -r$rev $file | grep "^date: " | awk '{printf("%s.%s\n",$2,$3); exit}' | sed -e 's~/~.~g' -e 's/:/./g' -e 's/;//' -e 's/^19//'`
78 olddate
=`rlog -r1.1.1.1 $dstdir/$bfile | grep "^date: " | awk '{printf("%s.%s\n",$2,$3); exit}' | sed -e 's~/~.~g' -e 's/:/./g' -e 's/;//' -e 's/^19//'`
79 sed "s/$olddate/$newdate/" < $dstdir/$bfile,v
> $dstdir/$bfile.x
80 mv -f $dstdir/$bfile.x
$dstdir/$bfile,v
81 chmod -w $dstdir/$bfile,v
82 symname
=`rlog -h $file | sed -e '1,/^symbolic names:/d' -e 's/[ ]*//g' | awk -F: '$2 == "'"$rev"'" {printf("-n%s:1.1.1.1\n",$1)}'`
83 if [ -n "$symname" ]; then
84 echo "tagging $file with $symname ..."
85 rcs
$symname $dstdir/$bfile,v
87 echo ERROR
- rcs
$symname $dstdir/$bfile,v
91 continue # skip first rev....
95 # get a lock on the destination local branch tip revision
96 co
-r1 -l $dstdir/$bfile
98 echo ERROR
- co
-r1 -l $dstdir/$bfile
103 # get file into current dir and get stats
104 date=`rlog -r$rev $file | grep "^date: " | awk '{printf("%s %s\n",$2,$3); exit}' | sed -e 's/;//'`
105 author
=`rlog -r$rev $file | grep "^date: " | awk '{print $5; exit}' | sed -e 's/;//'`
107 symname
=`rlog -h $file | sed -e '1,/^symbolic names:/d' -e 's/[ ]*//g' | awk -F: '$2 == "'"$rev"'" {printf("-n%s\n",$1)}'`
109 rlog
-r$rev $file |
sed -e '/^branches: /d' -e '1,/^date: /d' -e '/^===========/d' |
awk '{if ((total += length($0) + 1) < 510) print $0}' > $commentfile
111 echo "==> file $file, rev=$rev, date=$date, author=$author $symname"
113 co
-p -r$rev $file > $bfile
115 echo ERROR
- co
-p -r$rev $file
119 # check file into vendor repository...
120 ci
-f -m"`cat $commentfile`" -d"$date" $symname -w"$author" $bfile $dstdir/$bfile,v
122 echo ERROR
- ci
-f -m"`cat $commentfile`" -d"$date" $symname -w"$author" $bfile $dstdir/$bfile,v
127 # set the default branch to the trunk...
128 # XXX really only need to do this once....
129 rcs
-b1 $dstdir/$bfile
131 echo ERROR
- rcs
-b1 $dstdir/$bfile
140 echo " Conversion Completed Successfully"