Locked, Cleanup, Not a working copy

The following is an example of a problem I've had with Subversion on a number of occasions. The problem arises because a versioned directory (working copy) contains an unversioned resource/directory. This prevents subversion doing anything with the resources, as in the following example:

steph@dimwit:java # ls
com
steph@dimwit:java # svn revert -R com
svn: Working copy 'com' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
steph@dimwit:java # svn cleanup com
svn: 'com/opencms' is not a working copy directory
steph@dimwit:java # cd com
steph@dimwit:com # svn add opencms
svn: Working copy '.' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
steph@dimwit:com # svn status
L .
~ opencms

If you type svn status you'll probably see some resources preceeded with a tilda. This means that the versioned item is obstructed by some item of a different kind (i.e. an unversioned one). Some of the other resources may be locked too (indicated with a capital L).

Unfortunately, the only solution I know of is to replace the unversioned resource with the latest from the repository. If it's a directory this will mean restoring the directory and everything it contains. Of course, this means you will loose all versioning since your last commit.

  1. Backup the unversioned resource by renaming it. For the above example, I'd rename the opencms directory to opencms.bak with mv opencms opencms.bak.
  2. Clean up the working copy with svn cleanup.
  3. Update up the working copy with svn update, to make sure it's up to date.
  4. Remove any references to the unversioned resource from the .svn/entries file. You may have to do this as root. For the above example I'd remove the entry like <
  5. Remove any .svn directories from the backed-up resource. You can do this for the current directory (and all subdirectories) with find . -name .svn -print0 | xargs -0 rm -rf. For the above example it'd be find ./opencms.bak -name .svn -print0 | xargs -0 rm -rf.
  6. Rename the backed-up resource to what it should be. For the above example this would be cp opencms.bak opencms (note that I copied it rather than moving it - always best to maintain a backup just in case).
  7. Add the resource to version control as usual. For the above example, svn add opencms.
  8. If all has gone well, delete the backed-up resource. Even better, move it somewhere else, out of the working copy. Hopefully you'll never need it again.

References

Re: Working copy very screwed up.

Last modified: 01/01/1970 (most likely earlier as a site migration in 2006 reset some dates) Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top