从SVN到Mercurial的迁移(英)

小卒过河 发布于 2011/05/13 23:33
阅读 1K+
收藏 2

When I start at my company, their system uses a very old SVN system. It’s slow, it can’t even branch properly and give me conflicts all the time. So the very first thing is to migrate it to a new version control system. I wrote a tutorial about starting with Git before, so I’m quite tempting to use Git, but in the end I decide to go for Mercurial. This article will show you how to move your existing projects in SVN to a mercurial repository.

Prepare the system for Mercurial

If you used SVN, you maybe used to TortoiseSVN. Mercurial has a similar software for it called Open new tab TortoiseHG, you can Open new tab download the latest version from here. The interface and the overlay icon is look about the same as the tortoiseSVN so SVN user won’t feel so much different.
Open new tab TortoiseHG History

You will need to set TortoiseHg in both your server and you client.

Move the codebase from SVN to Mercurial without keeping changesets

As our version control server is in an internal networks and got access only by developers, I don’t bother to set up the whole mercurial server up. This article will show you how to move your existing projects in SVN to a mercurial repository.

In server:
I create a folder for the repository in the version control server. Make sure it shared and all the developers’ve got full permission.
Right click on that folder, Sharing & Security, select Share this Folder.
Go to Security, select a group or the user, check Full Control permission.

Permission Screen

Permission Screen


Go into the folder, right click > TortoiseHg > Create Repository Here.

In Client:
Right click on the folder you want to store the code. Choose TortoiseHg > Clone…

Clone screen

Clone screen


Enter the Path to the repository folder in the Source and click Clone.
Now you linked your client folder with the repository.
Copy the code over.
Do the first comit then Push to the server.
Done and done.

Move the code base from SVN to Mercurial and keeping history changesets

If you want to keep all the history in the SVN and move them to Mercurial, you can, quite easily.

In Server:
Enable convert extentions
Right click in a folder. Choose TortoiseHg > Global Settings.
Go to Extensions
Check convert

Global settings screen

Global settings screen

Create a new folder for repository and check the permission as above.

Convert the SVN repository to Mercurial repository
Go to Cmd
%ProgramFiles%\TortoiseHg\hg convert “[Source repository]” “[New mercurial repository folder]”
Then it will convert the SVN repository to mercurial with all the history

In Client:
Clone from the repository, Pull the changeset back and you will get all the code files

Notices

Username in mercurial
If you haven’t set your username for Mercurial yet, you may want to do so. If not it will comit under your domain name.
Right click in a folder. Choose TortoiseHg > Global Settings.
Go into Commit, change the Username to whatever you like.

Push after commit
if you’re used to work with SVN and 2 actions commit and push aren’t your cup of tea.
You can go into a repository, go to Repository Settings (like above)
Go into Commit, change Push After Commit to true.

Update after pull
The same as push, you can change the action after pull
Go into Repository Settings
Go into Workbench and change After Pull Operation to Update

加载中
0
IBMdW
IBMdW

最近很少有人再提 Mercurial ,倒是 Git 提了很多。

0
特劳特
特劳特

不错,个人感觉在window下面hg的很多功能已经对window的支持性都大于git,尤其是eclipse的插件就很强大

返回顶部
顶部