Mercurial Is Getting Better for .NET Projects
Friday, March 5, 2010 at 9:33 Tweet Recently I've started using Mercurial (distributed version control system, an analogue of Git) more and more for working on various projects. This applies even if the project itself lives in the Subversion for collaboration.
Icon overlays have got more stable in the latest versions of Windows 7, Jungle Disk, TortoiseHg (shell extension for the Mercurial) and TortoiseSvn. The last two, share same overlays, as a matter of fact, along with showing much smarter overlay management. There is no need to mess with the registry (works on my machine).
So it is a real pleasure to work with Mercurial these days. This also allows to perform solution-wide refactorings and cleanups featured by the ReSharper 5.0.
Here's the snippet of the .hgignore file that I use:
# Mercurial .hgignore file template by Abdullin.com # For syntax see: http://linux.die.net/man/5/hgignore # Source: http://bitbucket.org/abdullin/snippets/ # Visual Studio glob:*.user glob:*.suo glob:*.cache glob:_ReSharper.*/ relre:/obj/ relre:/bin/ # Subversion glob:.svn/ glob:_svn/ # Build structure relre:^Build/ # Misc glob:Thumbs.db glob:*.bak glob:*.log
The snippet itself is saved (link to the latest version) on the bitbucket, although Google Code already supports Mercuarial as well.
In order to use the snippet, simply paste it into the ".hgignore" file in the root of the working copy. Chances are, the file has already been created for you by Mercurial.
And here's a bit of PowerShell code for wiping clean a SVN working copy, in order to merge latest branch with it:
ls -r -force |
where {!$_.Mode.StartsWith("d") } |
where {!$_.FullName.Contains(".svn")} |
del -force
Basically, the command wipes clean all files (you can put it in a single line), leaving an empty folder tree with the Subversion files. Then you can copy another solution export over it (i.e. export of a Mercurial branch) and simply accept the changes. That's how we've been syncing some folders in SVN repositories in one of the projects a few years ago.
Fortunately copying snapshot from the SVN to Mercurial is more simple than that: just wipe the all files, except for the single hg folder in the root; export contents of a Subversion solution over to this folder and commit changes.
Reader Comments (3)
Thank you. Could you link the snippet on bitbucket and tell how to add it to hg? :-)
Hi Lars,
Thanks, I've updated the article. In short:
Link: http://bitbucket.org/abdullin/snippets/src/tip/hgignore.txt
Usage: paste snippet into .hgignore file in the root folder of working copy.
Thanks for a great .hgignore file. Much cleaner than some of the others I've seen for Visuual Studio.
Cheers,
joakim