R – Copying a directory that is version controlled


I am curious whether it is OK to copy a directory that is under version control and start working on both copies.

I know it can be different from one VCS to another, but I intentionally don't specify any VCS since I am curious about different cases.

I was talking to a coworker recently about doing it in SVN. I think it should be OK, but I am still not 100% sure, since I don't know what exactly SVN is storing in the working copy.

However, if we talk about the DVCS world, things might be even more unclear, since every working copy is a repository by itself. Being faced with doing this in bzr now, I decided to ask the question.

Later edit:

Some people asked why I would want to do that. Here is the whole story:

In the case of SVN it was because being out of the office, the connection to the SVN server was really slow, so me and my coworker decided to check out the sources only once and make a local copy. That's what we did and it worked OK, but I am still wondering whether it is guaranteed to work, or it just happened.

In the bzr case, I am planning to move the "main" repo to another server. So I was thinking to just copy it there and start considering that the main repo. I guess the safest is to make a clone though.

Best Solution

In Subversion, every .svn folder has whatever is necessary for the containing folder. And since all local paths are stored as relative, you are safe while copying whole or partial trees outside the original checkout tree. They will continue to function in their new homes.

I frequently copy subtrees from my trunk outside, switch the new copies to other branches/tags and do whatever is necessary on the "cloned" local copies. This way, if, for any reason, I need to go back and do something in the trunk, I have an undisturbed trunk copy in the original location.

Copying source-controlled directories into other source-controlled trees, on the other hand, is unsafe. If you will be overwriting any .svn folders, you'll most probably be corrupting your target copies.