Sonntag, 2. Februar 2020

Moving hg to git

Bitbucket is shutting down there Mercurial support:
Sunsetting Mercurial support in Bitbucket

With that move I need to save my repositories somewhere else. For now github and gitlab seem to be the best choices available.

I don't have any fancy wiki or issue tracking or such things set up, so it will just mean getting the code from one place to the others.




My way uses the hg-git extension, which allows using git repositories with mercurial.

As of writing the latest available version in Debian is mercurial-git (0.8.12-1.2), but the official one is from a year later at tag 0.8.13. Either one can get it via pip install hg-git or just clone the repository and set the path to it in the ~/.hgrc:
[extensions]
hggit = [path-to]/hg-git/hggit

It may need some more python extensions like:
  • python-dulwich
  • python-brotli
  • python-ipaddress

Clone the mercurial repository (you will fine the Clone-button on the source-website), e.g.:
hg clone https://USER@bitbucket.org/USER/REPOSITORY

Create new a repository on github or a new project on gitlab.
Adjust the REPOSITORY/.hg/config to include the paths to those repositories, like:
[paths]
default = https://USER@bitbucket.org/USER/REPOSITORY
github = git@github.com:USER/REPOSITORY.git
gitlab = git@gitlab.com:USER/REPOSITORY.git

Those are the ssh-variants. It should also work with the https-variant, but currently there seems to be a bug, which results in
abort: git remote error: unexpected http resp 401

Using https one should set up the authentication in the auth-section in the .hgrc-file, e.g. like:
[paths]
default = https://myproject.googlecode.com/hg
[auth]
myproject.prefix = myproject.googlecode.com/hg
myproject.username = my.username
myproject.password = ******
myproject.schemes = https

For the ssh I set up two new keys, which were firstly not used giving the message:
git@gitlab.com: Permission denied (publickey).
abort: git remote error: The remote server unexpectedly closed the connection.

It seems, that the keys need to get registered in the ~/.ssh/config
I choose the simple option:
$ cat ~/.ssh/config
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/github.id_rsa
IdentityFile ~/.ssh/gitlab.id_rsa

Having branches and bookmarks in a mercurial repository, the hg-git extension basically just takes care of the bookmarks and treats them as git-branches. But it has the option to define a suffix, branch_bookmark_suffix, that then will be used as a trick.
[git]
branch_bookmark_suffix=_hgbranch

You have to create bookmarks on your branches yourself which need to end in the specified suffix. Those bookmarks will then be synchronized with git branches. And that synchronization will back propagate over hg bookmarks into hg branches.

Having hg-git, ssh-keys, repository-paths set up, a simple
hg push github
hg push gitlab

pushed all the things to those repositories.


https://bitbucket.org/Urfoex/
https://github.com/Urfoex/
https://gitlab.com/Urfoex/

Keine Kommentare:

Kommentar veröffentlichen

[Review/Critic] UDock X - 13,3" LapDock

The UDock X - 13.3" LapDock is a combination of touch display, keyboard, touch-pad and battery. It can be used as an extension of vari...