223

Recently our Subversion (SVN) server was changed and we did a svn switch.

Since the working copy had a huge amount of unversioned resources, the working copy got locked and we started switching folder by folder for all folders under SVN, which works perfectly fine.

But at the topmost level of the repository, when I try to update files, I get an error that says svn: Working copy '.' locked. Trying to do cleanup does not help either; it causes errors like svn: 'content' is not a working copy directory.

A fresh checkout is not an option at all. How else can I clean up and release the locks and complete the svn switch process?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vijay Dev
  • 26,966
  • 21
  • 76
  • 96

25 Answers25

132

If you get a "not a working copy" when doing a recursive svn cleanup, you likely have a subdirectory which should be a working copy (i.e. the .svn directory at the top level says so), but the subdirectory is missing its own .svn directory.

In that case, you could move or delete that directory and then do a local update. To delete the directory,

rm -rf content
svn checkout content

WARNING: rm -rf deletes the folder content permanently.

If you get a not a working copy error, it means that Subversion cannot find a proper .svn directory in the content subdirectory. Check to see if there is an .svn directory in content.

The ideal solution is a fresh checkout, if possible.

Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415
JesperE
  • 63,317
  • 21
  • 138
  • 197
  • 1
    I agree, do a fresh checkout instead of trying to move your working copy with the repo. – Tigraine Dec 17 '08 at 12:00
  • 2
    My problem is that I've migrated to a new server and restored my backups of the filesystem with work not yet committed, and used svnadmin to filter out old projects I no longer need. So my repository contains all the info I need, but has a new UUID. In this case, I'm just going to tar up the changed files, get a fresh checkout, and then untar. – Drarok Aug 28 '09 at 15:21
  • Your suggestion in first paragraph does not work on my system (W7+Cygwin). Rather rm & svn update did it. – Jukka Dahlbom May 02 '12 at 12:54
  • 19
    **WARNING:** `rm -rf` deletes the folder `content` permanently. Take a backup before executing it. – KrishPrabakar Mar 13 '15 at 09:51
48

I got into a similar situation (svn: 'papers' is not a working copy directory) a different way, so I thought I'd post my battle story (simplified):

$ svn add papers
svn: Can't create directory 'papers/.svn': Permission denied

Oops! fix permissions... then:

$ svn add papers
svn: warning: 'papers' is already under version control
$ svn st
~     papers
$ svn cleanup
svn: 'papers' is not a working copy directory

And even moving papers out of the way and running svn up (which worked for the OP) didn't fix it. Here's what I did:

$ mv papers papers_
$ svn cleanup
$ svn revert papers
Reverted 'papers'
$ mv papers_/ papers
$ svn add papers

That worked.

Ken Arnold
  • 1,942
  • 1
  • 20
  • 24
6

I solved it by

  1. Copy a backup of the impacted folders
  2. SVN revert the impacted folders
  3. Paste the files back from the backup

In my case the problem was due to deleted .svn-files.

5

Maybe you just copied tree of folder and trying to add lowest one.

SVN
|_
  |
  subfolder1
       |
       subfolder2   (here you get an error)

in that case you have to commit directory on the upper level.

Himanshu
  • 31,810
  • 31
  • 111
  • 133
Hextler
  • 59
  • 1
  • 1
3

If you created a file inside a new directory, instead of 'svn add newdir/newfile' use 'svn add newdir' because you need to add the directory. All the files inside the directory will be added by default.

HenryF
  • 31
  • 1
3

Workaround:

Rename the directory which is not the 'working copy'. Check out/update/restore this directory again. Move files from the renamed directory to a new one. Commit changes.

Reason:

You made some changes to some files under the .svn directory, and this breaks the 'working copy'.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
abatishchev
  • 98,240
  • 88
  • 296
  • 433
  • 1
    @peter-mortensen a passive-aggressive edit of 15-years old response, huh? thanks for the edit itself and for a link with the exact timing too. but it wasn't really necessary :-P – abatishchev Feb 03 '23 at 22:20
  • 1
    Wow: he did it to almost every answer/comment here... Wikipedia hyperlinks etc. Reputation/point farming on 15 year old threads. – Andy Needham Feb 22 '23 at 12:06
1

I just got "not a working copy", and for me the reason was the Automouter on Unix. Just a fresh "cd /path/to/work/directory" did the trick.

AlexLa
  • 11
  • 1
1

I tried pasting the .svn folder from the sub folder to the root folder. It works!!!

navin
  • 11
  • 1
1

This is what I did:

  1. rename trunk to trunk_
  2. create a new folder trunk
  3. Re-checkout and interrupt the process after few files are checked-out
  4. Move the files from trunk_ to trunk
  5. Do svn cleanup
  6. Do svn update. This will update the status of files and then all your files will be versioned.
Shaunak Sontakke
  • 980
  • 1
  • 7
  • 17
1

I also met this problem in a svn diff operation. It was caused by an incorrect file path. You should add './' to indicate the current file directory.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Armstrongya
  • 795
  • 1
  • 6
  • 9
1

Same, I needed to update a 'contrib' folder:

  1. Moved the old folder out,
  2. Copied the new one
  3. Copied the .svn folders into each (only three in my case) new folder.

I my case too the problem was due to deleted .svn folders.

Solved.

arieltools
  • 1,136
  • 3
  • 15
  • 21
  • Found this about 4 hours into SVN cleanup using the Eclipse plugin - good times! Working copy is locked - no it's not, come up with a better message Eclipse people, thanks. – Darth Jon May 20 '15 at 20:29
1

I was facing the same error when trying to check out parts of sources from a large SVN project:

svn co --depth empty svn://tug.org/texlive/trunk/Build
cd Build
svn update --set-depth infinity --parents ./source/texk/web2c

Here the --parents is the key to make it a success.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mindon
  • 318
  • 4
  • 13
0

I had this same problem. It turns out we had SlikSVN 1.6.2 as well as TortoiseSVN on the same machine. Tortoise had been updated (and had updated the working copy), but SlikSVN had not, so Tortoise worked OK, but command lines failed with:

svn: '.' is not a working copy directory

Removing both TortoiseSVN and SlikSVN, and then reinstalling TortoiseSVN with command line tools enabled, fixed this for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Twoayem
  • 9
  • 1
0

For Mac: take a checkout from the server side and a new window will open to select the directory from your local machine. Then put all your code in the selected folder. Then open the SVN local side. Add and commit the project.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
RaviPatidar
  • 1,438
  • 1
  • 18
  • 29
0

Today I have found the same issue, /FILE_NAME/ is not a working copy, in the morning, and I have spent more than two hours to solve it. After a long of RND and Google I found some solution and that is Checkout.

  1. Checkout from Subversion to local as a new project.
  2. Change some of code in a Java file and Commit the project.
  3. It works for me.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85
0

svn: The repository at 'svn://repourl/reponame/foldername' has uuid 'm/reponame', but the WC has 'b5b39681-0ff6-784b-ad26-2846b9ea8e7d'

Every Subversion repository has a unique identifier (UUID). Subversion uses this to make sure that the repository is actually the same when doing things like switching. You should probably change the UUID on the server to be the same as before.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
JesperE
  • 63,317
  • 21
  • 138
  • 197
0

It could be a working copy format mismatch. It changed between SVN 1.4 and 1.5 and newer tools automatically convert the format, but then the older ones no longer work with the converted copy.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
agnul
  • 12,608
  • 14
  • 63
  • 85
0

You must have deleted a SVN - base file from your project (which are read-only files). Due to this you get this error.

Check out a fresh project again, merge the changes (if any) of your older SVN project with new one using WinMerge and commit the changes in your latest check out.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Samiksha
  • 6,122
  • 6
  • 29
  • 28
0

Recently I was using another developer's Mac. I had the same situation. The problem was; first I needed to type get repository path in the terminal, but I didn't. Then it says what is your user name and password.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Samir
  • 6,405
  • 5
  • 39
  • 42
0

I just ran into a case where the .svn directory is on an NFS server on a different machine, and the NFS client was not running the file locking service (lockd).

svn: E155007: '/mnt/svnworkdir' is not a working copy

This went away once lockd was started on the NFS client host.

It seems like Subversion could come up with a better error message when it has trouble locking files. This was Subversion 1.10.0

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Juan
  • 1,204
  • 1
  • 11
  • 25
0

I made a new checkout from the same project to a different location, copied the .svn folder from it, and replaced it with my old .svn folder.

After that I called the svn update function and everything were synced properly up to date.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ramesh Jaya
  • 671
  • 1
  • 10
  • 16
0

JesperE mentions that you need to change the UUID. The following should help you achieve this.

On SVN 1.5+, you can do svnadmin setuuid; you can then check that it's been set correctly using svnlook uuid. On earlier versions of SVN, it's a harder process. See Managing Repository UUIDs.

Additionally the UUID of "m/reponame" looks suspicious. I believe it should be a hex-formatted number like the working copy's, so maybe this action will improve things all-around :-)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
alastairs
  • 6,697
  • 8
  • 50
  • 64
0

I had this exact error. I noticed that I was in the wrong directory. Once I reverted to the SVN Trunk directory the issue was resolved.

sqrepants
  • 996
  • 2
  • 10
  • 22
0

I saw this error when I was performing mvn release:prepare on my code. In my case, I had migrated the project from SVN to GitHub, and had cloned the source code from GitHub. But in my pom.xml file, I missed to update the SCM location from SVN URL to GitHub URL, which caused the mismatch between the working directories.

Correcting URL to the GitHub location helped solve it for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
-1

Delete the .svn folder that is present in your local machine. Press the windows icon if it is a

windows machine

and type .svn, delete the entire folder. It worked for me.

Bhuvana
  • 47
  • 3