Donnerstag, 28. Februar 2013

[SVN + Mercurial] Mirroring and using an SVN repository with Mercurial

For trying some code changes in the Blender Game Engine I needed its code. It is accessible via SVN from https://svn.blender.org/svnroot/bf-blender/trunk/
With Git and Mercurial around I'm used to do local changes, commit them locally and maybe undo them if I made mistakes. With SVN this is not possible.



Why do they still use SVN?
http://wiki.blender.org/index.php/Dev:Doc/FAQ#Why_not_switch_to_distributed_version_control.3F_.28git.2Fmercurial.2Fbazaar.29

There is even a discussion on the mailinglist:
http://lists.blender.org/pipermail/bf-committers/2011-May/032082.html

And?
Still SVN.
The Git mirror mentioned in the Wiki seems outdated.
But there are some unofficial ones on github:
https://github.com/ldo/blender-main
https://github.com/nicholasbishop/blender/

But compiling them gives you messages about missing locale, addons and addons_contrib. Those folders are normally pulled via SVN externals. So if you are using the Git mirror you still need to get those extra folders from somewhere. A way might be Git-Submodules.

Looking around I found hgsubversion: http://mercurial.selenic.com/wiki/HgSubversion
A simple one:
  • add hgsubversion to your extensions list
  • hg clone svn+repository
You should have plenty of time or a PC in the back to do that job because it really takes a long time for big repositories. It reads like every SVN commit and puts it into the Mercurial repository. You will have a nice version history afterwards.
The same I did for
"Locale" did again take a long time because most files in it are binary. That's why in the end it had a size of about 300MB. The SVN co of it is just about 50MB.
In the meantime I pushed the repositories to new created repositories on https://bitbucket.org/

After that I had the following:
The next step was to include the former SVN externals via Mercurial subrepositories http://mercurial.selenic.com/wiki/Subrepository
Just create a .hgsubs file in your hg root folder and insert the appropriate lines. Just like this:
release/datafiles/locale = [svn]https://svn.blender.org/svnroot/bf-translations/trunk/locale
release/scripts/addons = https://bitbucket.org/Urfoex/addons
release/scripts/addons_contrib = https://bitbucket.org/Urfoex/addons_contrib
You can use Mercurial, Git and Subversion repositories here.
I'm not sure right now if I had to checkout / clone those repositories myself for it to initially work. At least for SVN HG complained about locale "is not a working copy". But right now if I clone my repository and go to the right branch Mercurial pulls all subrepositories in without my help. It works just like with SVN and SVN externals.


Sounds easy so far.

Looking at the commit graph shows that I had some problems.
I simply can't delete branches. I made some to test if I can put some commits in the branch and then put commits from default to it to, like "rebase". Didn't really work as I thought and now I have some branches "just because". This also includes some commits that I made that I can't remove. Not reverting. That works. But real deletion.
Branches could be removed in 3 ways: http://mercurial.selenic.com/wiki/PruningDeadBranches
None worked for me. I finally merged and closed them but they are still there.  The clone-method somehow didn't work with hgsubversion. It technically worked but doing a "hg pull" that normally pulled new SVN changes in resulted in an error.
Another commit and another branch was just locally. "hg strip" did fine to remove those. (http://webcache.googleusercontent.com/search?q=cache:jYnn0rwFlkIJ:mercurial.selenic.com/wiki/EditingHistory+&cd=2&hl=de&ct=clnk&gl=de)
Somehow I managed to accidentally put a commit in the default branch. And hgsubversion created a new head for the new SVN incomings. Now I have two heads for the default branch and don't now how to safely change that. Every time I pull the changes from SVN in it create a new head. If I don't mind I can push that and have two heads. Or I merge those two heads together. That creates a commit and looks a bit ugly. But at least the last commit will unsure that the specific subrepo-changes are in.

One thing I would like to know is: What happens when my local hgsubversion repository that I use to pull SVN changes and push them to Mercurial gets deleted? How do I then push SVN changes? Can I simply create a new local hgsubversion repository and my pushes will work on top?


At least it works for now.

Btw.: If you gonna push to a different path then you pull you can tell hg to do so in the .hg/hgrc file. Just like this:
[paths]
default = svn+https://svn.blender.org/svnroot/bf-blender/trunk/blender
default-push = https://bitbucket.org/Urfoex/blender

I also create a very simple script for updating the  repositories:
$ cat update.sh
#!/bin/sh
echo "+==============================================+"
echo "-------------------- ADDONS --------------------"
echo "+==============================================+"
cd addons
hg pull
hg push
cd ..

echo "+==============================================+"
echo "---------------- ADDONS_CONTRIB ----------------"
echo "+==============================================+"
cd addons_contrib
hg pull
hg push
cd ..

echo "+==============================================+"
echo "------------------ BLENDER-HG ------------------"
echo "+==============================================+"
cd blender-hg
hg pull
echo "+==============================================+"
echo "!! Don't forget to merge changes for subrepos !!"
echo "+==============================================+"
hg push
cd ..

echo "+==============================================+"
echo "----------------- BL_HG_CLONE ------------------"
echo "+==============================================+"
cd bl-hg-clone
hg pull
hg push
cd ..

echo "+==============================================+"
echo "-------------------- LOCALE --------------------"
echo "+==============================================+"
cd locale
hg pull
hg push
cd ..

:-D
Very simple.


In the end it is possible to move a SVN repository to Mercurial or just use one that way. Moving it over is a nice opportunity.
But using it as a wrapper is a bit painful. It feels much better with just Mercurial or just Git.


Back to changing BGE code…

Keine Kommentare:

Kommentar veröffentlichen

[Review/Critic] UDock X - 13,3" LapDock

The UDock X - 13.3" LapDock is a combination of touch display, keyboard, touch-pad and battery. It can be used as an extension of vari...