TortoiseHg – How to export changed files

TortoiseHg is excellent linux client for Mercurial Hg distributed source control management tool (SCM). It has excellent performance on mainstream filesystems (i.e linux EXT4), extensibility, and heap of features and settings.

The only thing I truly missed was the ability to export changed files between two arbitrary commits. Not patches, but whole files. This feature was only supported by SVN and I found it irreplacible while working on many projects.

Luckily, it is pretty easy to add this feature to a TortoiseHg client via extension – here’s how.

1. Download python script called “exportfiles.py”
Grab latest version from https://bitbucket.org/albert_brand/hgexportfiles.

2. Place script “exportfiles.py” somewhere on your computer
this my case, I will place the script into directory “/home/zaien/Master/exportfiles.py” (this path my different with your own).

3. Install the script as TortoiseHg extension in global settings
If you only want to use this script in a particular repository, you need to edit settings only for that particular repository. I assume that most likely you want to use this feature for all repositories, therefore we add the extension into global settings.

Open a repository using TortoiseHg, any repository of your choice. right click on opened repository, select Settings.

Open Global settings and click “Edit file”. Add following line to section [extensions]:

[extensions]
exportfiles = c:\Program Files\TortoiseHg\extensions\exportfiles.py

If the section [extensions] does not exist, just create it. You may also name “exportfiles” anything you like, just keep in mind that this will be the hg command to execute the extension (see further).

Click “Save” and close client window. Then open again – and now it should be compiled in source directory and installed on the “Extensions” tab.

4. Execute export of changed files into single directory
Now you can use command line commands to export any changeset.

hg exportfiles -r 10 ./export
-- will export files changed in revision 10 into directory "./export"

hg exportfiles -r 10:20 ./export
-- will export changed files from revision 10 up to revision 20

hg exportfiles -r 10:tip ./export
-- will export all changed files from revision 10 up to latest commit (tip)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s