]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/cvs/contrib/cvscheck.sh
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / cvs / contrib / cvscheck.sh
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
27 name=cvscheck
28 changes=0
29
30 # If we can't run CVS commands in this directory
31 cvs status . > /dev/null 2>&1
32 if [ $? != 0 ] ; then
33
34     # Bail out
35     echo "$name: there is no version here; bailing out" 1>&2
36     exit 1
37 fi
38
39 # Identify files added to working directory
40 for 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
73 done
74
75 # Identify changed files
76 changedfiles=`cvs diff | egrep '^diff' | awk '{print $3}'`
77 for file in $changedfiles ; do
78     echo "file changed:    $file - not CVS committed"
79     changes=`expr $changes + 1`
80 done
81
82 # Identify files removed from working directory
83 removedfiles=`cvs status | egrep '^File:[       ]*no file' | awk '{print $4}'`
84
85 # Determine whether each file has been cvs removed
86 for 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`
93 done
94
95 exit $changes