Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I revert a modified file using CVS?

Tags:

revert

cvs

I have checked out a file from CVS repository and changed it.

cvs up command says that the file is modified M.

I need to delete my changes. What cvs command can do it for me?

like image 536
Ashot Avatar asked Mar 29 '13 14:03

Ashot


People also ask

How do I revert changes to cvs?

cvs export the 'old version' by tag (or you could do it by date) into a new folder. ensure the 'current version' is checked out, updated, and live. copy the files from the old version into the folder with the current version. commit the result with a suitable comment.

How do I undo cvs remove?

If you notice that you accidentally removed a file you need (before you run cvs commit ), you can use cvs add to undo the removal and then use cvs update to retrieve the removed file. This process leaves no record in the repository.

How do I edit a file in cvs?

cvs add Add new files to an existing directory under CVS control. The cvs add command tells CVS to add the given file to its list of files that should be tracked in the working directory. The file is not created in the repository until you CVS commit the file or the directory it's in.


2 Answers

You use

cvs update -C filename 
like image 125
Eric Avatar answered Oct 12 '22 20:10

Eric


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 
like image 21
Mort Avatar answered Oct 12 '22 20:10

Mort