How do I revert a big change in CVS?

前端 未结 10 759
离开以前
离开以前 2021-02-01 16:49

One of my colleagues has totally messed up the contents of a directory in our main CVS repository. I need to just revert the whole module to the state it was in at the end of l

10条回答
  •  忘掉有多难
    2021-02-01 17:10

    I'm still interested to know if there's an easier way. (There must surely be an easier way). What I ended up doing was, on a Linux PC using bash:

    # Get woking copy we're going to change
    cd ~/work
    rm -rf modulename
    cvs up -dP modulename
    cd modulename
    
    # Remove all files
    find . -name CVS -prune -o -type f -print | xargs cvs rm -f
    
    # Get the old revision
    cd ~
    mkdir scratch
    cd scratch
    cvs -q co -D 2008-12-31 modulename
    cd modulename
    
    # Copy everything to the working dir and do "cvs add" on it
    find . -name CVS -prune -o -type f -print | \
        xargs tar c | \
        (cd ~/work/modulename && tar xv | \
        xargs cvs add)
    
    # Check everything is OK before we commit
    cd ~/work/modulename
    cvs -nq up
    
    # it gave me an error on readme.txt because I'd deleted and then added it, so:
    mv readme.txt x # save good rev
    cvs add readme.txt # resurrect the bad rev
    mv x readme.txt # clobber file with good rev
    
    # Commit it
    cvs commit -m "Revert all changes this year"
    
    # Delete now-empty directories
    cvs -q up -dP
    
    # Double-check everything is back how it was
    diff -ur -xCVS ~/scratch/modulename ~/work/modulename
    

    Then I discovered that there were still differences - my colleague had added filenames containing spaces, which weren't deleted by the above process. I had to delete those separately. (I should have used find ... -print0 rather than -print, and passed the -0 argument to xargs. I just didn't realise there were files with spaces.)

提交回复
热议问题