Git bridge to Mercury

I work mainly with Git and have a lot of code in github. I would also like to have it on Bitbucket, for people using mercurial, but more importantly, because I want to have code on my domian as well, and BItbucket supports Cnames for hosted code.

So, there is a way for me to basically work with Git, but also be able to click on HG.

Github created the project in a different direction (for HG repos git), but is there any direction for me.

+4
source share
2 answers

If you just create a mirror of the Git repository, then you can configure the cron job to run the following script:

#!/bin/bash USER=bitbucketuser ERROR_FILE=clone_update_err CLONES=/path/to/clones cd $CLONES if [ $# -ne 1 ]; then for DIR in *; do if [ -d $DIR ]; then ./update.sh $DIR 2> $ERROR_FILE if [ -s $ERROR_FILE ]; then echo $DIR >&2 cat -n $ERROR_FILE >&2 fi fi done else DIR=$1 echo $DIR cd $DIR if [ -a source ]; then cd source if [ -d .hg ]; then hg pull elif [ -d .git ]; then git pull elif [ -d .bzr ]; then bzr pull elif [ -d .svn ]; then svn up else echo "$DIR is not a known repository type." return 1 fi cd .. hg convert source hg URL=ssh:// hg@bitbucket.org /$USER/$DIR/ cd hg hg pull $URL hg push $URL # You can add -f here if you don't mind multiple heads cd .. else # hg dir or hg-git cd hg hg pull hg push $URL cd .. fi cd .. sleep 5 fi 

It is assumed that you have the SSH key installed. As you can see, this will reflect other VCSs. It assumes a directory structure as follows:

 clones/ project1/ source/ # Original Git/Bazaar/SVN/Mercurial repo hg/ # Mercurial repo 

Obviously, this is only one-way, but if you do all your work in Git, then it does not matter.

+4
source

I was going to add this to my other answer, but it was a little delayed, so we will do it as a separate answer.

If you want to go both ways, you can use hg-git to get the hg repo version on your computer, you can still do all your work in Git, it just means that you will use GitHub as your intermediary.

 $ cd src # do some work # push to GitHub $ cd ../hg $ hg pull $ hg push bitbucket 

However, it makes sense that if you want to pull changes from the Mercurial user, you can pull them into the hg repository and push them into GitHub.

 $ cd hg $ hg pull someotherrepo # Probably merge $ hg push # Changes go to GitHub $ cd ../src $ git pull # Continue working in Git 
+7
source

Source: https://habr.com/ru/post/1315212/


All Articles