Extracting a Directory into its Own Subversion Repository[source]

xml
<glacius:metadata>
    <title>Extracting a Directory into its Own Subversion Repository</title>
    <description>Legacy blog post about extracting a directory in a subversion server to its own, new repository</description>
    <category>Subversion</category>
    <category>Source control</category>
    <category>Programming</category>
    <category>Legacy blog posts</category>
</glacius:metadata>
<glacius:macro name="legacy blargh banner">
    <properties>
        <originalUrl>https://tmont.com/blargh/2009/10/extracting-a-directory-into-its-own-subversion-repository</originalUrl>
        <originalDate>2009-10-27T04:41:30.000Z</originalDate>
    </properties>
</glacius:macro>
<p>
  Like my <glacius:link page="articles/running-a-subversion-server-on-windows">previous subversion 
  post</glacius:link>, this is something that is a bit difficult to find on the internet.
</p>
<p>
  Every so often, you realize that a project is growing too big, and it deserves its own repository. What 
  you want is to extract a single directory from one repository, and create an entirely new repository that
  only has the revisions related to that one directory in it. And it would be nice if they started from one. 
  Luckily, subversion provides just such a tool for doing it.
</p>
<p>Suppose your repo looks like this:</p>
<glacius:code lang="plaintext"><![CDATA[/foo
/bar
--/src
--/tests
--/www
----/css
----/images
----/js
--/bin
/baz
/bat]]></glacius:code>
<p>
  and you want to remove the "bar" directory and create a new repository out of it. Here is what you would do:
</p>
<glacius:code lang="bash"><![CDATA[
svnadmin dump /path/to/big/repo > repodump
cat repodump | svndumpfilter include bar --drop-empty-revs --renumber-revs > newrepodump
svnadmin create newrepo
svnadmin load newrepo > newrepodump]]></glacius:code>
<p>
  You'll probably want to create trunk, tags and branches for your new repo, so you have two choices:
</p>
  <ol>
  <li>Try and figure out how to modify the dump file and delete the proper nodes (impossible)</li>
  <li>Say screw it, and just <code>svn mv</code> the files around after you've loaded the revision into the new repo</li>
</ol>
<p>
  This is all fine until you realize that <code>svndumpfilter</code>doesn't play nice with an 
  <code>svn mv</code> outside of the directory you're filtering. That's when you have to play 
  with the <code>exclude</code> subcommand, and pipe the output about 30 different times to 
  <code>svndumpfilter</code> until you've got what you want. It's not enjoyable. I'll leave this one 
  as an exercise to the reader.
</p>