head 1.12; access; symbols SVS_1_1_0:1.12 SVS_1_0_5:1.10 SVS_1_0_4:1.9 SVS_1_0_3:1.8 SVS_1_0_2:1.7 SVS_1_0_1:1.6 SVS_1_0_0:1.1; locks; strict; comment @# @; 1.12 date 2009.06.25.18.11.59; author rse; state Exp; branches; next 1.11; commitid kx8jUjxgtb50xgTt; 1.11 date 2009.06.25.18.10.41; author rse; state Exp; branches; next 1.10; commitid EPyStuOQ1DKywgTt; 1.10 date 2005.10.07.10.59.27; author rse; state Exp; branches; next 1.9; 1.9 date 2005.10.03.10.33.48; author rse; state Exp; branches; next 1.8; 1.8 date 2005.08.18.07.46.14; author rse; state Exp; branches; next 1.7; 1.7 date 2005.02.06.12.17.47; author rse; state Exp; branches; next 1.6; 1.6 date 2005.01.13.11.15.03; author rse; state Exp; branches; next 1.5; 1.5 date 2005.01.13.11.14.01; author rse; state Exp; branches; next 1.4; 1.4 date 2005.01.13.11.12.58; author rse; state Exp; branches; next 1.3; 1.3 date 2004.12.17.09.52.08; author rse; state Exp; branches; next 1.2; 1.2 date 2004.12.16.16.39.37; author rse; state Exp; branches; next 1.1; 1.1 date 2004.12.14.19.18.37; author rse; state Exp; branches; next ; desc @@ 1.12 log @adjust copyright messages @ text @#!/bin/sh ## ## OSSP svs -- Stupid/Silly/Simple Versioning System ## Copyright (c) 2003-2009 Ralf S. Engelschall ## Copyright (c) 2003-2009 The OSSP Project ## ## This file is part of OSSP svs, a stupid/silly/simple versioning ## system which can found at http://www.ossp.org/pkg/tool/svs/ ## ## Permission to use, copy, modify, and distribute this software for ## any purpose with or without fee is hereby granted, provided that ## the above copyright notice and this permission notice appear in all ## copies. ## ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ## SUCH DAMAGE. ## ## svs.sh: program (language: Bourne Shell) ## # check command line if [ $# -eq 0 ]; then echo "Usage: svs vi [...]" echo "Usage: svs diff [| [...]]" echo "Usage: svs backout [| [...]]" echo "Usage: svs status [| [...]]" exit 1 fi # helper function for portable creating a file difference do_diff () { diff -U3 "$1" "$2" 2>/dev/null if [ $? -gt 1 ]; then diff -u "$1" "$2" 2>/dev/null if [ $? -gt 1 ]; then diff -C3 "$1" "$2" 2>/dev/null if [ $? -gt 1 ]; then diff "$1" "$2" fi fi fi } # a newline character NL=' ' # dispatch into commands cmd="$1" shift case "$cmd" in v|vi|vim | e|em|ema|emac|emacs ) ## ## EDIT ONE OR MORE FILES ## # iterate over all files for file in "$@@"; do # preserve original file if [ ! -f "$file.orig" ]; then cp -p "$file" "$file.orig" orig=new else orig=old fi # edit file chmod u+w "$file" if [ ".${EDITOR-vi}" = .vim -a -f "$file.rej" ]; then ${EDITOR-vi} -o2 "$file" "$file.rej" else ${EDITOR-vi} "$file" fi # check for editing results if cmp "$file.orig" "$file" >/dev/null 2>&1; then if [ ".$orig" = .new ]; then echo "svs: no changes made (keeping original)" else echo "svs: changes reversed (restoring original)" fi cp -p "$file.orig" "$file" rm -f "$file.orig" else echo "svs: changes made (preserving original)" if [ -f "$file.rej" ]; then rm -f "$file.rej" fi fi done ;; d|di|dif|diff ) ## ## GENERATE PATCHING DIFFERENCE ## # determine file list if [ $# -eq 0 ]; then set -- . fi files="" for file in "$@@"; do if [ -d "$file" ]; then OIFS=$IFS; IFS=$NL for f in `find "$file" -type f -name "*.orig" -print | sort`; do files="$files \"$f\"" done IFS=$OIFS elif [ -f "$file" ]; then files="$files \"$file\"" else echo "svs:ERROR: \"$file\" neither regular file nor directory" 1>&2 exit 1 fi done # generate patch eval set -- $files for file; do file=`echo "$file" | sed -e 's;^\./;;' -e 's;/\./;/;g' -e 's;\([^/][^/]*\)/\.\.;;g' -e 's;//*;/;g'` orig=`echo "$file" | sed -e 's;\.orig$;;' -e 's;$;.orig;'` edit=`echo "$file" | sed -e 's;\.orig$;;'` if [ ! -f "$orig" ]; then echo "svs:WARNING: original file \"$orig\" not found" 1>&2 continue fi if [ ! -f "$edit" ]; then # special case: removed file echo "Index: $edit" do_diff "$orig" /dev/null | sed -e "1s/^--- $orig/--- $edit/" elif [ ! -r "$orig" ] && [ ! -s "$orig" ]; then # special case: new file echo "Index: $edit" do_diff /dev/null "$edit" else # regular case: edited file if cmp "$orig" "$edit" >/dev/null 2>&1; then : else echo "Index: $edit" do_diff "$orig" "$edit" fi fi done ;; b|ba|bac|back|backo|backou|backout ) ## ## BACKOUT EDITING CHANGES ## # determine file list if [ $# -eq 0 ]; then set -- . fi files="" for file in "$@@"; do if [ -d "$file" ]; then OIFS=$IFS; IFS=$NL for f in `find "$file" -type f -name "*.orig" -print | sort`; do files="$files \"$f\"" done IFS=$OIFS elif [ -f "$file" ]; then files="$files \"$file\"" else echo "svs:ERROR: \"$file\" neither regular file nor directory" 1>&2 exit 1 fi done # backout changes eval set -- $files for file; do file=`echo "$file" | sed -e 's;^\./;;' -e 's;/\./;/;g' -e 's;\([^/][^/]*\)/\.\.;;g' -e 's;//*;/;g'` orig=`echo "$file" | sed -e 's;\.orig$;;' -e 's;$;.orig;'` edit=`echo "$file" | sed -e 's;\.orig$;;'` if [ ! -f "$orig" ]; then echo "svs:WARNING: original file \"$orig\" not found" 1>&2 continue fi echo "svs: backing out changes to \"$edit\"" if [ ! -f "$edit" ]; then # special case: removed file cp -p "$orig" "$edit" rm -f "$orig" elif [ ! -r "$orig" ] && [ ! -s "$orig" ]; then # special case: new file chmod u+w "$orig" rm -f "$orig" rm -f "$edit" else # regular case: edited file cp -p "$orig" "$edit" rm -f "$orig" fi done ;; s|st|sta|stat|statu|status ) ## ## CHANGE STATUS ## # determine file list if [ $# -eq 0 ]; then set -- . fi files="" for file in "$@@"; do if [ -d "$file" ]; then OIFS=$IFS; IFS=$NL for f in `find "$file" -type f \( -name "*.orig" -or -name "*.rej" \) -print | sort`; do base=`echo "$f" | sed -e 's;\.orig$;;' -e 's;\.rej$;;'` if [ ".$f" = ".$base.orig" ] && [ -f "$base.orig" ] && [ -f "$base.rej" ]; then continue fi files="$files \"$f\"" done IFS=$OIFS elif [ -f "$file" ]; then files="$files \"$file\"" else echo "svs:ERROR: \"$file\" neither regular file nor directory" 1>&2 exit 1 fi done # show status on files eval set -- $files for file; do file=`echo "$file" | sed -e 's;^\./;;' -e 's;/\./;/;g' -e 's;\([^/][^/]*\)/\.\.;;g' -e 's;//*;/;g'` base=`echo "$file" | sed -e 's;\.orig$;;' -e 's;\.rej$;;'` prefix="?" case "$file" in *.orig ) prefix="M" ;; *.rej ) prefix="C" ;; esac echo "$prefix $base" done ;; * ) echo "svs:ERROR: invalid command \"$cmd\"" 1>&2 exit 1 ;; esac @ 1.11 log @Support directories and files with spaces in the name. @ text @d4 2 a5 2 ## Copyright (c) 2003-2005 Ralf S. Engelschall ## Copyright (c) 2003-2005 The OSSP Project @ 1.10 log @Fix diff(3) option fiddling introduced in version 1.0.4 @ text @d42 1 a42 1 diff -U3 $1 $2 2>/dev/null d44 1 a44 1 diff -u $1 $2 2>/dev/null d46 1 a46 1 diff -C3 $1 $2 2>/dev/null d48 1 a48 1 diff $1 $2 d54 4 d70 2 a71 2 if [ ! -f $file.orig ]; then cp -p $file $file.orig d78 3 a80 3 chmod u+w $file if [ ".${EDITOR-vi}" = .vim -a -f $file.rej ]; then ${EDITOR-vi} -o2 $file $file.rej d82 1 a82 1 ${EDITOR-vi} $file d86 1 a86 1 if cmp $file.orig $file >/dev/null 2>&1; then d92 2 a93 2 cp -p $file.orig $file rm -f $file.orig d96 2 a97 2 if [ -f $file.rej ]; then rm -f $file.rej d114 4 a117 3 if [ -d $file ]; then for f in `find $file -type f -name "*.orig" -print | sort`; do files="$files $f" d119 3 a121 2 elif [ -f $file ]; then files="$files $file" d129 2 a130 1 for file in $files; do d134 1 a134 1 if [ ! -f $orig ]; then d138 1 a138 1 if [ ! -f $edit ]; then d141 2 a142 2 do_diff $orig /dev/null | sed -e "1s/^--- $orig/--- $edit/" elif [ ! -r $orig ] && [ ! -s $orig ]; then d145 1 a145 1 do_diff /dev/null $edit d148 1 a148 1 if cmp $orig $edit >/dev/null 2>&1; then d152 1 a152 1 do_diff $orig $edit d169 4 a172 3 if [ -d $file ]; then for f in `find $file -type f -name "*.orig" -print | sort`; do files="$files $f" d174 3 a176 2 elif [ -f $file ]; then files="$files $file" d184 2 a185 1 for file in $files; do d189 1 a189 1 if [ ! -f $orig ]; then d194 1 a194 1 if [ ! -f $edit ]; then d196 3 a198 3 cp -p $orig $edit rm -f $orig elif [ ! -r $orig ] && [ ! -s $orig ]; then d200 3 a202 3 chmod u+w $orig rm -f $orig rm -f $edit d205 2 a206 2 cp -p $orig $edit rm -f $orig d222 3 a224 2 if [ -d $file ]; then for f in `find $file -type f \( -name "*.orig" -or -name "*.rej" \) -print | sort`; do d226 1 a226 1 if [ ".$f" = ".$base.orig" ] && [ -f $base.orig ] && [ -f $base.rej ]; then d229 1 a229 1 files="$files $f" d231 3 a233 2 elif [ -f $file ]; then files="$files $file" d241 2 a242 1 for file in $files; do @ 1.9 log @- Try diff(3) with options -U3, -u, -C3 and none (in this order) to be more platform neutral. - Upgraded to GNU shtool 2.0.3 @ text @d40 14 d134 1 a134 5 ( diff -U3 $orig /dev/null 2>/dev/null ||\ diff -u $orig /dev/null 2>/dev/null ||\ diff -C3 $orig /dev/null 2>/dev/null ||\ diff $orig /dev/null ) | sed -e "1s/^--- $orig/--- $edit/" d138 1 a138 4 diff -U3 /dev/null $edit 2>/dev/null ||\ diff -u /dev/null $edit 2>/dev/null ||\ diff -C3 /dev/null $edit 2>/dev/null ||\ diff /dev/null $edit d145 1 a145 4 diff -U3 $orig $edit 2>/dev/null ||\ diff -u $orig $edit 2>/dev/null ||\ diff -C3 $orig $edit 2>/dev/null ||\ diff $orig $edit @ 1.8 log @Do not show a file as both modified and conflicting if both *.orig and *.rej exists. Instead list it just as conflicting as "cvs" does. @ text @d120 5 a124 1 diff -u3 $orig /dev/null | sed -e "1s/^--- $orig/--- $edit/" d128 4 a131 1 diff -u3 /dev/null $edit d138 4 a141 1 diff -u3 $orig $edit @ 1.7 log @Replace unportable "if ! " construct. @ text @d200 4 @ 1.6 log @ops, output base filename only @ text @d127 3 a129 1 if ! cmp $orig $edit >/dev/null 2>&1; then @ 1.5 log @Adjust copyright messages for new year 2005 @ text @d211 1 d217 1 a217 1 echo "$prefix $file" @ 1.4 log @1. Add a convenient "svs status" command which output a "cvs update" style list of files and their status (modification or conflict). 2. Remove *.rej files on "svs vi" if a modification was done. 3. Fix "make uninstall" procedure. @ text @d4 2 a5 2 ## Copyright (c) 2003-2004 Ralf S. Engelschall ## Copyright (c) 2003-2004 The OSSP Project @ 1.3 log @be even more convinient and open .rej file automatically if there is one @ text @d36 1 d78 3 d184 36 @ 1.2 log @When searching for *.orig files, sort the resulting filename list to make sure we deterministically produce patches. @ text @d60 5 a64 1 ${EDITOR-vi} $file @ 1.1 log @initial cut for OSSP svs @ text @d89 1 a89 1 for f in `find $file -type f -name "*.orig" -print`; do d139 1 a139 1 for f in `find $file -type f -name "*.orig" -print`; do @