Production Code Deployment with Mercurial Version Control
I recently switched to Mercurial source control and it’s proving to be a lot more fun to work with than Subversion. However there is one SVN feature that I have been missing dearly: The ability to export deployment code. SVN has an export command that I would use to generate a copy of project source files free from all the source control utility folders.
Up until recently, I had not figured out how to do this in Mercurial. I had to manually remove the .hg folder in order to move project files to production. That was until I came across this gem. Mercurial has an Archive command. It essentially does the same thing as the SVN Export command. In order to archive in TortoiseHg (Windows):
- Right-click the source code project folder and select Hg Repository Explorer.
- In the Repository Explorer, right-click on the default (tip) revision point and select Archive.
- On the Archive dialog:
- Select the Archive revision you want to export
- Supply the destination path
- Pick Directory of files as the Archive type.
- Click Archive.
You now have a copy of your source files that does not contain source control infrastructure.