Thursday, October 1, 2009

Using Mercurial with TFS – Read Only files

After having used mercurial on a project, going back to TFS was slightly depressing. However I did stumble upon this post which shows how you can use mercurial to fill in some of the TFS gaps around working offline.

If you working on a particularly large piece and don’t want to go through the pain of a TFS branch, being able to commit to a local repository frequently and take advantage of mercurials merge algorithms when committing to older revisions is incredibly useful – anyway I digress.

The post outlined above seems to have omitted the way TFS tracks changes against files using the read-only file system flag. So when you attempt to update you ‘tracking’ workspace with a bunch of new changes mercurial will be unable to update the read-only files.

If you attempt to make all the project files writable, TFS will pick up changes against files even when they have no differences with the workspace version.

Luckily there is a handy mercurial extension called MakeWritableExtension which will make read-only files writable if it tries to make changes to them.

http://mercurial.selenic.com/wiki/MakewritableExtension

If like me your using TortoiseHg, either update the Mercurial.ini in the TortoiseHg folder or in your local user folder. I added the following lines to C:\Program Files\TortoiseHg\Mercurial.ini

[extensions]
makewritable = C:/makewritable.py

And then copied the python file in the link above in my C drive (because I’m lazy). Whenever mercurial tries to update a read-only file you will get:

image 

Now it will automatically set the edited files to writable thus doing a TFS checkout and making life a *lot* easier.

1 comment:

  1. nym nym nym nym nym nym nym nym nym nym nym nym nym nym nym nym ................... so this is what you've been doing with yourself.....hehehe

    ReplyDelete