tags:

views:

473

answers:

3

Say I have a directory structure like this

dir1
   dir2
   dir3

dir2is already under version control, whereas dir1 is not. Now I realize that I would like to have dir1 under version control as well (and maybe later on dir3 etc.) How can I do this and reflect the changes correctly in the repository?

If I just move dir2 out of dir1, add dir1 to SVN and move dir2 back into dir1, this will probably destroy the version history of dir2. What makes it even more complicated is that dir2 contains many files which are not under version control (they are ignored), so dir2 cannot be (fully) recreated from the repository.

A: 
  • create dir1 besides dir2
  • move dir2 into dir1

You can do this on the server (by using URLs) or in your working copy (by using file system paths). In the latter case you will have to commit afterwards.

sbi
I tried this on the server (i.e. `svn mkdir url/dir1; svn mv url/dir2 url/dir1`) which succeeded. But when I tried `svn up` I get `svn: Failed to add directory 'dir2': object of the same name already exists`?
fuenfundachtzig
You will have to make a fresh checkout into a new location.
sbi
I would like to avoid checkouts (see question). Thus I tried to do this locally, I now have `dir11` on the same level as `dir2`, but `svn mv dir2 dir11` gives `svn: Unable to lock 'dir11'`.
fuenfundachtzig
+1  A: 

You're right, re-importing dir2 will not save the history of your existing dir2.

This should do the trick (assuming path is the url repository):

  1. svn mkdir path/dir1
  2. svn mv path/dir2 path/dir1
Wolfgang
Fails with `svn: No support for repos <--> working copy moves`.
fuenfundachtzig
You tried to mix working copy paths and repo URLs in a way that didn't work. Try either all working paths or all URLs.
sbi
OK, then one should change the second item above, otherwise it's misleading.
fuenfundachtzig
Sorry, I had surrounded the last *path* with <> which made it not appear. I've corrected it.
Wolfgang
I guess this is the cleanest solution, but it requires a full check-out. In my case this was not feasible.
fuenfundachtzig
I'm not sure if a svn switch would let you keep the already checked out files.In general, the branch contents should not be so big that a complete checkout is a problem. If you want to use svn effectively, data transfer should not be a limitation.
Wolfgang
A: 

There is another possibility, although it might not be exactly what you're looking for: SVN externals.

  1. Check in dir1.

  2. Add dir2 as SVN external to dir1s properties:

-

$ svn propget svn:externals dir1
dir2  svn://repository/dir2
Boldewyn