Mercurial and hosting it as an ISAPI module under IIS6

by DJMatty2. May 2010 03:07

After reading a bit more about Mercurial as a distributed source code control system, and discovering that it will co-exist with git I decided to try it out, so I could see which I prefer. The jury is still out at the moment, but I also decided to install mercurial on my windows home server so I could try hosting repos centrally. Here's the process I went through to get it set up, it took a bit of messing about to get working in IIS6 with ISAPI, mainly due to there not being many resources on the net for setting it up with ISAPI under IIS6.

First thing is to follow this great post by Matt Hawley, it has the links and instructions to set up all the required packages, python, pywin32, mercurial, and isapi-wsgi. Follow that post up to the config part.

Now my setup differs from Matts, he creates a new website to host mercurial and starts it on port 81, I wanted to use port 80/443 and have it play nicely with the rest of the WHS standard web sites, but I didn't want to have to configure host headers, and wildcard certs, etc. I discovered that using host headers were a problem too, apparently they mess up the existing software in my HP WHS, so I decided to go with a virtual directory under the main web page.

When modifying the 'hgwebdir_wsgi.py' file to set your hgweb_config path, I also set the path_strip and path_prefix to 1 rather than 0. It doesn't seem to work if you only set path_prefix to 1.

 

 

Follow Matt's instructions for generating the DLL shim called _hgwebdir_wsgi.dll.

I created a shared folder in WHS to contain the repos (because you can't access the drives directly that are used in the drive set), so set that path in hgweb.config file:

[paths]
/ = \\server\repos\*

In IIS Manager create a new app pool called Mercurial, then create a new virtual directory pointing to the folder you created in Matt's post step 1. (mine was c:\inetpub\hg, but it could be anywhere you like)

If you do use a network share for your repos, you will need to change the identity that the app pool uses to a user that has permissions to access that folder, or give access permissions to Network Service. If you change the identity to a local user, follow the instructions in this post for assigning the correct groups and rights to the user, otherwise you might just get a 'Service Unavailable' message when you browse to the page.

 

 

Click the configuration button to configure the application.

 

Click Insert in the Wildcard Application Maps and select the _hgwebdir_wsgi.dll file. Important! Ensure you uncheck the 'Verify that file exists' checkbox, otherwise you will get 404 errors when you try to browse the site.

 

 

In the directory security tab click the Edit button on the Authentication and Access Control and disable anonymous access, also enable basic authentication and disable integrated windows authentication. This is needed for mercurial authentication, but credentials are transmitted in plain text so shouldn't be used on the public internet without ssl.

 

 

To enable ssl, assuming your site already has a certificate etc, just click edit on the secure communications, and check the require secure channel checkbox.

 

Now you should be able to browse to https://yoursite/hg and see the repository summary page.

 

Tags:

More Git

by Administrator26. February 2010 12:49

Been using Git for a while now and getting to like it. Found out some more info about some of the commands.

The commands I gave previously for adding p4merge as the merge tool didn't do quite what I was expecting, and didn't actually work :)

After expecting git to use this merge tool whenever merges were needed it doesn't, you have to run it when auto merge fails using this command (discovered from this SO question):

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git mergetool[/sourcecode]

This will then go through each file with conflicts and run p4merge on them. Except that each time it tried to run p4merge it failed, so I guess the command was setup incorrectly.

I took a look at the .gitconfig file in my user folder and noticed that each of the file parameters to the p4merge.exe had got lots of slashes:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"][user]

name = Mike Hunt

email = someone@somewhere.com

[core]

editor = notepad.exe

[merge]

tool = p4merge

[mergetool "p4merge"]

cmd = p4merge.exe \\\"$BASE\\\" \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$MERGED\\\"[/sourcecode]

So I changed it to this:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]

[user]

name = Mike Hunt

email = someone@somewhere.com

[core]

editor = notepad.exe

[merge]

tool = p4merge

[mergetool "p4merge"]

cmd = p4merge.exe "$BASE" "$LOCAL" "$REMOTE" "$MERGED"

[diff]

tool = p4merge

[difftool "p4merge"]

cmd = p4merge.exe "$LOCAL" "$REMOTE"

[/sourcecode]

And now it runs p4merge for the merges and shows the files properly, and also note the entry for the diff tool, so it uses that for diffs as well, using the command:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git difftool[/sourcecode]

Other things that had me scratching my head for a while were:

1) If I delete a folder from the working set I couldn't stage the delete (or commit it), which I discovered was due to me not using:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git add -u .[/sourcecode]

or

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git add -A .[/sourcecode]

-u (or --update) stages files based on what is in the index rather than the working set, so it won't add new files, but will update newly updated files that are already staged, and it will also remove files that were staged but have been removed from the working set.

-A (or --all) will do as -u but will also stage new files as well (lesson learned, "use git add -A ." from now on!) More details here

2) "git pull" performs a "git fetch" then a "git merge". The fetch fetches the remote branch to a local tracking branch based on the remote and branch you fetched, e.g. "git fetch unfuddle master" fetches the master branch from the unfuddle remote to a tracking branch locally called 'unfuddle/master'. The merge then merges that tracking branch to the local branch. e.g. if you are in the local branch "git merge unfuddle/master" will merge the changes.

3) If you mess up and want to reset your working files to the last commit:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git reset --hard HEAD[/sourcecode]

4) If you only want to reset individual files:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git checkout -- hello.cs[/sourcecode]

will reset the local working file hello.cs to the staged version

or

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git checkout HEAD hello.cs[/sourcecode]

will reset the local working file to the HEAD version (last local commit)

Here are some handy links that I have come across for finding this info:

http://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-visual-diff-program

http://gitguru.com/2009/02/22/integrating-git-with-a-visual-merge-tool/

http://stackoverflow.com/questions/866262/p4merge-error

http://www.andymcintosh.com/?p=33

http://www.gitready.com/advanced/2009/02/11/pull-with-rebase.html

Tags:

Git :)

by Administrator16. February 2010 11:47

With the weather being a bit rubbish the past few weekends I have been geeking out (in addition to playing Uncharted 1 & 2) and been learning wpf, mvvm pattern and I decided to start using an open source source code control system. After some deliberation I picked Git (I did look at subversion and mercurial), it seems to have gained popularity and I wanted to see what all the fuss was about and if it was written and used by Linus for the linux kernel then it should be good enough for me :)

After some investigation I found msysgit which is basically git on windows. It effectively installs a bash shell on your windows box with all the git commands. I also decided to use Unfuddle as an online store of my source code. Here are the steps I took to get setup, mainly so that I can find them again if I need to do this later…

Installing msysgit was pretty straight forward, I accepted the defaults and it installed just fine. (This was after discovering the right package to download, as that is not immediately obvious, but it’s here, the git package, rather than the msysgit package)

Setting up git to work with unfuddle and setting up ssh keys etc was the next step, and also setting up the repo to work with Visual Studio, which is basically setting up a .gitignore file to tell git not to include certain files and filetypes in the source code control

Once git is up and running you should then set up some global config, an ssh-key can be created using the following:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]ssh-keygen –C “your@email.com” –t rsa[/sourcecode]

This will create the key in a folder called .ssh in your user folder. You then use this key to add to unfuddle (or github or wherever) so that you can be authorised against the remote repo.

Then set your username and email:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git config -–global user.name “Your Name”

git config –-global user.email "Your@Email.com”[/sourcecode]

In your user folder there should be a .profile file, if there isn’t then you can use

[sourcecode language="bash" gutter="false" 1="tab-size="4"" toolbar="true"]touch .profile [/sourcecode]

which will create a file without a filename and only an extension (you can't do this in explorer) Then add this to it, which starts up the SSH Agent when bash is run, so that you only have to enter the ssh key password once.

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]SSH_ENV=$HOME/.ssh/environment

function start_agent {

echo "Initialising new SSH agent...";

/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"

echo succeeded

chmod 600 "${SSH_ENV}"

. "${SSH_ENV}" > /dev/null

/usr/bin/ssh-add;

}

# Source SSH settings, if applicable

if [ -f "${SSH_ENV}" ]; then

. ${SSH_ENV} > /dev/null

#ps ${SSH_AGENT_PID} doesn't work under cywgin

ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {

start_agent;

}

else

start_agent;

fi

[/sourcecode]

This question on SO tells you how to change git’s default editor, I changed it from vi to notepad. (I use notepad2, but it’s installed to take over from notepad, so opening notepad.exe opens notepad2)

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git config –-global core.editor “notepad.exe”[/sourcecode]

This question on SO tells you how to change the default merge tool to p4merge, which is my merge tool of choice:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git config --global merge.tool p4merge

git config --global mergetool.p4merge.cmd ‘p4merge.exe \”$BASE\” \”$LOCAL\” \”$REMOTE\” \”$MERGED\”’[/sourcecode]

Then that should be the environment set up, after that its just a case of either creating a new repo or cloning one from unfuddle.

This page has the basic info on how to do it:

1) If you are starting a new repo, create it in unfuddle, then create a folder locally for it then:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git init[/sourcecode]

1b) you might also want to create a .gitignore file in the repo folder, so that you can tell git to only commit your source code, mine looks like this (you can tell where I ‘borrowed’ it from):

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]# .gitignore for .NET projects

# Thanks to Derick Bailey

# http://www.lostechies.com/blogs/derickbailey/archive/2009/05/18/a-net-c-developer-s-gitignore-file.aspx

# Additional Thanks to

# - Alexey Abramov

# Standard VS.NET and ReSharper Foo

obj

bin

*.csproj.user

*ReSharper*

*resharper*

*.suo

*.cache

*Thumbs.db

*.scc

# Other useful stuff

*.bak

*.cache

*.log

*.swp

*.user

_compareTemp

_notes

aspnet_client

httpd.parse.errors

# Office Temp Files

~$*

# If you have a deploy folder

deploy

deploy/*

# Exclude ALL DLLs?

#*.dll[/sourcecode]

2) Associate the repo with the unfuddle remote repo:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git remote add unfuddle git@subdomain.unfuddle.com:subdomain/abbreviation.git

git config remote.unfuddle.push refs/heads/master:refs/heads/master[/sourcecode]

2a) If you already have code in the repo you can clone it

3) Finally, write some code, and when you are happy and want to commit the changes to your local repo:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git add *

git commit[/sourcecode]

4) Then push the changes to the remote unfuddle repo:

[sourcecode language="bash" gutter="false" firstline="1" toolbar="true"]git push unfuddle master[/sourcecode]

Tags:

Fishing

by Administrator14. December 2009 06:41

Just spent the morning rock fishing at Whale Beach, and this time we actually caught something! It's a beautiful day, blue skies, blue seas, and almost no-one there so we got to pick our spot.









Tags:

The sun is a good cure for a hangover

by Administrator1. November 2009 07:35

Well, we decided to head out for beers and pool last night, so after some dinner at James Squires I introduced Dave to the delights of the Shark Hotel. It has supposedly been refurbished, but looked pretty much the same to me, although they have taken up some of the space for more chairs and tables, and squashed the pool tables together a bit. Still, it didn't affect my game, as I lost most of them to Dave, who seems to be getting the hang of these funny upside down tables now. Needless to say, a lot of boags, strongbow, and g&t's were quaffed, hence my "special" feeling this morning.

Dave pursuaded me to go with him to sit in the sun on the grass at the botanical gardens and I'm sat here on the grass typing this. Not a bad idea Dave! I've attached some pictures of Dave enjoying himself, mind you it's only about the 3rd day or so of sun that we have had since he got here, so he's been enjoying the decidedly English-like weather up until yesterday!

Oh and happy Halloween too!







Tags:

We've all arrived in Filey

by Administrator17. October 2009 18:23

We're all settled in, it's a little bit windy and a bit pearl harbour, I doubt I'll be going for a dip in the sea, I'll wait till I get home to Sydney for that

Tags:

I am really using my iPhone for stuff these days

by Administrator2. October 2009 14:05

I'm surprised at how much I am using my iPhone nowadays, and what for.

I've managed to steer clear of eBooks for a long time, being a firm believer of having a nice chunk of mashed up tree in my hand is part of getting into a good book. However, I have recently installed iPhone app Stanza and downloaded a couple of eBooks. Partly because books are really expensive over here, and partly because I didn’t want to lug a book around with me on my way to work.

I have to say that I have got into reading on my iPhone, I’ve bought a copy of the book I am reading at the moment, Day Watch by Sergey Lukyanenko and just carried on reading from where I had already got to in the paper book. I had thought before I gave it a try that the iPhone would be too small to read on, but using it I don’t think that’s the case. The app remembers where you got to in each book, it has online catalogues that you can browse to either purchase books and download them there and then in the app or safari, or just download from the many free catalogues too, like project gutenberg.

Since I was on a roll with eBooks, I thought I’d give video a go, to make the journey to and from work pass quickly. After some research (well, googling, still not that impressed with bing) I discovered an opensource project called Handbrake which is a video transcoding app. It has a default setting for iPhone, and I just ran some tv shows through it and hey presto, 200mb m4v files of each episode, no matter what format I threw at it, xvid in avi, or h264 in mkv, it sorted them all out.

Most impressed, a quick iTunes sync with the iPhone and the next morning I was watching TV on the way to work, great quality, really watchable even on the screen size that it is (I think handbrake crops the video as well as shrinking it so you may lose some of the edges of the frames, but it doesn’t make everything really tiny).

The only thing I have to be careful of now is missing my stop on the train cos I am too busy watching tv :)

Tags:

Sydney moved to Mars

by Administrator25. September 2009 16:07

Woke up yesterday morning after it being really windy all night, to the deep orange glow of a very dusty Sydney. Very eerie it was, sorta like you'd think a dust storm on Mars would be :)

Took a couple of shots with my iPhone camera:

[caption id="" align="aligncenter" width="425" caption="Dusty Sydney"][/caption]

[caption id="" align="aligncenter" width="425" caption="Dusty Sydney in my apartment"]Dusty Sydney in my apartment[/caption]

It had mostly gone by lunch time and things were back to normal

Tags:

Some general Winforms coding info

by Administrator25. September 2009 02:01

The difference between Control.Invalidate, Control.Update and Control.Refresh:

Control.Invalidate()

Adds a region or a control to the update region of a window

Control.Update()

Sends WM_PAINT to the window if the windows update region is not empty (sends directly to wndproc bypassing the apps message queue)

Control.Refresh()

Calls invalidate and then update

String format alignment enums

The names of LineAlignment and Alignment (plus the descriptions in their tooltips) are confusing and I keep forgetting which one is which.

StringFormat.LineAlignment

Text alignment vertically

StringFormat.Alignment

Text alignment horizontally

Scrollbars

The scroll value automatically takes into account not scrolling the amount at the end of the range given by LargeChange. According to reflector:

case ScrollEventType.SmallDecrement:

newValue = Math.Max(this.value - this.SmallChange, this.minimum);

break;

case ScrollEventType.SmallIncrement:

newValue = Math.Min((int) (this.value + this.SmallChange),

(int) ((this.maximum - this.LargeChange) + 1));

break;

case ScrollEventType.LargeDecrement:

newValue = Math.Max(this.value - this.LargeChange,

this.minimum);

break;

case ScrollEventType.LargeIncrement:

newValue = Math.Min((int) (this.value + this.LargeChange),

(int) ((this.maximum - this.LargeChange) + 1));

break;

Tags:

A compact framework tip

by Administrator25. September 2009 01:56

Thought I'd start posting tips and reminders here for things about coding I have found useful, mainly as a place where I can store them so I can find them again when I have forgotten them in the near future :)

So this one is the location of the actual compact framework assemblies on your development machine, handy for loading into reflector.

C:\Program Files (x86)\Microsoft.NET\SDK\CompactFramework\v3.5\Debugger\BCL

Tags:

About the author

Something about the author

Month List

Page List