Search code examples
gitgithubmercurialhg-git

Using mercurial with hg-git as a github client


I am a satisfied user of mercurial, and I would like to use it to work with some repos on github. I have installed hg-git (still having connectivity problems but that's not the question) and looked at the documentation and various questions here on SO, but I am still unsure how complete a solution it provides.

  1. Are there important features of git / github for which hg+hg-git support is unavailable, limited, or problem-prone? I use branching and merging, tags, and occasionally mercurial's commit --amend command. I do not really need bookmarks, subrepos, custom hooks, or mercurial patch queues.

  2. Are there problems or limitations because of the different branching models of git and hg? (This six-year old question suggests that it was a less than seamless experience at the time.)

  3. On the hg-git site I read that "In theory, the changeset IDs should not change [in hg -> git -> hg conversion], although this may not hold true for complex histories." How worried should I be about this? Could it happen if I am just synchronizing (both directions) between github and a single hg repo?

I am looking at two use cases:

A) Using hg as a github client for a large-ish project, with lots of branches, that is normally developed by git users (master branch, etc.)

B) Using github to host my own (smaller) projects that I develop with mercurial.

I'm not expecting a 100% complete replacement. I have and use git, I just prefer to work with hg on a day to day basis. I do most of my work on OS X, if that matters.


Solution

    1. There are limitations to the use of hg-git, such as git-lfs. Repositories using large files will not work. There are corner cases such as octopus merges (merges with more than two ancestors) that will cause trouble on the Mercurial side as well as they do not have an equivalent in Mercurial. However in a day-to-day work it is rare to come across these limitations. In most cases hg-git will just work perfectly fine.
    2. Mercurial branches cannot be reflected properly into Git as git does not have the same concept. I think hg-git is mapping branches to bookmarks so you should keep using bookmarks. If you want to push a named branch somewhere to a git repository and then on the git side it is renamed you can't rename the named branch in Mercurial, so avoid named branches.
    3. In your case it is most likely going to be fine. hg->git->hg errors happen due to, e.g. name branch conversions, missing octopus merges, etc.