#!/bin/sh
# \
	exec tclsh8.5 "$0" ${1+"$@"}

# $Id: cvscheck.blank,v 1.8 1995/11/20 06:08:35 davide Exp $
#
# cvscheck -- Check a directory for new, updated, or out of date files.
#
# Contributed by Brett Bergquist (bergquis@gdc.com)
#

proc msg {file msg} {
    puts [format "%-40s: %s" $file $msg]
}

# get the status of the files in the current directory
set fd [open "|cvs -n -q update [lrange $argv 1 end]"]
while {[gets $fd line] != -1} {
    regexp {^([UARMC?]) (.*)} $line junk mode file
    switch -exact -- $mode {
	U {
	    msg $file "file changed in repository, needs updating"
	}
	A {
	    msg $file "file added, not committed"
	}
	R {
	    msg $file "file removed, not committed"
	}
	M {
	    msg $file "file modified, not committed"
	}
	C {
	    msg $file "file modified and in conflict, not committed"
	}
	? {
	    msg $file "file unknown, not in CVS"
	}
    }
}
if {[catch {close $fd} res]} {
    puts "ERROR: $res"
    exit 1
}
# now find directories not added.  This is accomplished by finding all of
# the directories in the current directory seeing if there is a CVS control
# file in each one.
set files [glob -nocomplain -- .??* *]
set dirs {}
foreach file $files {
    if {[file isdirectory $file] && "$file" != "CVS"} {
	lappend dirs $file
    }
}
# see if there are any directories not added.
if {[llength $dirs]} {
    foreach dir $dirs {
	if {! [file exists $dir/CVS] || ! [file isdirectory $dir/CVS]} {
	    msg $dir "directory unknown, not in CVS"
	}
    }
}
exit 0
