17

We're migrating from Subversion to Mercurial and have run into a bump in the SVN->Hg conversion process. Right now, our single SVN repo holds code for a couple distinct "projects", and we'd like to split them apart in the migration process. Our SVN repo is organized as:

.
|-- proj1
|   |-- branches
|   |-- tags
|   `-- trunk
`-- proj2
    |-- branches
    |-- tags
    `-- trunk

and we'd like to simply make proj1 and proj2 their own Hg repos. We'd like to, of course, not have history specific to proj1 appear in proj2's log either. Right now, when hg convert does the conversion, it just reads all the files pretty dumbly, not even distinguishing branches from trunks.

What's the process for filtering by directory and recognizing SVN branches in hg convert?

erjiang
  • 44,417
  • 10
  • 64
  • 100
  • 1
    +1 This is a really important question and relevant at many companies. – Andres Jaan Tack Nov 17 '10 at 23:43
  • @Andres Jaan Tack: why were not projects organized as separated repositories at the beginning of work then? – zerkms Nov 18 '10 at 00:09
  • 1
    @erjiang: If you were happy using 2 projects in 1 repo using svn, why don't you follow the same (incorrect) schema and with mercurial? ;-))) – zerkms Nov 18 '10 at 00:11
  • 1
    I'm gonna go with "use SVN to sort the mess out and then import into Hg" aka "How do you split SVN repos into two projects and keep the appropriate data with each" ... you're trying to shoehorn two projects under one banner. At least, that's the case from where I'm standing. – jcolebrand Nov 18 '10 at 00:14
  • @zerkms: Perhaps the same reason that ALL of KDE was in one SVN repo. They were two somewhat-related projects (a lot of the same people working on both), and having them in one repo saved some work setting up SVN. The reasons we justified it with don't really hold in Mercurial, so... – erjiang Nov 18 '10 at 03:23
  • 4
    All in one is pretty good setup in svn because there's the ability to checkout only portions of a tree. Mercurial (and other DVCSs) just don't offer that, which is why convert and filemap make it pretty easy to split out a repo. – Ry4an Brase Nov 18 '10 at 03:31
  • 1
    Here's the similar question: http://stackoverflow.com/questions/3066298/split-large-repo-into-multiple-subrepos-and-preserve-history-mercurial/3067054#3067054 – Ry4an Brase Nov 18 '10 at 03:32
  • @erjiang: "repo saved some work setting up SVN" -- you saved a lot of time on ~20 keystrokes of `svnadmin create ...` ;-) – zerkms Nov 18 '10 at 03:54
  • 1
    -1 to all unhelpful commenters. – Binary Phile Nov 18 '10 at 05:51

3 Answers3

8

I've got it working now, thanks to the ConvertExtension wiki page!

I tried Ry4an's method, but it came with the downsides of having to first convert the SVN repo into an intermediate Mercurial repo before splitting everything, and that branches, trunk, and tags weren't being recognized because there are two projects each with their own branches, trunk, and tags.

I found that manually specifying the branches, trunk, and tags directory worked great for converting one project from SVN to Mercurial at a time:

hg \
--config convert.svn.trunk=proj1/trunk \
--config convert.svn.branches=proj1/branches \
--config convert.svn.tags=proj1/tags \
convert --authors authors.txt original-svn-dir hg-proj1

This will take care of recognizing SVN branches, tags, and trunk and filter for only proj1 revisions at the same time. Then, I just repeated it for proj2.

erjiang
  • 44,417
  • 10
  • 64
  • 100
  • Glad you got it working. The drawback with multiple svn->hg conversations is that the svn->hg piece takes much much longer than the hg->hg pieces, so given the iterative nature of getting authormaps, splits, etc. right doing the svn->hg once, and doing (and redoing) hg->hg for each project usually saves time. Also, if you're going to be using convert's support for incremental conversion (ie: do this again in a month bringing in the new svn stuff w/o altering hg hashids) you need a single svn convert. – Ry4an Brase Nov 18 '10 at 14:58
  • It was a local->local conversion, so it wasn't too bad time-wise. – erjiang Nov 18 '10 at 15:29
2

Another way to solve it would be to use svnadmin dump and svndumpfilter to split the svn repo into one new svn repository per project as described in the svn documentation. Splitting repositories by filtering repository history

8DH
  • 2,022
  • 23
  • 36
0

This is easily done using the 'convert' extension as you've suggested. Here's the procedure:

  1. do a hg convert SVNREPO all-in-one-mercurial-repo from svn to mercurial with everything
  2. do multiple hg convert --filemap projectfilemap.txt all-in-one-mercurial-repo project-repo commands -- one per project

Those filemaps have in them lines like:

exclude proj1
rename proj2 .

That would the the filemap used when extracting just project two's repo from the all-in-one mercurial repo. You may need to list each individual file in those maps, but I think directories are okay.

There's another question here on SO where I answered pretty much the same thing and pasted in a full example, but that should be enough to get you going.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169