Friday, February 4, 2011

CVS could not find desired version blues

Using CVS as your source repository integrates pretty well with Eclipse Ganymede but sometimes you'll make some changes to a file and when you try and commit it...

cvs [update aborted]: could not find desired version

Somewhere along the way the version numbers got out of sync and now you can't commit all the fabulous changes you've made to the file.

What do you do?

Well the first thing you do, as a way of creating yourself a safety net, is to copy the contents of the file and paste them into a blank text document. That way, if you completely screw up your files you won't lose your hard work.

With that safely aside, you can start fixing your CVS problem.

1: Right click the file, and select Replace with --> Latest from HEAD

This will load the version from CVS and straighten out the version number by forcing Eclipse to match. It only loads into your editor however, and isn't changing the file on your local.

2: Right click the file again and select Replace with --> Previous from Local History

This will replace the contents in your editor with the file you actually saved in your file system with all your changes.

3: Right click the file and select Team --> Commit

It will successfully commit your changes.

This happened to me with a pom.xml TWICE a couple of weeks apart. The first time we fixed it by completely blowing away not only the file on my local, but also the version in the CVS repository. Then, we added the file back in. It made it possible to commit he changes, but now the unbroken file history was... well, broken. Obviously, the problem came back again later anyway. Time will tell if the procedure above will be permanent, and I'll post any further developments on it.

7 comments: