Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to export a version in Mercurial

📅 2011-Dec-06 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ archive, export, mercurial ⬩ 📚 Archive

Most of the work of transitioning from one version control system to another is figuring out the mapping from the jargon of the old one to the new. In Subversion, you could give someone a copy of a certain version using the export command. The copy thus created would be free of any repository information.

The corresponding operation in Mercurial is called archive. This creates an unversioned archive of a certain revision of the repository. Creating an archive of the current revision of your repository to give to a colleague named Harry is as easy as:

$ hg archive ../Copy-For-Harry

Another cool feature of the archive command is that it can create archives in compressed formats like zip. For example, to create a zip archive of the above:

$ hg archive Copy-For-Harry.zip

The hash of the revision being exported can be used in the name of the destination directory or file. For example:

$ hg archive Copy-For-Harry-%h.zip

The above command will create a file whose name might be Copy-For-Harry-72f497079285.zip, where 72f497079285 is the hash of the exported revision.

(Thanks to Rudi and Paul on StackOverflow for these tips.)

Tried with: Mercurial 1.9.2


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧