How to replace a directory in a SVN repository without breaking anything

davmorr picture davmorr · Apr 14, 2011 · Viewed 14.9k times · Source

I need to replace a directory in my SVN repository on the production server, but am not sure of the correct way to do this without breaking anything. The directory being replaced is a third-party module revision that has been completely restructured, so in order to upgrade cleanly I need to deleted the old directory/files and replace with the new directory and files. When I do this (using svn delete) the working copy becomes obstructed or in a state that prevents me from committing or adding the new, unversioned directory to the working copy. I've tried svn update, svn cleanup, as well as other UI (TortoiseSVN and Cornerstone) fix-it shortcuts, but can't seem to get things re-synced - that is without rolling back to a previous revision or checking out a new copy.

I believe that the target directory on both the local working copy and remote repo have to be deleted, the working copy updated, the new directory added to the working copy and then committed to the repo; but I am unsure of the specifics or any missing steps or subtleties that I may be missing. The module that I am upgrading is pretty vital to the site application, so I need to get this right the first time - as this is being made on the production server - and has to be done quickly. If someone could map the steps out clearly, I would really appreciate it.

Answer

Simon picture Simon · Apr 14, 2011

To make this easier, you can do it in a way that creates a single "broken" revision where the directory doesn't exist.

  1. svn up to get your working copy up to date
  2. svn delete <directory> to get rid of the current directory
  3. svn commit -m 'Deleted old module'
  4. Copy in the new directory to the working copy
  5. svn add <directory> to add your new directory structure
  6. svn commit -m 'Added new module'

This question has details about how to use "Vendor Branches", which may prove to be a better solution for your situation.