sccshist.sh revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2003 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
#
# Print sccs history of a file with
# comment and differences for each delta.
#
# With the -r invocation style, only the deltas between the given sids are
# printed. sccshist -r1.2 -r1.3, for example, prints the SID description for
# 1.3, followed by the diffs between 1.2 and 1.3. The SID description for 1.2
# is not printed.
#
# With the -n invocation style, deltas to a given number of SIDs are printed.
# Given a file with 1.5, 1.4, ... 1.1, sccshist -n 2 will print the 1.5 SID
# header, 1.4 -> 1.5 diffs, the 1.4 SID header, and 1.3 -> 1.4 diffs.
#
die()
{
exit 1
}
usage()
{
exit 2
}
typeset -i nsids=0
while getopts "cn:r:u" c ; do
case $c in
c|u)
[[ -n "$diffflags" ]] && usage
diffflags="-$c"
;;
n)
;;
r)
if [[ -n "$highsid" ]] ; then
elif [[ -n "$lowsid" ]] ; then
else
fi
;;
*)
;;
esac
done
FILE=$1
#
# The main processing loop. A new SID triggers a printing of the diffs between
# the new SID and the last one. If there is no previous SID (if we're looking
# at the first one), no diff is printed.
#
if [[ -z "$highsid" ]] ; then
printing=1
else
printing=0
fi
typeset -i last=0
typeset -i count=0
set - $LINE
if [[ "$2" = "$highsid" ]] ; then
printing=1
else
continue
fi
fi
if [[ $1 != "D" ]] ; then
echo "$LINE"
continue
fi
# We calculate `last' before printing the diff, and defer breaking out
# of the loop until after the diff, because we want to act upon the
# value during the diff.
fi
if [[ -r $tmpf2 ]] ; then
echo "________________________________________________________"
fi
fi
echo "$LINE" # The new SID delta line
done