Question

I'm forking a project's SVN repo and need to integrate into my Mercurial repo. To keep things simple I have a local hgsubversion repo and a local hg repo. However both the mercurial and hgsubversion repo uses default as their default branch name. My goal here is to put the original code and updates on one branch and my code on the default branch

However I have yet to be able to do this.

W:\programming\tcsite-svn-test>hg clone http://*HG_SITE*/hg .
no changes found
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

W:\programming\tcsite-svn-test>hg branch blizzard
marked working directory as branch blizzard

W:\programming\tcsite-svn-test>hg commit

W:\programming\tcsite-svn-test>hg log
changeset:   0:be13a9580df0
branch:      blizzard
tag:         tip
user:        Leon Blakey <lord.quackstar@gmail.com>
date:        Fri Jan 14 23:44:25 2011 -0500
summary:     Created Blizzard Branch

W:\programming\tcsite-svn-test>hg pull http://*SVN_SITE*/svn/
pulling from http://*SVN_SITE*/svn/
....
pulled 23 revisions
(run 'hg update' to get a working copy)

W:\programming\tcsite-svn-test>hg branch
blizzard

W:\programming\tcsite-svn-test>hg branches
default                       23:93642a8890ab <------
blizzard                       0:be13a9580df0

Not surprisingly, hgsubversion puts pulled commits into the default branch when I really need them in the blizzard branch. From the docs, there is no way to rename the branch that a commit came from.

Frustratingly I can't even come up with a way to do it on a repo with only the hgsubversion repo being pulled from, nothing else. All commits are tied to that one branch no matter what.

Is there any suggestions on how to pull changes from an SVN repo and rename the branch to something else?

Was it helpful?

Solution

You have a few options here.

For one, the builtin extension 'convert' is significantly more flexible for one-way conversions, and can easily handle this using the --branchmap option. However, hgsubversion provides nice features for sync'ing back to svn, which are not provided if you're using hg convert.

In this case, would it be possible to just switch around your naming scheme? Use default for the 'imported from svn' case and use local or something similar for your local changes? You could then name independent projects on the codebase with different branchnames. I've used a similar mechanism in the past.

EDIT: Just caught this in the hgsubversion documentation:

hgsubversion.branch

Mark converted changesets as belonging to this branch or, if unspecified, default. Please note that this option is not supported for standard layout clones.

"Standard layout clones" almost certainly means cloning an entire project including /tags, /branches & /trunk in the normal svn fashion.

If I understand this correctly, you should be able to do something like

hg --config hgsubversion.branch=blizzard clone <svn-repo/trunk>

Not sure if you have to add that --config line every time you update from svn, but a little experimentation should confirm it.

If that doesn't work for some reason, the hgsubversion.branchmap feature is also available,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top