Hi I've converted a local svn repository to mercurial, commited several revisions in hg and want now to get the changes back into svn.
Can anyone advise in how to do it?I've found https://www.mercurial-scm.org/wiki/WorkingWithSubversion#With_Convert_extension but unfortunately, I haven't done开发者_运维问答 the conversion as described there (just did hg convert on the local repo) and didn't work with MQ, either.
Is there any chance to push back the individual revisions to subversion or is all I can to a local diff on the changes?
I think you might be able to use hgsubversion.
I'd try to do this:
- Clone the SVN repository using hgsubversion.
- Try to move your changes from your old repository to this new one. This might prove to be tricky. Here are some solutions:
- Adding changes from one Mercurial repository to another, which uses
export
andimport
commands, or thetransplant
extension. - Maybe you can use
hg pull --force
to pull changesets from that unrelated repository. (see How to combine two projects in Mercurial?) But then, after that, you would need to runmerge
, which might get buggy when you push your changes back to SVN. So maybe you can try usingrebase
ormq
extension. - Maybe you might be able to use
mq
extension to generate a bunch of patches on the old repository, copy them to the new one, and then apply them. - If all else fails, you can "manually" apply each changeset, one-by-one, by re-doing the changes you've done previously. (
hg diff -c rev_id
command will be useful)
- Adding changes from one Mercurial repository to another, which uses
- With all changes in your hgsubversion copy, just
push
them, and they will be added to the SVN repository. - ...?
- Profit!
This isn't as hard as people are making it out to be. Long term, I do suggest you use hgsubversion as the other answers suggest, but there is a pretty simple short-term solution.
- Check in everything in your hg repo
- hg up -r [last revision that was converted from svn]
- Check out from svn into a clean directory
- Copy the .hg directory from your hg repo to your svn checkout
- Check all of these svn changes into your hg repo (remember to add/delete files... this step will take a bit as hg has to scan everything this time)
- Merge the two heads you have now using hg (assuming svn has moved on ahead of you)
- Test the build (if needed) by pulling the changes back to your original hg repo and testing there (the idea is to keep your 'hg+svn repo' clean so missing/added files are easy to spot in the respective tools)
- Check in all the changes using svn (remember to add/delete files)
Once you have this in place, it's actually not too hard to use both systems on top of each other... but hgsubversion is probably a better solution if you need this long term. I personally use the above system because hgsubversion does not handle some of the rather bizarre things we've done to our svn repo in the past.
EDIT: I'm making an assumption with this solution that the svn trunk has moved on ahead of you; if this is not the case, this procedure becomes much simpler. If you want to merge each hg revision in separately, there should be no reason you can't do this, it'll just take a bit more work.
- Merge hg rev 1 to the svn tip... commit in svn
- Merge hg rev 2 to the svn tip... commit in svn
- Merge hg ...
I personally use Mercurial at work to work with our subversion repository. I strongly suggest you clone using hgsubversion, since it is able to commit back to the subversion repository when doing a simple push. The only thing is that you have to learn how to rebase your changes as you cannot use the merge functionality of mercurial (subversion simply cannot understand that a changeset could have two parents).
A converted repository as you have done is useful if you want to remove the subversion repo and replace it with mercurial. This is, unfortunately, impossible to push back (unless you want to start playing with diffs)
However, if you clone the svn repo with hgsubversion, you will probably (assuming no merges) be able to pull the changes you already made on your current converted mercurial depot into it. If there are merges, you will have to "linearize" it before transferring the changes.
精彩评论