Programming

Windows에서 SVN을 Mercurial (HG)로 마이그레이션 / 변환하는 방법

procodes 2020. 7. 14. 21:40
반응형

Windows에서 SVN을 Mercurial (HG)로 마이그레이션 / 변환하는 방법


히스토리, 레이블 등을 사용하여 두 개의 SVN 저장소를 Mercurial로 마이그레이션하는 도구를 찾고 있습니다.

TortoiseHg (Windows x32)를 사용하고 있으므로 ConvertExtensions가 삭제됩니다. Linux 상자 ( hgsvn ) 에서이 프로세스를 수행하는 방법에 대한 정보가 있지만 Linux 시스템을 사용할 수 없습니다.

Windows에서 해당 Python 스크립트를 사용할 수 있습니까? 그렇다면 어떻게해야합니까? 또는이 프로세스를 수행하기 위해 사용할 수있는 다른 도구는 무엇입니까?

기본적으로 SVN 프로젝트를 Mercurial로 변환하려면 어떻게해야합니까?


나는이 문제를 스스로 해결해야했습니다. VisualSVN Server를 호스팅하는 별도의 Windows 서버가있는 Windows XP 컴퓨터가 있습니다.

또한이 TortoiseHG가 뿐만 아니라 설치 콜 랩넷 서브 버전 명령 줄 클라이언트 .

<Enable Convert Extension w/ Tortoise Hg 2>

TortoiseHg 2.0을 사용하여 변환 확장을 활성화하는 것이 그 어느 때보 다 쉬워 졌다는 의견을 지적한 bgever 에게 감사드립니다 . 그가 말한대로

TortoiseHG 2.0을 사용하면 훨씬 간단 해집니다. 시작 메뉴에서 TortoiseHG Workbench를 시작하십시오. 파일-> 설정을 선택하십시오. 목록에서 확장을 선택하십시오. '변환'체크 박스를 체크하고 확인을 클릭하십시오. 그게 다야! 더 이상 구성 파일을 생성하여 파일 시스템에서 검색 할 필요가 없습니다. – bgever 3 월 11 일 7:56

</Enable Convert Extension w/ Tortoise Hg 2>

<Enable Convert Extension Manually>

저장소를 SVN에서 HG로 변환하기 위해 다음 단계를 수행했습니다.

1) C : \ Program Files \ TortoiseHg \ Mercurial.ini를 엽니 다.

편집하다

참고-Tortoise Hg가이 파일을 다음으로 마이그레이션했습니다.

  • XP 이상-C : \ Documents and Settings \ USERNAME \ Mercurial.ini
  • Vista 이상-C : \ Users \ USERNAME \ Mercurial.ini

해당 파일은 대부분 비어 있으며 재정의하려는 항목 만 나열하면됩니다. 이것이 당신이 가진 것이라면, 파일의 맨 끝에 다음 두 줄을 추가하십시오.

[extensions]
convert =

2)로 시작하는 줄을 검색

[확장명]

3) 아래에 각 줄에 세미콜론 (;)으로 주석이 달린 키워드 목록이 표시됩니다

4) 줄을 찾으십시오

; 변환 =

세미콜론을 삭제하여 읽습니다.

변환 =

</Enable Convert Extension Manually>

5) 명령 프롬프트를 열고 새 hg 폴더를 만들 디렉토리로 이동합니다 (프로세스는 명령 프롬프트가 열려있는 디렉토리에 yoursvnreponame-hg라는 새 폴더를 만듭니다).

6)이 명령을 사용하십시오

HG 파일 변환 : /// y : / yoursvnreponame

변환 도구에 네트워크 리포지토리에 문제가있을 수 있으므로 드라이브를 매핑해야했지만 나에게 잘 작동했습니다.


  1. localhost에서 시작 SVN 서버
  2. HG 변환 svn : // localhost / your_repo
  3. svn 바인딩은 file : // 프로토콜에만 필요했기 때문에 완료되었습니다.

Mercurial 은이를위한 변환 확장 기능을 내장하고 있습니다.


SVN Repo를 HG Repo로 변환하고 다른 서버로 복사하려면 몇 가지가 필요합니다.

  1. TortoiseHG가 설치되었습니다. (현재 사용중인 버전을 확인하십시오)
  2. 파이썬이 설치되었습니다. (현재 사용중인 버전을 확인하십시오)
  3. 파이썬 모듈 ( http://pysvn.tigris.org/project_downloads.html에서 찾을 수 있습니다 )
  4. convertTortoise에 확장을 추가해야합니다 . 시작 메뉴에서 TortoiseHG Workbench를 시작하십시오. 를 선택하십시오 File -> Settings. Extensions목록에서 선택하십시오 . 체크 convert체크 박스를하고 확인을 클릭합니다.

먼저 변환…

  1. 현재 SVN Repo가있는 폴더를 작업중인 컴퓨터에 매핑하는 것이 가장 좋습니다. (예 \\server\folder: SVN Repo 폴더 자체를 매핑하지 마십시오. 바로 위에 폴더를 매핑하십시오) 매핑 된 드라이브에 다음과 같은 문자를 지정하십시오.Y:\
  2. 명령 프롬프트를 열고 다음을 입력하십시오. CD /D Y:\
  3. 상기 Y:\프롬프트 : hg convert y:/RepoName앞으로 및 뒤로 슬래시의주의 (현재 리포의 이름을 사용). 명령에서 하나는 슬래시입니다. 또한 이름에 공백이 있으면 이름을 따옴표로 묶으십시오. (즉 Y:/"My Repo folder")
  4. Now it should be running and will create another folder alongside the old one. And an hg folder should be inside. IT WILL NOT BE INITIATED, AND DO NOT INITIATE!
  5. The conversion is complete.

Second the cloning…

  1. Open TortoiseHG Workbench. Go to File -> Clone Repository
  2. Source: Enter the full path of the converted repo.
  3. Destination: Enter the full path of where you want the repo cloned. It is not necessary to create a folder at the new destination as the cloning process will create it and initialize it.
  4. Add the permissions to the new cloned folder.
  5. You’re done!!!

Nobody still does not mention hgsubversion (Extension Wiki), which can do it without almost any headache (excluding rare cases and specific tree).

Just add extension, enable it and hg clone SVN_REPO to local mercurial repo


This is in the TortoiseHg FAQ:

How can I convert a subversion repository to Mercurial?

You must install svn-win32-1.4.6 command line tools, then add them to your path. Then you must enable the convert extension. At this point, you should be able to use the 'hg convert' command to do the conversion. Please direct problems/questions about the convert extension to the Mercurial mailing list or #mercurial on irc.freenode.net.

So it is apparently possible -- I'm using Linux so I haven't tried myself.


I just converted a remote SVN repo with HTTP auth to a Mercurial repo, and let me tell you, there's not a lot of documentation on how to do this. I had to download the Mercurial source and install it stand-alone, using the source package, that way the SVN bindings will work the right way.

I installed it like:

python setup.py install

Which worked just fine on my Server 2003 box. I can now convert an SVN repo the correct way, by doing something like this:

python c:\python26\scripts\hg convert <remote repo>

The documentation for ConvertExtension on the Mercurial site isn't terribly clear, but it does say this:

There's no way to install the Subversion bindings into [Mercurial's] built-in Python library. So you'll need to use a Mercurial installed on top of a stand-alone Python

So now I just use the stand-alone version for converting, and TortoiseHg for actual VCS work.


better late than never ...

Two answers for the price of one ...

  1. If it is a public, open-source repo you could just use http://svn2github.com/add/ which took about half an hour to clone that repo to GitHib and then just pull that into Hg.

  2. The advantage of using hg convert is that is can be resumed. Converting SVN to Hg can take days. If you stop this it will resume from where it left off.

Below is a batch file I wrote because Codeplex SVNbridge rubbish. The repo in this example did take a couple of days to fetch the whole history (I'm in Australia so the latency may have been a factor). I'd like to think it gave a TFS server somewhere a good beating.

This batch file can be run at any time to pull updates from the SVN source if they happen to be the only ones left on earth actually still using SVN. I haven't tested it so see what happens if you do this so if I were you I'd abandon the original branch if you're going to edit the repo.

The robocopy shamap stuff is to maintain the SVN history if you clone the Hg repo, shamap is ephemeral - check the batch file & shamap in (I'd do that on a new branch).

the batch...

@echo off
mode con:cols=100 lines=800

:: Change the SVN remote name here
::
set remote=https://cinch.svn.codeplex.com/svn
::

title Fetching SVN from %remote%. This could take...DAYS
echo .
echo Fetching SVN checkins from %remote%
echo .
echo Dependencies: Tortoise Hg and hg.exe in the Path would be ideal.
echo using hg convert
echo .
echo First, I will make a backup of shamap in the hg repo folder.
echo If shamap in .hg\ is newer then it will be copied to the repo.
echo You should commit it so hg clones of this repo work with this.
echo Commit this .BeeyATch file as well.
echo shamap keeps track of what has been fetched from SVN.
echo ok, that ends the educational part of this script...
echo Now I will fetch SVN changes from
echo %remote%
echo ...
echo ...(this could take quite some time)...
echo ...DAYS...yes...DAYS
echo ...especially if it's fecking Codeplex SVN...
echo .
echo If this craps out just run it again - it will resume from where it left off. 
echo and fetch the rest...eventually
echo .
echo Control C to abort or any other key to start:
echo .

pause

echo .
:: http://mercurial.selenic.com/wiki/ConvertExtension <== see for details of shamap
:: copy the shamap from the original convert into the .hg folder unless it is already there & newer
:: don't panic if shamap is much bigger than the original - diff it to see why
robocopy .\ .\.hg\ shamap /XO 
robocopy .\.hg\ .\ shamap /XO 
echo .

hg convert --verbose --debug %remote% "%CD%"
echo .
echo .
echo Finished fetching from %remote%
title Finished fetching from %remote%
echo Any  key to Exit
echo .
pause

exit

Using the convert extension of Mercurial:

  1. Enable convert extention; add convert= to the [extensions] section of .hgrc like this:

    [extensions]
    convert=

  2. Linux needs additional python bindings: sudo apt-get install python-subversion
  3. Execute hg convert command
    • See hg convert -h for help
    • Example: hg convert http://[svnserver]/[Project] --source-type svn [DestinationDir] (see note 2)
  4. Push to newly created Mercurial repository: hg push https://[mercurialserver]/[Project]

note: you can even repeat the hg convert command to include new changes made in the svn repository after the previous convert.

note 2: When hg convert doesn't work using http:// or svn:// you could first checkout the Subversion repository (or update an existing one) and convert using the local checkout; example: hg convert [DirectoryOfLocalCheckout] --source-type svn [DestinationDir]

참고URL : https://stackoverflow.com/questions/850213/how-to-migrate-convert-from-svn-to-mercurial-hg-on-windows

반응형