How to configure Mercurial and hgwebdir on IIS?

I kept looking for decent instructions on how to get hgwebdir to work in IIS, but I did not find much value.

There this step by step on the Mercurial wiki page, but it is not very good. There is also this and this , but again, I cannot find good steps to bring them to where they start.

+72
windows mercurial iis
May 04 '09 at 2:08 a.m.
source share
10 answers

I just had to install a new instance of Mercurial yesterday, the instructions for 1.7 are updated here:

  • Install Mercurial (these instructions have been tested since 1.7)
  • Install Python (for Mercurial 1.7 you must use Python version 2.6.6 for x86)
  • You need to download the hgweb.cgi file from the Mercurial source. You can download the source code by running: hg clone https://www.mercurial-scm.org/repo/hg/
  • Create a folder that will be your web application folder. You will need to copy three things to this folder:

    • Hgweb.cgi file
    • The contents of Library.zip from the folder "C: \ Program Files \ Mercurial"
    • The Templates folder from your "C: \ Program Files \ Mercurial"
  • You need to make sure that you have Python installed in IIS.

    • Enable CGI through: Control Panel β†’ Enable or Disable Windows Features β†’ Roles β†’ Web Server (IIS) β†’ Add Role Services β†’ Check CGI
    • Create a new website in IIS and verify that the physical path is the folder that you created above.
    • In the handler mappings for the new website, select "Add Script Map." Type * .cgi for the request path, c: \ Python26 \ python.exe -u "% s" for the executable and Python for the name.
  • You will also need to create a file called "hgweb.config" with contents similar to the one below. The path in the file should be the location on your disk where you want to store Mercurial repositories:

    [collection]
    c: \ Mercurial \ repos = c: \ Mercurial \ repos

  • Edit the hgweb.cgi file and change the line where it sets the path to your hgweb.config like this: (wherever the hgweb.config file is):

    config = "C: \ Mercurial \ hgweb.config"

  • Now open your browser and go to http: //localhost/mercurial/hgweb.cgi (or something like the corresponding URL path set in IIS) and you should see the Mercurial Repositories page.

Also check out Jeremy Skiners blog post . This is a bit outdated, but there are some additional nice steps, such as setting up URL rewriting for a cleaner URL.

+49
May 20 '09 at 9:12
source share

It seems that since the release of Mercurial 1.5.2, these tutorials have not worked for sure. Firstly, hgwebdir.cgi has been removed and is now replaced by hgweb.cgi.

The instructions that work best for me are at eworldui.net :

http://www.eworldui.net/blog/post/2010/04/08/Setting-up-Mercurial-server-in-IIS7-using-a-ISAPI-module.aspx

These instructions are for IIS 7 or higher. If you configure this on IIS 6, I wrote similar instructions targeting Win2k3 and IIS 6.0:

http://partialclass.blogspot.com/2010/05/setting-up-mercurial-server-on-win2k3.html

UPDATE: Shortly after getting this work, I found out that BitBucket changed its pricing scheme by offering free unlimited private hosting: https://bitbucket.org/ . I would choose this in an instant when I initially worked on this project.

+34
May 04 '10 at 16:08
source share

I found that the Vampire Basic blog post was a good start, but it didn’t get to the last detail, it was after.

I made a blog entry in 4 parts, which starts you from scratch using IIS, including integration with Active Directory, setting security privileges for push / pull, setting up a template, I would reproduce it here, but for quite a while that Mercurial was really Designed to host on Linux / Apache:

http://www.endswithsaurus.com/2010/05/setting-up-and-configuring-mercurial-in.html

+12
Jul 23 '10 at 17:44
source share
+11
Jul 19 '09 at 16:09
source share

Below I did what I did after doing a lot of research to get the hgwebdir.cgi installation on IIS6. It is based on the following sites:

You will need to install the following on the server:

  • Mercurial (I used version 1.5)
  • Python 2.6 The version of Python depends on the version of Mercurial installed. Mercurial 1.5 uses Python 2.6. Install x86 even if you are using x64.

For me there were the following steps:

  • Create a directory for the website. I used c: \ inetpub \ wwwroot \ hg.
  • In IIS, right-click the folder for hg, select properties, select the Home Directory tab.
  • Click the "Create Application" button. Set execution permissions for scripts.
  • On the Home Directory tab, click the Configuration button. In the "Application Settings" drop-down list, click the "Add" button to add the application extension. The executable is c: \ Python26 \ python.exe -u "% s" "% s". Extension -.cgi. Set the "verbs" to "restriction: GET, HEAD, POST". Check both Script engines and make sure the file exists.
  • On the Directory Security tab, click the Edit button in the Authentication and Access Control sections. Uncheck all authentication methods and check the "Basic authenification" method. Set the default domain if you like the Active Directory domain.
  • In IIS, click on the Web Services Extensions folder in the left pane. Click the Add New Web Service Extension link. The extension name must be Python, the required file is: c: \ Python26 \ python.exe -u "% s" "% s". Make sure the new extension is "Allowed."

Now is the time to check if Python is working. Create a file in a new Hg folder called test.cgi. Paste the following python code:

 print 'Status: 200 OK' print 'Content-type: text/html' print print '<html><head>' print '' print '<h1>It works!</h1>' print '' print '' 

Open a browser on your website, for example http: //localhost/hg/test.cgi

You should see "It works!" in the browser.

Next, enable hgwebdir.

  • Delete test.cgi
  • clone the hg repo into a new directory: https://www.mercurial-scm.org/repo/hg/
  • copy hgwebdir.cgi to your web directory: c: \ inetpub \ wwwroot \ hg \ from the cloned hg repo
  • Edit the file and change
 application = hgwebdir('hgweb.config') wsgicgi.launch(application) 

to

 application = hgwebdir('c:\inetpub\wwwroot\hg\hgweb.config') wsgicgi.launch(application) 
  • Unzip the Library.zip file in the Mercurial directory, c: \ Program Files \ Mercurial \, in your web directory, c: \ inetpub \ wwwroot \ hg \
  • Copy the templates directory from c: \ Program Files \ Mercurial \ templates \ to c: \ inetpub \ wwwroot \ hg \ templates \
  • Create the hgweb.config file in your web directory.

Now is the time to check it out. Go to the following URL in the browser, http: //localhost/hg/hgwebdir.cgi

  • Modify hgweb.config and paste the following:
 [collections] \\server\share$\Hg\ = \\server\share$\Hg\ [web] allow_push = * push_ssl = false 

These are all my preferences, for example, we have our repositories in subdirectories on \\ server \ share $ \ Hg. The web application will run under the permissions of the registered user through a browser, so they will need read and write permission for the shared resource.

The final step is to allow long connections that can happen when you first clone a repo. Run the following command to increase the timeout to 50 minutes:

 cd \inetpub\AdminScripts\ cscript adsutil.vbs GET /W3SVC/CGITimeout cscript adsutil.vbs SET /W3SVC/CGITimeout 3000 
+11
Apr 6 '10 at 9:40
source share

Use mercurial to clone mercury storage:

 hg clone https://www.mercurial-scm.org/repo/hg/ 

You will find hgwebdir.cgi on the top level. It should install like any other cgi script.

+3
May 04 '09 at 21:39
source share

I struggled with this setting for mercurial 1.7.2 last week or so, I had to do something a little different than in the above articles to make it work.

Post here because Google kept returning me here.

Full instructions are available here.

I followed a combination of these instructions and these (to the source)

The main differences are that I had to install a "pure python" installation of mercury , otherwise it will complain about missing DLLs, and I that it is important to use the "python installers" for pywin and isapi-wsgi. (maybe this is obvious to experienced python developers, but I'm new to python, so this was news to me)

Hope this helps someone, and I'm not just doing something (I might be, as I said, a python newbie)

+2
Dec 6 '10 at 15:05
source share

The hg red book contains some more general general instructions than I have seen elsewhere. They are not specific to IIS, but they are pretty good:

http://hgbook.red-bean.com/read/collaborating-with-other-people.html#sec:collab:cgi

+1
Aug 11 '09 at 21:35
source share

I encountered an error like "... I can’t load the module ...", and after some reading, the key for me was to ignore the Library.zip file in the Mercurial folder and use one of C: \ Program Files ( x86) \ TortoiseHg.

This tip I found in this guide as # 6:

http://www.endswithsaurus.com/2010/05/setting-up-and-configuring-mercurial-in.html

Hope this helps someone ...

+1
Dec 10 2018-10-10
source share

You can try HgLab . This is not really hgwebdir; rather, it is a purely managed implementation of Mercurial using a push-pull server and repository browser.

-one
Oct 10 '12 at 8:17
source share



All Articles