tags:

views:

424

answers:

3

For a number of reasons, the canonical source of some files I have can't be a working copy of the repository (the Subversion server is behind an inaccessible firewall, and the data doesn't natively exist in the file system in my preferred structure). So, I wrote a tool that downloads the data, generates a directory structure from it, and then uses SharpSvn to import the result into the repository. This works… the first time. The second time, of course, a directory of that name already exists in the repository, and I can't import again.

Instead, I could:

  1. Delete the directory, then import. I haven't tested this, but aside from sounding stupid, it probably also deletes the revision history of the respective files, regarding the new ones as entirely different.
  2. See if the directory exists, check it out, remotely delete the files that no longer exist in the canonical source, then replace the remainder and commit. This would probably work, but sounds error-prone and needlessly difficult.

Is my assumption correct that deleting files will mark new ones of the same ways as different files? Is there an easier way than the second approach?

A: 

Subversion has a loose connection to the files. For files inside a folder, you can easily do a get/update, make massive changes (including deleting, replacing, or adding files), then commit the differences. That file-level behavior is typical Subversion usage.

The directories are slightly different. Subversion stores the repository information at the folder level. So, if you create a new folder, it won't automatically have a connection to Subversion. (Using something like TortoiseSvn, it takes care of much of that for you.)

If you are going to be adding and deleting directories during the generation process, you'll have some slightly different issues than with the files themselves. But, you can still accomplish your goal through the command-line, SharpSvn, TortoiseSvn, or other similar tools.

John Fisher
+2  A: 

For 1), it won't delete the revision history, but the new files will be treated as completely unrelated to the old ones. You still could get the old files back though.

For 2), that would be the recommended way. But after 'svn delete'ing the existing files and adding the new ones, you also have to 'svn add' those new files before committing.

But it seems you should consider using the svn-load-dirs.pl script. You can read about this in the Subversion book, chapter "Vendor branches".

Stefan
A: 

Since you can't overwrite the directories or you'll destroy the .svn directory and lose all the repository information, you have to copy the files over but only create new directories. This is how I would do that, from within the subversion working copy you want to update:

(cd <newdirectory> ; tar -cf - * ) | tar -xf -

Granted you need a Unix-y system. It should work with Cygwin, unless Windows does something particularly bizarre with overwriting folders at the system level.

Otto