From: "Ondrej Certik" <ondrej@certik.cz>
To: "Git Mailing List" <git@vger.kernel.org>
Subject: bidirectional hg <-> git syncing
Date: Wed, 5 Nov 2008 13:48:37 +0100 [thread overview]
Message-ID: <85b5c3130811050448s28f2a26by266f9d674ecdacfd@mail.gmail.com> (raw)
Hi,
I wanted to share how we sync hg and git repo and I am interested if
anyone has any comments to it.
In our project [0], we used Mercurial, but recently several of the
core developers including me switched to git, but because we already
wrote docs and taught our users to use mercurial (see for example
[1]), we want to support both. So currently our main repo is still
mercurial and we automatically convert to git using
Our /home/hg/repos/sympy/.hg/hgrc contains:
[hooks]
#update the git repo
changegroup = /home/git/update-sympy.sh
where /home/git/update-sympy.sh is:
-----------
#!/bin/bash
cd /home/git/repos/sympy
sudo /bin/su git -c "../fast-export/hg-fast-export.sh -r /home/hg/repos/sympy"
cd /home/git/repos/
sudo /bin/su git -c "rm -rf sympy.git"
sudo /bin/su git -c "git clone --bare sympy/.git/ sympy.git"
sudo /bin/su git -c "echo 'main SymPy repository' > sympy.git/description"
sudo /bin/su git -c "touch sympy.git/git-daemon-export-ok"
---------
Which uses hg-fast-export to update the git repo.
Before pushing any patches in, we need to convert them to mercurial.
So if the user uses mercurial, nothing changes. If the user (like me)
uses git, I need to convert the patches to mercurial first, so that I
can push it in. So I do the following sequence, starting off my master
branch:
git checkout -b fix
# do some commits
./hgconvert
where the ./hgconvert script is:
-----
#! /bin/bash
work=`mktemp -t -d sym.XXX`
git format-patch -k -p -o $work master..HEAD
# add a new line after the subject line so that Mercurial imports it fine.
sed -i '4a\\' $work/*
cd ~/repos/sympy.hg/
hg import $work/*
rm -r $work
---------
This takes all patches commited after the master and commits them to
my hg repo at ~/repos/sympy.hg/. I'll then push them in, both our hg
and git repo updates and then I do in my local git repository:
git checkout master
git pull # this pulls the changes, essentially the same as in the
"fix" branch, only from our official git repo
git branch -D fix
This works nicely as long as I do not do any merges in my local git
repo. Is there some way to also convert the branches and merges? As I
understood it, there are tools that only convert the whole repo, but
since we already convert the whole repo from hg to git, I need to only
convert the latest commits from git back to hg.
One solution is to fully switch to git and convert to hg automatically
on our server -- and that's what we'll do soon probably. Then we'll be
able to push nonlinear history in git, but only linear in mercurial.
Thanks,
Ondrej
[0] http://code.google.com/p/sympy/
[1] http://docs.sympy.org/sympy-patches-tutorial.html
Ondrej
reply other threads:[~2008-11-05 12:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85b5c3130811050448s28f2a26by266f9d674ecdacfd@mail.gmail.com \
--to=ondrej@certik.cz \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox