Anyway, if you need to import a repository into another and relocate some entries, this can be hard and is not supported natively in the 1.4 tools.
People will be tempted to just copy the files in, but never underestimate the power of the change log!
svn admin load will happily load a dump file at a given location, but the only way to generate such a file for mortals is to use svnadmin dump and there are no options to relocate paths that inconveniently have unwanted prefixes.
The tool svndumpfilter will allow inclusion and exclusion only : good for purging a rogue directory full of customer credit card no.s but no good for nestling a bunch of commits into a pre-existing folder.
There are a few examples of instructions on how to do this out there:
but all seem to have some flaws relating to things like copy-from which happens for renames
The script at the end seems to do the full set of tasks for what I needed:
- dump the source repository of interest
- filter out everything except the desired location
- relocate all node entries in the dump, taking into account renames
All it requires is the Subversion command line tools and sed, which for windows you can easily obtain from GNUwin32.
This script was originally written to split a single repository into multiple dumps that could be imported into different locations in the destination repository, which is why it looks a little hard-coded: there where more calls to :extract for each set of related paths to be extracted.
Once used the dumps can be imported easily using svnadmin load and the --parent-dir argument with the outputs piped into the process.
The end result will be a load of the required changesets, giving a bit of a spike in the commit history. Note that people who sort their commit history by date will most likely become very confused at this point as time seems to go backwards and forwards, because the commit dates are preserved. This can't really be helped unless you want to fake up some dates and in that case why did you need the history. I think people get over it quite quickly.
So, without further ado: here's the batch file!
@echo off
if (%1) == () echo need dump file! && exit /b
SET DUMP_INPUT=%1
SET DUMP_OUTPUT=ImportProject
call :extract /trunk/Location1 /trunk/Location2
exit /b
:extract
echo extracting to %DUMP_OUTPUT%.dump from %DUMP_INPUT%...
shift
shift
echo paths to be included are %*
pause
svndumpfilter --drop-empty-revs --renumber-revs include %* < %DUMP_INPUT% > %DUMP_OUTPUT%-orig.dump
echo done extracting
:: here comes the tricky bit
echo trimming /trunk from paths
echo munging Node-path...
sed -e "s,^Node-path: trunk/,Node-path: ," %DUMP_OUTPUT%-orig.dump > %DUMP_OUTPUT%.dump.tmp
echo munging Node-copyfrom-path...
sed -e "s,^Node-copyfrom-path: trunk/,Node-copyfrom-path: ," %DUMP_OUTPUT%.dump.tmp > %DUMP_OUTPUT%.dump
echo trimming done
echo.