1
votes

I am currently in the process of figuring out how best to approach moving from SVN to Mercurial.

I've done some research into recommended Mercurial repository structures - see Subversion Re-education, Recommended Mercurial repository/folder structure for an SVN user and (Yet another) What's the best conversion from an SVN repository to HG repository(ies)?.

I think I have the structure in place now, but I'd like some advice on how best to approach the actual conversion.

Just for reference, here's our current SVN structure:

Project-repository
    Trunk
        ProductA
            Trunk
            Branches
            Tags
        ProductB
            Trunk
            Branches
            Tags
    Branches
        ClientA
            ProductA
                Trunk
                Branches
                Tags
            ProductB
                Trunk
                Branches
                Tags
        ClientB
            ProductA
                Trunk
                Branches
                Tags
            ProductB
                Trunk
                Branches
                Tags
    Tags

and here's the proposed Hg structure:

Stable-ProductA-repository

Stable-ProductB-repository

ClientA-ProductA-repository (branched from Stable-ProductA-repository)

ClientA-ProductB-repository (branched from Stable-ProductB-repository)

Now to convert our current SVN structure into Hg, I'm thinking about doing it the following way using the Convert extension

  1. Convert "Project-repository/Trunk/ProductA" to Stable-ProductA-repository
  2. Convert "Project-repository/Trunk/ProductB" to Stable-ProductB-repository
  3. Convert "Project-repository/Branches/ClientA/ProductA" to ClientA-ProductA-repository
  4. Convert "Project-repository/Branches/ClientA/ProductB" to ClientA-ProductB-repository
  5. Etc. for ClientB

From what I've read, this seems like the proper way to structure your Mercurial repository and do the conversion from SVN to Mercurial, but I'm a bit unsure if I'm missing something. Specifically I'm unsure if changes made to e.g. the ClientA-ProductA-repository can be pulled from the Stable-ProductA-repository. We spend most of the time developing in client repositories, so we need to be able to merge changes back into the stable repository.

I'm aware that Mercurial supports subrepositories, but I'd like to move away from the nested repository structure and have clean cut so to speak.

So just to be clear on what I'm asking: Will it be possible to pull/push between repositories after the conversion from one SVN repository to multiple Hg repositories, and is my proposal for the new Hg structure sound?

1
You're right to want to move away from nested repos. The thing I'm not sure about is if you convert Trunk/ProductA into one repo, and the client branch into another, if you'll be able to pull and push between them. The alternative is having convert put ProductA with all its branches into a single repo, which I've seen done.Paul S
Thanks Paul. Do you have any information on how converting e.g. Product into a single repo is done?Tchami

1 Answers

2
votes

Specifically I'm unsure if changes made to e.g. the ClientA-ProductA-repository can be pulled from the Stable-ProductA-repository. We spend most of the time developing in client repositories, so we need to be able to merge changes back into the stable repository.

Initially, no, I don't believe you will be able to pull from them. However, it won't be too hard to do an initial manual merge. In fact, I believe it will be as simple as running:

clientA$ hg checkout $CLIENTA_HEAD
clientA$ hg pull ../stable
clientA$ HGMERGE=true hg merge $STABLE_HEAD
clientA$ hg revert --all -r $CLIENTA_HEAD
clientA$ hg ci -m "Merge stable into clientA, throwing away changes from stable"

Now, from this point on (well, after pushing those changes into stable, and possibly a bit more fiddling), the two repositories will share a common ancestor, so you will be able to merge between them.

I'm aware that Mercurial supports subrepositories, but I'd like to move away from the nested repository structure and have clean cut so to speak.

In general this is a good idea, just be careful if you have, ex, a utilities library that everything depends on — it's less painful to keep that in a subrepo to make sure that, for any version of your “main” repo, you can find out what version of the utilities repo it was built against.

So just to be clear on what I'm asking: Will it be possible to pull/push between repositories after the conversion from one SVN repository to multiple Hg repositories, and is my proposal for the new Hg structure sound?

Sounds reasonable to me.

The only other thing I'd change is that I'd use ProductA-ClientA instead of ClientA-ProductA because I'd prefer to see the repos grouped by product instead of by client… But there are likely good reasons to do it your way.