Programing

Mercurial Repository와 Git 상호 운용성

lottogame 2020. 5. 12. 07:58
반응형

Mercurial Repository와 Git 상호 운용성


Mac에서 GIT을 사용합니다. 충분했다. 도구가 있고 경험이 있습니다. 그리고 나는 그것을 계속 사용하고 싶습니다. 여기에 전쟁이 없습니다 ...

문제는 항상 상호 운용성입니다. 대부분의 사람들은 SVN을 사용합니다. Git SVN은 기본적으로 작동하며 주름없는 솔루션입니다. 사람들은 계속해서 행복하게 SVN을 사용할 수 있으며 워크 플로와 도구를 잃지 않습니다.

자 ... 일부 사람들은 Mercurial과 함께옵니다. 그들에게 좋습니다 : 그들은 이유가 있습니다. 그러나 즉시 사용할 수있는 GIT HG를 찾을 수 없습니다. HG로 전환하고 싶지 않지만 여전히 저장소와 상호 운용해야합니다.

당신들 중 누구라도 이것에 대한 간단한 해결책을 알고 있습니까?


2012 년 6 월 업데이트. 현재 개발자가 git 쪽에서 작업하려고 할 때 Git / Hg 상호 운용성을위한 다음과 같은 방법이 있습니다.

  1. Mercurial 및 hg-git 확장을 설치하십시오 . 패키지 관리자를 사용하거나을 사용하여 후자를 수행 할 수 있습니다 easy_install hg-git. 그런 다음 ~ / .hgrc에 다음이 있는지 확인하십시오.

    [extensions]
    hggit = 
    

    bookmarks여기 에서 확장명을 지정하는 것에 대한 언급이 있지만 v 1.8 이후 Mercurial에 내장되어 있습니다. 다음은 Windows에서 hg-git 설치에 대한 팁 입니다.

    hg-git이 있으면 위에 게시 된 Abderrahim Kitouni 와 같은 명령을 사용할 수 있습니다 . 이 방법은 2009 년 이후 개선되고 조정 되었으며 친숙한 래퍼 ( git-hg-again)가 있습니다. 최상위 디렉토리를 Mercurial과 Git의 작업 디렉토리로 동시에 사용합니다. defaultMercurial 저장소 (이름이없는) 브랜치 끝과 동기화 된 Mercurial 책갈피를 작성하고 해당 책갈피에서 로컬 Git 브랜치를 업데이트합니다.

  2. git-remote-hg 는 Mercurialhg-git확장을기반으로하는 다른 래퍼입니다. 이것은 또한git-remote-helpers프로토콜 (따라서 그 이름)을 사용합니다. Git 작업 디렉토리에 대해서만 최상위 디렉토리를 사용합니다. Mercurial 저장소를 노출시키지 않습니다. 또한 Git과 Mercurial 간의 동기화를보다 안전하고 관용적으로 gitlike로 만들기 위해 두 번째 베어 Git 저장소를 유지 관리합니다.

  3. 자식-HG의 스크립트 (이전의 유지 여기가 )에 따라 다른 방법을 사용 hg-fast-export로부터 빠른 속도로 수출 프로젝트를 . 방법 2와 마찬가지로 베어 Mercurial 저장소와 추가 베어 Git 저장소도 유지합니다.

    당기기 위해이 도구는 Mercurial 책갈피를 무시하고 대신 이름이 지정된 모든 Mercurial 분기를 Git 분기로 가져오고 기본 (이름이없는) Mercurial 분기를 마스터로 가져옵니다.

    일부 해설> 자식뿐 아니라 그것이 내가 설명해 년 12 2011 년 7 git-> HG 푸시 지원 합병했다고 주장 hg- 인 것으로이 도구에 대해 설명 이러한 도구의 검토 , 방법,하지만이 도구의 시도가 구현을 푸시 지원이 작동하지 않는 것 같습니다.

  4. git-remote-hg라는 또 다른 프로젝트 도 있습니다 . 위에 나열된 버전과 달리이 버전은 hg-git에 의존하지 않고 Mercurial Python API에 직접 액세스합니다. 현재이를 사용하려면 패치 버전의 git이 필요합니다. 아직 시도하지 않았습니다.

  5. 마지막으로 Tailor 는 다양한 VCS 사이를 점진적으로 변환하는 프로젝트입니다. 이것의 개발이 적극적으로 진행되지 않을 것 같습니다.

이러한 접근법 중 처음 세 가지 방법은 조사를 설득하기에 충분히 가벼워 보였다. 설정에서 실행할 수 있도록 몇 가지 방법으로 조정해야했으며, 개선하기 위해 조정하는 방법을 보았습니다. 그런 다음 평가를 위해 서로 더 유사하게 동작하도록 더 조정했습니다. 더 효과적으로. 그런 다음 다른 사람들도 동일한 평가를 수행하기 위해 이러한 조정을 원한다고 생각했습니다. 따라서 처음 세 가지 도구 중 하나를 내 버전으로 설치할 수 있는 소스 패키지만들었습니다 . 또한 필요한 hg-fast-export부품 을 설치해야 합니다. ( hg-git자체적 으로 설치해야합니다 .)

나는 당신이 그들을 시도하고 가장 잘 작동하는 것을 스스로 결정하도록 권장합니다. 이 도구가 깨지는 경우에 대해 기뻐할 것입니다. 나는 그것들을 업스트림 변경 사항과 동기화하고 업스트림 작성자가 내가 생각하는 유용한 조정을 인식하도록 노력할 것입니다.

위에서 언급했듯이 이러한 도구를 평가할 때 git-hg푸시가 아닌 Mercurial에서 가져 오기에만 사용할 수 있다는 결론에 도달했습니다 .

이와 관련하여 Git과 Mercurial 간의 유용한 비교 / 번역 매뉴얼은 다음과 같습니다. 일부 경우 이미 Git을 알고있는 사용자를 대상으로합니다.


기본 지원을 제공하는 새로운 git-remote-hg가 있습니다.

Mercurial 및 Bazaar를위한 Git의 브릿지 지원

git-remote-hg 를 $ PATH에 복사 하고 실행 가능하게 만드십시오. 그러면 종속성이 없습니다 (Mercurial 제외).

git clone hg::https://www.mercurial-scm.org/repo/hg/

마치 기본 Git 리포지토리 인 것처럼 밀어 넣을 수 있습니다.

새로운 Git 브랜치를 누르면 Mercurial 북마크가 생성됩니다.

자세한 정보는 git-remote-hg 위키 를 참조하십시오.


hg-git 을 사용할 수 있어야합니다 .

hg clone <hg repository>

편집 ~/.hgrc및 추가 :

[extensions]
hgext.bookmarks =
hggit =

mastergit에 책갈피를 만들려면 git :

cd <repository>
hg bookmark -r default master

.hg/hgrc저장소에서 편집 하고 추가하십시오.

[git]
intree = true

이제 git 저장소를 만들 수 있습니다 :

hg gexport

결과 디렉토리를 git clone으로 사용할 수 있습니다. 수은에서 당기는 것은 다음과 같습니다.

hg pull
hg gexport

and pushing to mercurial :

hg gimport
hg push

(Yes, you need to use hg with this workflow but your hacking will be all in git)

P.S. If you have a problem with this workflow, please file a bug.


You can try hg2git, which is python script and is part of fast-export, which you can find at http://repo.or.cz/w/fast-export.git .

You'll need to have mercurial installed though.


Since hg-git is a two-way bridge, it will also allow you to push changesets from Git to Mercurial.


Hg-Git Mercurial Plugin. Haven't tried it myself, but might be worth checking out.


I have had great success with git-hg from https://github.com/cosmin/git-hg (requires working install of hg, too). It supports fetch, pull and push and is more stable for me than hg-git (similar features from hg to git).

See https://github.com/cosmin/git-hg#usage for usage examples. The user interface is very similar to git-svn.

The git-hg requires extra disk space for each cloned hg repo. The implementation uses full mercurial clone, an extra git bare clone and the actual git repo. The required disk space is roughly 3 times the normal git only usage. The extra copies are stored below the .git directory of your working directory (or location pointed by GIT_DIR as usual).

Notice: The basic problem that git-hg tries to solve is that there is no 1:1 mapping between git and hg features. The biggest problem is the impedance mismatch between git branches and hg unnamed branches and hg named branches and hg bookmarks (all of those look a lot like branches to git users). A related problem is that hg tries to save original named branch name in the version history as opposed to git where the branch name is only added to template commit message by default.

Any tool that claims to create interoperable bridge between git and hg should explain how it's going to deal with this impedance match. You can then decide if the selected solution fits your needs.

The solution that git-hg uses is to discard all hg bookmarks and convert named branches to git branches. In addition it sets the git master branch to default unnamed hg branch.


Have tried hggit. Works for me, since I have to cope the work of git'ers and hg'ers. Especially for reviews this is great.

A minor issue/warning on that topic:

I have tried to clone a stable linux kernel repository with hg. These repositories are maintained in git and typically have a large number of files in it.

It was very slow. Took me 2 days to fully clone and update a working copy.


I have tried cosmin's git-hg and abourget's git-hg-again both on mutt's hg repo, it seems that the later respects the order of a merge well, the former is a bit random. You can see from the screenshots below.

A merge history graph of mutt imported by cosmin's git-hg:

enter image description here

A merge history graph of mutt imported by abourget's git-hg-again:

enter image description here

The actuall history graph plotted by hgk on mutt's hg repository:

enter image description here

As you can see from the above, the second graph by abourget's git-hg-again is very close to the original hgk graph and is actually reflecting the real workflow of the mutt.

One drawback of git-hg-again I found is that it does not add a 'hg' remote, rather imports all its refs as local tags, git-hg has a wonderful 'hg' remote represents the upstream hg repo.


Two-way hg-git (and git-git, hg-hg) sync is also possible with the service Git-hg Mirror. It uses hg-git (among others) behind the scenes and its code is also open source.


Disclaimer: I'm from the company behind it.

참고URL : https://stackoverflow.com/questions/883452/git-interoperability-with-a-mercurial-repository

반응형