How do I revert a modified file using CVS?
You use
cvs update -C filename
It's a surprisingly complicated to do. We ended up using this script "cvsunedit". Which I admit looks like overkill, but there are things in cvs that are just harder to do than they should be.
#!/bin/bash
# cvsunedit - revert a file's modifications while preserving its current version
set -e
if [ "$1" = "" ]
then
exit 0
fi
for f in $*
do
echo "$f"
base="$(basename "$f")"
dir="$(dirname "$f")"
rev="$(perl -e "while(<>){m#/$base/([^/]+)/# && print \$1 . \"\n\";}" < "$dir/CVS/Entries")"
if [ "$rev" = "" ]
then
echo "Cannot find revision for $f in $dir/CVS/Entries"
exit 1
fi
executable=0
[ -x "$f" ] && executable=1
mv "$f" "$f.$$.rev$rev.bak" || rm -f "$f"
set -x
cvs up -p -r "$rev" "$f" > "$f"
set +x
chmod -w "$f"
[ $executable -ne 0 ] && chmod aog+x "$f"
done
exit 0