7

I've found what appear to be very similar questions here on SO, with what appear to be good answers; but for some reason, I still can't seem to figure out how to get this to work. My concern is that it may simply not be possible.

Here's the situation: I am working on a small team that uses a central SVN repository as our version control system. My pair programmer and I got frustrated not having the option of local commits (and didn't want to have to go through the hassle of using SVN branches), so we looked into using either Git or Mercurial as an SVN client and found that hgsubversion seems capable of doing what we want: to work locally on an Hg repository, commit locally, and only push to SVN when we're ready.

When the time came to push, we received this error message from Hg:

Sorry, can't find svn parent of a merge revision.

I'm wondering if the problem is that we had to pull changes from SVN to get our teammates' updates, then merge with our local changes, and now Hg can't figure out how to make SVN happy? This seems to be the message I'm getting from the other SO questions & answers I've looked at; however, the advice that was dispensed in those cases (doing hg rebase --svn) seems not to work for us either; that same "can't find svn parent" message is given.

Is this even possible? Or is it more trouble than it's worth when other developers on the team are making changes directly to SVN?

Dan Tao
  • 125,917
  • 54
  • 300
  • 447
  • Since you mentioned Git.. I use git-svn regularly to interact with Subversion repositories. I can interact with others either through SVN or through Git directly, and have no problems pushing things back up to Subversion (after rebasing). I haven't used the hg-svn connector to compare. – Greg Hewgill Mar 24 '11 at 20:58
  • You can't push hg merges into svn. You need to transform your Hg repo to a linear version history. http://stackoverflow.com/questions/5336192/steps-needed-to-allow-hgsubversion-svn-clone-to-push-back – Rudi Mar 25 '11 at 08:12

2 Answers2

6

I've been doing this for over a year now and it works great. I get sweet, sweet DVCS love and the rest of the folks, uh... don't. I use hgsubversion as my bridge. I had quite a bit of trouble with hg-svn. YMMV.

I used this to get setup and have been loving it ever since!

The caveat is, you can't use Mercurial to merge changes between branches. You can still work on the branch (use hg up [some-branch]), but when it comes time to merge it into trunk, you'll need to commit, push to some-branch, then use subversion to merge some-branch into trunk.

I've prepared a blog post that describes this procedure in detail. You can see it here: http://xinmyname.tumblr.com/post/11305033055/subversion-mercurial-branches-oh-my

Good luck!

Andy S
  • 8,641
  • 6
  • 36
  • 40
  • 1
    Andy, I like your hint about how to pragmatically deal with branching between Hg and SVN. Could you provide further details of how to do this as this in detail? I want to do this (SVN is my upstream project where I have a set of changes I want to apply but the gatekeeper wants me to submit into different SVN branch first before he accepts and merges it into the SVN trunk). So currently I cloned SVN's trunk with hgsubversion. Should I first create a branch with SVN directly? And then use hgsubversion to clone this branch which would then be where my commits later go? – J.D. Oct 08 '11 at 04:30
  • Aye, I'd like more detail too. I'm trying to use hg while everyone else is on SVN, but seems pointless if I can't have different branches locally. What it sounds like is you may have to manually push changes to the hg branches? All SVN cares is a linear history, right? if I'm not ready to commit to SVN, can I have multiple branches behind the scenes? I went with bookmarks this time, but not sure that is what I really want either. – nportelli Oct 10 '11 at 12:56
  • I suppose that would be a blog worthy post, eh? I'll try to work something up this evening and post a link. And yes, you have to manually push changes back to SVN. At least, as far as I know. Maybe someone knows a better way? – Andy S Oct 10 '11 at 17:07
  • I put together a pretty detailed blog post on how to setup and merge branches from Subversion. It's available here: http://xinmyname.tumblr.com/post/11305033055/subversion-mercurial-branches-oh-my – Andy S Oct 11 '11 at 04:30
5

The problem is that hgsubversion can't push merges from Mercurial to Subversion. As long as you don't create any merge changesets, everything should work fine. (FWIW Subversion merges work fine, as hgsubversion simply disregards the merge info and creates regular, single-parent changesets.) The problem you are describing is one of the known limitations of hgsubversion; others are listed in hg help subversion.

In order to work around this, you might want to consider using the rebase extension to ensure that the history to push is perfectly linear.