#!/bin/rc fn usage { echo 'usage: vcs/submit [file1] [file2] ... [fileN]' >[1=2] echo ' file: file or directory to store in versioned archive' >[1=2] exit usage } fn errruninit { echo 'You must first run vcs/init before you can run' >[1=2] echo 'vcs/submit in this directory.' >[1=2] exit runinit } fn errvac { echo 'Vac exited with an error.' >[1=2] echo 'Please ensure your Venti is running and try again.' >[1=2] exit vacerror } fn f { du -a $* | awk '{ print $2 }' } if (~ $*(1) -h) { usage } if (! test -f ./.vcs/root) { errruninit } root=`{cat ./.vcs/root} if (! ~ $* '') { filelist=$* } if not { filelist=$root } echo 'Type in a description for this changeset (type  when complete)' cat > $home/tmp/.change # Infortunately, we have to lock through the vac in case it fails. We # can't really get around this, as far as I can tell, because of relying # on prev always representing the last successful commit. <$root/.lock { commitnum=`{cat $root/.commits/.N} echo $commitnum + 1 | bc > $root/.commits/.N commitdir=$root/.commits/$commitnum mkdir $commitdir cat $home/tmp/.change > $commitdir/.change if (! ~ $filelist $root) { echo $filelist >> $commitdir/.change } if not { deferfiles=1 } echo $user > $commitdir/.user prev=`{echo $commitnum - 1 | bc} if (test -f $root/.commits/$prev/.vac) { vacdarg='-d'$root'/.commits/'$prev'/.vac' } vac $vacdarg -f $commitdir/.vac -e $root/.lock -q $root >/dev/null >[2=1] } # At this point, we can't be raced. if (! ~ $status '') { rm -rf $commitdir echo $commitnum > .commits/.N errvac $status } if (~ $deferfiles 1) { vacdir=`{echo /n/$user'vac'$prev} if (test -d $root/.commits/$prev) { vacfs -m $vacdir $root/.commits/$prev/.vac rootup=`{basename -d $root} # Can't detect new files, so we have to do another loop for that. for (i in `{f $vacdir}) { localfile=`{ echo $i | sed 's,'$vacdir','$rootup','} if (echo $localfile | grep -s -v -e '.lock' -e '\.commits' -e '\.vcs' -e '^'$root'$' -e '^'$rootup'$') { cmp -s $i $localfile cs=$status if (! ~ $cs '') { echo $localfile '#' 'a'^$cs^'b' >> $commitdir/.change } } } for (i in `{f $root}) { vacfile=`{ echo $i | sed 's,'$rootup','$vacdir',' } if (echo $vacfile | grep -v -s -e '\.lock' -e '\.commits' -e '\.vcs' -e '^'$root'$' -e '^'$rootup'$') { if (! test -e $vacfile) { echo $vacfile ne echo $i' # New' >> $commitdir/.change } } } unmount $vacdir } if not { f $root >> $commitdir/.change } } echo 'All done!'