Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######################################################
- #! /bin/bash
- #
- # cic - "ci with checksum"
- #
- # cic file_name "revision log"
- # Sha1 checksum gets prepended before optional log message, $2
- # File_name get expanded by $1
- # Any other option to ci could be appended, like -l
- #
- # Use only after the initial commit
- #
- # The filename needs to be quoted in the following way,
- # Or else ci -m $1 will fail, due to wrong escaping.
- # Taken from Nautilus File Manager Scripts FAQ
- # http://g-scripts.sourceforge.net/faq.php
- # file[spaces]name in $1 gets properly quoted here, in $quoted
- quoted=$(echo -e "$1" | awk 'BEGIN {
- FS = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##)
- # Get file's checksum
- chksm=`sha1deep -q "$1"`
- # Check-in file, prepending checksum to log message
- # and temporarily store ci message
- eval "ci -m'$chksm- $2'" $quoted &> RCS/rev.tmp
- cd RCS
- # Get revision from ci message; get rid of tmp file
- # One just has to love awk!
- #rvsn=`awk '(/revision/) {print $2}' rev.tmp`
- rvsn=`awk '(/revision/) {print substr($3,1,3)}' rev.tmp`
- rm rev.tmp
- # co revision (unlocked)
- co -r$rvsn "$1"
- # Rename checkout as revision; -f because file is unlocked
- mv -f "$1" "$1".$rvsn
- # Write revision's checksum to disk as well
- sha1deep -q "$1".$rvsn > "$1".$rvsn.sha1
- # un-unixesque trivial message, just to check
- # Delete when sure everything is hunky-dory
- echo Revision $rvsn of file "$1" has been checked-in with:
- echo Log msg: "$2"
- echo Checksum: $chksm
- echo The revision is also available as RCS/"$1".$rvsn
- ######################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement