0

I have a StarTeam repo that I'm trying to migrate to SVN. Unfortunately the repo is HUGE, so I can't use any of the polarion scripts, etc. I'm resorting to checking out snapshots of each release in StarTeam and then manually adding/committing them to SVN.

However, I'm confused about what to do for old files. In StarTeam, we had to move deleted files to an "obsolete" folder since the purge command removed all copies of the file. I know that I don't need to do that in SVN, but how does SVN deal with files which have been deleted/are missing?

Say I have three files in the following structure:

trunk/
    Src/
        A.cpp
        B.cpp
        C.cpp

If from one release to another I deleted "C.cpp", do I just need to commit all of src for the deletion to be reflected in the SVN repo?

Likewise, if I deleteed "C.cpp" but added "D.cpp", I would need to call add on all of "src/" before committing. Would that cause any problems with detecting and deleting the missing files? There are too many of them to go through manually and delete every one individually.

As a separate question, is there a reason why it takes tortoiseSVN almost 3 hours to detect which files are changed before I can add/commit? All I see is the "Please wait..." message in the dialog box, and it takes FOREVER.

Thanks!

Jordan
  • 9,014
  • 8
  • 37
  • 47

1 Answers1

1

Any change you make to the repo needs a commit, so yes after doing svn delete you need to svn commit. Similarly when you add files, that's a change that needs to be committed. In both cases it's possible to undo the add and delete without commiting.

In terms of adding and removing files in one transaction, again that "just works", you'd effectively issue:

svn delete C.cpp
svn add D.cpp
svn commit

If you want to recover a deleted file, then you can just recover the file from an earlier revision of the svn repo, then recommit (see also What is the correct way to restore a deleted file from SVN?).

The main thing you must remember though when deleting files: you must delete it using subversion tools (i.e. from the command line as svn delete or using Delete within TortoiseSVN. Just deleting it using del, rm, or a file manager like windows explorer will have SVN see the file as "missing" and not "deleted", and a commit of the repo will not commit the delete; thus the next time you update your working copy, the missing files will be restored. Thus you use subversion to delete the file so subversion knows that you do actually want it deleted.

For your last question -- what version of SVN and how big is the repo (in terms of file-count). Essentially T-SVN has to walk the tree and check each file against the repo-version to see it it's changed. As of SVN 1.7, the working copy format changed with a lot of metadata being held in the database, and improvements to the storage of pristine copies (i.e., what the file looked like when it came out of svn) means that it's faster than it was. If you aren't using 1.7, then it's worth checking out. Also, if you have a large repo but only work in a small part of it then consider using sparse checkouts to reduce the size of your local working copy. See this answer to Checkout one file from Subversion for a brief overview or sparse checkouts.

Community
  • 1
  • 1
Chris J
  • 30,688
  • 6
  • 69
  • 111
  • Yes, but if I have a bunch of files which were deleted in later snapshots, how do I get them to delete from the repo WIHTOUT having to go through manually and deleting each one? – Jordan Dec 20 '11 at 14:40
  • You'll need to look into scripting this. The key command to consider is `svn status`. I'm thinking how to translate this into Windows without Cygwin, but on a UNIX box, you can use `svn status` as follows to remove missing files from the repo: `svn delete \`svn status | awk '/^!/ { print $2 }'\` `. Similarly for `svn add` search for `?` instead of `!` in the output from `svn status`. – Chris J Dec 20 '11 at 15:57
  • After poking ... you might be able to do it in two parts: `svn status | findstr /R "^!" > c:\temp\missing_files.txt` and then `for /f "tokens=2" %i in (c:\temp\missing_files.txt) do svn delete %i` ... and similarly for `svn add` as well. – Chris J Dec 20 '11 at 16:04
  • Couldn't I just fully delete the folder in my working copy (locally), "svn add", and then "svn commit"? – Jordan Dec 20 '11 at 16:21
  • Perhaps I should mention that I'm using TortioseSVN. It seems to realize after I did an add on the folder and then tried a commit that the files are deleted, but it gives me an error that the directory is out of date and that I should update first. – Jordan Dec 20 '11 at 16:32
  • It seems to delete the files in a folder alright, but it fails when it tries to delete the folder itself, presumably because it was "touched" or something and is now out of date. Is there a --force option with tortoiseSVN? – Jordan Dec 20 '11 at 16:39
  • What version of (T)SVN are you using? Prior to 1.7, SVN keeps working copy information in hidden `.svn` folders in each folder. IF you delete the folder, you lose the metadata and thus will confuse Subversion. With 1.7 onward, metadata is held in a single folder at the checkout root -- I don't know what happens if you blow away an entire folder though, but it would be safer, if you can, to checkout over the top of the existing checkout. – Chris J Dec 20 '11 at 17:11
  • For the type of operations you're doing, you may want to look at the command line tools though as this should be something that sounds like it would be scriptable. – Chris J Dec 20 '11 at 17:13
  • I'm using the latest tortoiseSVN version. CHecking out over the existing code doesn't make sense, because 1) It's from a different source control repo (StarTeam), and 2) There are files which were deleted in later revisions that exist in earlier revisions. If I don't blow it all away, won't the files which need to be deleted still exist? – Jordan Dec 20 '11 at 18:08
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/6015/discussion-between-jordan-and-chris-j) – Jordan Dec 20 '11 at 18:11