#! /bin/sh

# Copyright (C) 1999, Free Software Foundation
# Originally by Alexandre Oliva <oliva@gnu.org>

# This script is Free Software, and it can be copied, distributed and
# modified as defined in the GNU General Public License.  A copy of
# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html

# Reload the listed files from the CVS repository.  This is useful to
# restore a CVS tree to an unpatched state, if it is impossible to
# revert a patch for some reason, such as some of the modified files
# being binary or generated from others.

# This could first check whether the file is modified or not, and
# could try `cvs diff | patch -R' first.  It could also use a single
# cvs commands for files that live in the same cvs repository.

# Usage: cvsreload foo bar/baz
# See also: cvsreloadall

for f
do
  dir=`echo "$f" | sed 's,^[^/]*$,.,;s,//*[^/]*$,,'`
  file=`echo "$f" | sed 's,.*/,,'`
  (cd $dir
   rm -f $file
   cvs -q up $file)
done

exit 0
