incubator-ooo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Stahl <...@openoffice.org>
Subject Re: fetch-all-cws.sh
Date Thu, 07 Jul 2011 10:00:14 GMT
On 06.07.2011 18:35, Herbert Duerr wrote:
>  > there is another tool, a HG extension called hg-git, which can
>  > convert HG bookmarks to git branches.
>  > http://hg-git.github.com/
>
> Great find! I was already brushing up my python and mercurial internals
> skills to extend hg-fast-export's export_commit() for our one big
> hg-repo with one hg-branch and many hg-bookmarks. I'm glad that cup passed.
>
>  > so my current plan is this:
>  > 1. convert OOO340 repo to git via hg-fast-export.sh
>  > 2. pull all CWSes into OOO340 repo and create bookmarks
>  > 3. use hg-git to push all of them into the converted git repo
>
> Sounds good!

unfortunately it won't work :(

problem is that hg-fast-export.sh and hg-git don't quite agree what a 
converted git repo should look like.
i've actually tried it out with a trivial repo and 2 branches and 
surprisingly it actually worked, but then i tried it on a real repo (the 
hg-git one), just take some arbitrary changeset and convert up to that 
with hg-fast-export.sh, then hg-git push of the rest fails...

next thing i tried is to convert the whole thing via hg-git push, but 
unfortunately they weren't lying when they used the word "slow".
after a couple of hours it had converted one percent of the changesets, 
and the progress predicted an ETA of >8 days.

so then i've taken a deeper look at the hg-fast-export code, and it 
seems surprisingly easy to hack it to do something with HG bookmarks.

basically a HG bookmark points at a single revision, and is thus quite 
similar to a git "ref".
the hg-fast-export writes a header for every changeset, with a branch 
name: "commit refs/heads/$branchname"

so i'm detecting all the HG heads that are marked by bookmarks, and just 
use the bookmark name as the branch name.
also, a bookmark for the head that corresponds to OOO340 is necessary.

then invoke it like this:

mkdir git
cd git
git init
hg-fast-export.sh -r ../hg -M dummy

the "-M dummy" sets the default branch, so all changesets that are _not_ 
heads end up on the "dummy" branch, and for every head/bookmark a branch 
pointing to that head is created.
the "dummy" branch/ref can be deleted after conversion.

i don't understand git very well, but i hope this should work :)

the tool already errors out if there is more than one head without a 
branch/bookmark.

the attached patch just adds 3 lines of actual code plus some parameter 
shuffling.
(a case that may not be handled properly is if there is a HG branch and 
a HG bookmark with the same name, but we don't have HG branches at all...)

i've started converting yesterday evening, and maybe it'll be finished 
today (on my 3 year old laptop...)

> I'd clarify step one to "convert OOO340 repo to a bare git repo via
> hg-fast-export.sh". After all these steps please don't forget git
> pack-refs and git repack (e.g. with "-a -d -f --window=200
> --depth=1000") to get a nice and tight repository.
>
> Herbert

Mime
View raw message