如何使用CVS还原修改后的文件?

问题描述 投票:45回答:2

我已经从CVS存储库中签出一个文件并进行了更改。

[cvs up命令说文件已被修改M

我需要删除我的更改。什么cvs命令可以为我做?

cvs revert
2个回答
63
投票

您使用

cvs update -C filename

0
投票

这非常复杂。我们最终使用了此脚本“ cvsunedit”。我承认这看起来有些矫kill过正,但在简历中有些事情比应该做的要难得多。

#!/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
© www.soinside.com 2019 - 2024. All rights reserved.