blog 文章

2017年11月17日 星期五

git clone hg repository and vice versa

希望大家不會遇到像我這樣的問題, 我很喜歡 git, 希望世界上只剩下 git, 但這是不可能的, rcs, cvs, svn, mercurial 還有很多沒聽過得版本控制軟體都存在世界上。

由於需要使用 mercurial, 我實在用不慣, 找到了可以用 git clone mercurial repository 的方法。需要安裝 git-remote-hg。
git clone hg repository:
Bridge support in git for mercurial and bazaar
https://felipec.wordpress.com/2012/11/13/git-remote-hg-bzr-2/

apt-get install git-remote-hg

git clone "hg::http://username:password@a.b.com/x/y/z"
就這麼簡單, 沒了。
不過在操作 git push 時失敗了, 出現

TypeError: getchangegroup() got an unexpected keyword argument 'heads'
參考了 https://github.com/felipec/git-remote-hg/issues/66
但是搞不定。


另外一個作法:
git-cinnabar

apt-get install python-requests

git clone https://github.com/glandium/git-cinnabar.git
將 clone 的目錄加入 PATH
ex:
export PATH=/home/descent/git/git-cinnabar:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

git cinnabar download
make helper

一樣的 clone hg repository 指令:
git clone "hg::http://username:password@a.b.com/x/y/z"
git push 正常。



我體會到一樣的痛苦, 反過來照顧一下需要用 hg clone git repository 的使用者。

hg clone git repository:

apt-get install python-dulwich python-dev
easy_install hg-git

編輯 ~/.hgrc:

[extensions]
hgext.bookmarks =
hggit = 

clone git ssh repository
hg clone git+ssh://username@ip_or_domain_name/a_dir/b_dir/u-boot.git

舉例來說, 如果你想要 clone https://github.com/descent/simple_stdcpplib.git, 可以這樣下 hg clone 指令:
hg clone git+https://github.com/descent/simple_compiler.git

hg clone 會把 git repository branch 轉成 hg bookmark

Using TortoiseHg with Git
https://mcmblog.azurewebsites.net/using-tortoisehg-with-git/

the Hg-Git mercurial plugin

沒有留言:

張貼留言

使用 google 的 reCAPTCHA 驗證碼, 總算可以輕鬆留言了。

我實在受不了 spam 了, 又不想讓大家的眼睛花掉, 只好放棄匿名留言。這是沒辦法中的辦法了。留言的朋友需要有 google 帳號。