PageRenderTime 35ms CodeModel.GetById 19ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/cvs/contrib/cvscheck.sh

https://bitbucket.org/freebsd/freebsd-head/
Shell | 95 lines | 44 code | 14 blank | 37 comment | 12 complexity | 62708758e82ec41b88fdc7178e0cc90c MD5 | raw file
 1#! /bin/sh
 2#
 3# Copyright (C) 1995-2005 The Free Software Foundation, Inc.
 4#
 5# This program is free software; you can redistribute it and/or modify
 6# it under the terms of the GNU General Public License as published by
 7# the Free Software Foundation; either version 2, or (at your option)
 8# any later version.
 9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# cvscheck - identify files added, changed, or removed 
16#            in CVS working directory
17#
18# Contributed by Lowell Skoog <fluke!lowell@uunet.uu.net>
19# 
20# This program should be run in a working directory that has been
21# checked out using CVS.  It identifies files that have been added,
22# changed, or removed in the working directory, but not "cvs
23# committed".  It also determines whether the files have been "cvs
24# added" or "cvs removed".  For directories, it is only practical to
25# determine whether they have been added.
26
27name=cvscheck
28changes=0
29
30# If we can't run CVS commands in this directory
31cvs status . > /dev/null 2>&1
32if [ $? != 0 ] ; then
33
34    # Bail out
35    echo "$name: there is no version here; bailing out" 1>&2
36    exit 1
37fi
38
39# Identify files added to working directory
40for file in .* * ; do
41
42    # Skip '.' and '..'
43    if [ $file = '.' -o $file = '..' ] ; then
44	continue
45    fi
46
47    # If a regular file
48    if [ -f $file ] ; then
49	if cvs status $file | grep -s '^From:[ 	]*New file' ; then
50	    echo "file added:      $file - not CVS committed"
51	    changes=`expr $changes + 1`
52	elif cvs status $file | grep -s '^From:[ 	]*no entry for' ; then
53	    echo "file added:      $file - not CVS added, not CVS committed"
54	    changes=`expr $changes + 1`
55	fi
56
57    # Else if a directory
58    elif [ -d $file -a $file != CVS.adm ] ; then
59
60	# Move into it
61	cd $file
62
63	# If CVS commands don't work inside
64	cvs status . > /dev/null 2>&1
65	if [ $? != 0 ] ; then
66	    echo "directory added: $file - not CVS added"
67	    changes=`expr $changes + 1`
68	fi
69
70	# Move back up
71	cd ..
72    fi
73done
74
75# Identify changed files
76changedfiles=`cvs diff | egrep '^diff' | awk '{print $3}'`
77for file in $changedfiles ; do
78    echo "file changed:    $file - not CVS committed"
79    changes=`expr $changes + 1`
80done
81
82# Identify files removed from working directory
83removedfiles=`cvs status | egrep '^File:[ 	]*no file' | awk '{print $4}'`
84
85# Determine whether each file has been cvs removed
86for file in $removedfiles ; do
87    if cvs status $file | grep -s '^From:[ 	]*-' ; then
88	echo "file removed:    $file - not CVS committed"
89    else
90	echo "file removed:    $file - not CVS removed, not CVS committed"
91    fi
92    changes=`expr $changes + 1`
93done
94
95exit $changes