Mercurial tool to export changed files

Tuesday, April 27th, 2010

Recently, my friend Chris Brown convinced me to move my source control from SVN to Mercurial (or more specifically, Kiln).
I found Mercurial to be infinitely better than SVN in almost all resepects, but there was one thing missing that I could do with Tortoise SVN but not Tortoise HG, and that was to export any changed files from one revision to the next – something which as a web developer, I have to do very often.

Well, Chris came to the rescue and created a simple program to do exactly that. So here’s Chris to explain the program and how it works:
Download links are at the bottom of the page.

Hi,

My name is Chris Brown and I am a big fan of FogBugz so when FogCreek announced Kiln (a mercurial client) I immediately jumped on the bandwagon moved to Kiln and have never looked back. The Kiln Mercurial solution solved all the issues I had with merging and speed in Subversion and I was a very happy man indeed.

Then one day whilst chatting to my good friend Gary @ Simian Enterprises (who has kindly let me blog via his site on this occasion) I mentioned Kiln to him and proceeded to wax lyrical about how great it was until his ears were bleeding and to my surprise I had convinced him to give Kiln a try.

Now Gary was at first very happy and was as thrilled as me at the beautiful Kiln web experience and TortoiseHg integration, however there was one nagging feature he used a lot in Subversion which does not exist within the Mercurial system, and after doing a bit of googling it seems a few other people hit the same snag.

It is not possible with TortoiseHg to export a copy of all files changed since a specified revision. Now to most this would not cause much of an issue, I myself have never had this need, and do not think I will, but for those working on big complex websites like Gary does this is a big issue.

When uploading the new version of a site (usually by FTP) this can take some time, and I am sure most people will agree that uploading files with no changes is nothing but a waste of time. Being able to export just the files changed since the last update and only updating these makes a lot more sense and will result in far fewer files being transferred and as mentioned TortoiseSVN has this capability as standard.

With any luck one day the TortoiseHg system can also have this command, until then I have written a small application in Visual Studio 2010 which does what Gary needed and hopefully it will be of use to other Kiln/Mercurial users too.

Mercurial Changed Files Exporter

Please note: this is one of those programs I knocked up very quickly, it does not have much error handling and the code is not that tidy, however it does work and I have provided both an installer for the app and the original Source Code, please feel free to amend as needed or build on this to meet your needs.

Below are details of each input and what it is used for and what the buttons do, this currently checks for changes between a revision and tip and assumes the current working folder is updated to Tip.

Root Directory of mercurial repository: should point to the path of the root of your repo (where .hg lives)
From Revision #: the revision number to check from
Export target folder: the folder to copy changed files to (must be blank)
List Changed Files: lists the files in the list box that will be copied based on current settings.
Export Changed Files: same as above but also copied to the target folder/
Close: does what it says on the tin.

If you like this little utiity and would like to make any comments you can find me on Twitter (@CB46)
Thanks
Chris Brown

Download: Windows Installer | Source

Filed under: General, Source Control, Website Development.

5 Comments

  1. Joe

    Nov 15th, 2010
    7:16 pm

    I have tried installing this on two separate computers with Win XP SP3. Neither computer wil list any changes from repository. I’ve tried entering any number from my repos, but the List/Export button both prompt “No changes found”.

  2. Gary

    Nov 15th, 2010
    7:26 pm

    I’ve passed your comment onto Chris to see if he has any suggestions – it’s working fine for me though. Might be worth double checking that you’ve got the path to the repository correct.

  3. Chris Brown

    Nov 15th, 2010
    8:50 pm

    Hey,

    Sorry but don’t know of any reason why it would not work. Unfortunately I wrote this a long time ago in a hurry for Gary and without a way to recreate what your getting i’m not gonna get very far in fixing it.

    Garys idea about the path format seems sensible, however I would be surprised if anyone who uses Mercurial would make that mistake.

    Your best bet is probably to take a look at the (rather messy) source code ,Net Express should load it fine from what I remember of it.

    Best of luck!
    CB

  4. Albert

    Dec 1st, 2010
    7:57 am

    Some self-promotion: I’ve written a small Mercurial extension that does exactly the same as this tool. It takes a revision or a revision range and exports all files that were changed in this revision (range).

    Have a look at https://bitbucket.org/albert_brand/hgexportfiles/wiki

  5. Gary

    Feb 12th, 2011
    5:17 pm

    @Joe
    I recently updated my version of Kiln Tools, which included a new version of TortoiseHG. Since doing so, I’m experiencing the same problem with no files being listed.
    It seems that the syntax for logging changed files may have changed.
    I’ve asked Chris to take a look at this issue. When he manages to update the software I’ll post an update here.

    @Albert
    Thanks for posting that, the extension looks great. Personally I prefer to have a GUI to work with on this and don’t use the HG command much, but it’s good to have this functionality fully integrated into HG. Cheers.

About

Simian Enterprises is the trading name of Gary Stanton, a freelance web developer working by the sea in Brighton, UK. Gary's been creating websites since 1996 and still loves it. Read more

Contact

Gary Stanton

Email:

Tel:
01273 775522

Twitter

No public Twitter messages.

Delicious Feed

Website Design & Development