hg convert svn->hg - prevent branch deletion?

Patrick Mézard pmezard at gmail.com
Sun Jun 5 15:37:41 CDT 2011

Le 05/06/11 19:37, Judson Wilson a écrit :
> I am trying to convert an svn repo to hg.  I successfully ran svnsync and hg convert.  The problem is that there are no branches at all, trunk only.
> I am guessing this is because some of the latest commits in the svn repo deleted the branches (the latest revision of the SVN repo has no branches), which then caused the hg branches to be deleted.  Does this sound like a correct assessment?

>  I would like to keep the branches, perhaps archiving a bundle and manually deleting them later.   Is there something simple I can do? Maybe make a simple edit in a python file that blocks branch deletes from the svn repos?

The svn source works like:
- List project heads from config.svn.trunk/branches and check they exist
- Discover the whole revision graph by traversing the graph back in time
- Filter and sort the revisions to convert
- Convert them

What's failing for you is the heads discovery step implemented in hgext/convert/subversion.py#getheads() function. Discovering deleted branches is expensive because if requires scanning the whole revision history and guessing what is a branch and what is not, while the current code delegates this to the user. A more viable solution would be to introduce a new configuration option like:

svn.heads=/path/to/head1 at revhead1,/path/to/head2 at revhead2

Then getheads() could resolve the heads *at a given revision* instead of svn HEAD. If svn.heads is set, svn.trunk/branches would be ignored and the first svn.heads entry would be taken as the default branch, or something like that.

That said, if you are in a hurry, you can just hack your way in subversion.getheads()

Patrick Mézard

More information about the Mercurial mailing list