Skip to content
b4winckler edited this page Aug 17, 2010 · 15 revisions

How this repository was cloned from the Vim Mercurial repository

The hg-git Mercurial extension (as well as Mercurial itself) is required in order to track a Mercurial repository with Git, see below on how to enable it.

Create local Mercurial clone:

$ hg clone https://vim.googlecode.com/hg/ vim
$ cd vim

Add bookmark to master branch:

Make sure the bookmarks extension is enabled before this step (see below).

$ hg bookmark -r default master

(Optional) Add bookmark to other Mercurial branches:

$ hg bookmark -r vim73 hg/vim73

Set up Mercurial so that it pushes to the Git repository:

Edit vim/.hg/hgrc and add default-push path:

[paths]
default-push = git+ssh://git@github.com:b4winckler/vim.git

Push all changesets to the Git repository:

$ hg push

Updating the Git repository:

Every time the Mercurial repository is modified it is necessary to manually update the Git repository.

First pull and merge all new changesets from the Mercurial repository (see below on how to enable the fetch extension which is used in this step).

$ hg fetch

It seems that bookmarks created with the -r flag are not automatically updated when you fetch the latest changesets, so manually update the bookmarks (is there a better way to handle this?):

$ hg bookmark -d master
$ hg bookmark -d hg/vim73
$ hg bookmark -r default master
$ hg bookmark -r vim73 hg/vim73

Now push all new changesets to the Git repository:

$ hg push

Setting up Mercurial:

Install hg-git:

$ sudo easy_install hg-git

To enable the extensions used above, edit ~/.hgrc and add:

[extensions]
bookmarks =
hggit =
fetch =

Notes

Note that the hg-git bridge is lossless, so that:

  • If you loose your local Mercurial repository, the above steps can be repeated to set up a new one and you can continue updating the Git repository (only new changesets will be pushed).
  • If somebody else sets up a Git clone of the Mercurial repository you can git-pull from that to update your own Git clone (the Git commit ids are identical).
  • A maintainer of the Mercurial repository can pull changesets into a Mercurial repository from a cloned Git repository.
  • You can use Mercurial to clone a Git clone (if you prefer using Mercurial over Git). New changesets can be pulled from either the original Mercurial repository or from any Git clone. (Normally you would just clone the Mercurial repository, of course.)
Clone this wiki locally