From: Joshua Shrader Date: Fri, 18 Jun 2010 21:40:58 GMT Subject: Re: Fixing branches from a (really messed up) subversion repository Message-ID: In-Reply-To: I started with svnadmin dump /path/to/repo > svn.dump. Then I had to manually edit svn.dump (I'm sure someone smarter then me could roll this into the Perl script I used in the next step) to create a "trunk" and "branches" directory in the first commit. I found the commits that added "trunk" and "branches" when we re-organized our repo to follow this convention, and deleted them. Then I had to locate where all of the branches were created - looked like Node-path: branchname Node-kind: dir Node-action: add Node-copyfrom-rev: 23 Node-copyfrom-path: and change that blank "Node-copyfrom-path: " to "Node-copyfrom-path: trunk". The blank path is what really caused issues because everytime a branch was created, it would contain copies of branches which contained copies of branches, etc... So branch2 had a subfolder branch1, and branch3 contained branch2 and branch 1, where branch 2 contained branch 1... Then, I removed all of the contents of the commits (not the commits themselves) where we re-organized the repo. i.e. Node-path: trunk/src Node-action: add Node-copyfrom-ref: 23 Node-copyfrom-path: src and the ones where we deleted nested branches and moved the individual branches into a "branches" directory. I made these edits and saved them. Then I ran that file through a perl filter, tried to svnadmin load newrepo < filteredDumpFile, and if I got errors, I iterated - changed the pre-filtered file, blow away the svn repo that gave me an error during load, re-create it, and re-load. I iterated this over several days, as I discovered more and more inconsistencies with my edited dump file. I think I have all of the steps above, but I may be missing one or two, and if I am, I apologize. I'd imagine everyone's situation would be a bit different, so adjust accordingly. Now, I'm quite the Perl hack so I doubt you want to look at the script. It essentially did the following: Read each line of the dump file. If the line doesn't start with "Node-path:" or "Node-copyfrom-path:", then just print it un-altered. If it does, does what follows the ':' start with "trunk", "branches", or "tags"? If so, then just print un-altered. Otherwise, for each $branchname(@branchnames) if what follows the ':' begins with $branchname, replace it with "branches/$branchname", and print. If none of the branch names match, prepend "trunk" to the beginning of the path, and print. This essentially re-writes all of the paths so that everything not in a branch, or already under "branches", "tags", or "trunk", is put under trunk. It also moves all of the /branchenames to /branches/branchnames. After this, we did svnadmin hotcopy repo repo-backup rm -rf repo svnadmin create repo svnadmin load repo wrote: > On Fri, Jun 18, 2010 at 20:59, Joshua Shrader wrote: >> Thanks.  It took a couple days to get everything straightened out, but >> this seems to have worked very well. > > Mind sharing the details or code for what you did? > > I've only proved to myself that this approach will work, I haven't > actually done it. >