Posts tagged with “hg”

Posted 6 months ago

Got a hang of how to control read/write access to repositories & users through hgrc configuration.

Posted 6 months ago

Enabled digest authentication on Apache for repository access, so Apache authenticates users before allowing access to repositories.

Now I need to be able to manage things like:

user1 has ‘read access’ to repo1

user2 ha ‘readwrite access’ to repo1

etc.  but how? That’s what I got to figure out.

Posted 6 months ago

Using mod_rewrite rules of Apache and corresponding changes to hgweb.config file I am able to hide the hgwebdir.cgi from the URL. Next is to configure fine-grained access control to repositories.

Posted 6 months ago

A narrow hgwebdir HOWTO

I wanted to publish Mercurial repositories over HTTP using hgwebdir & I just got it working for me.

I struggled for a while with this & I thought a post on how I got it working (however narrow it might be) could be of some help to some. I write this without any assurances and being fully aware that this info can become stale pretty quickly.

System Info: Windows 7, Apache 2.2, Python 2.5, Mercurial 1.4.2 (Windows binary distribution)

Assuming you have Apache 2+ server up & running and you also have Python 2.5 installed (Python 2.6 dint work for me, it caused some magic number errors), I list the steps to get it working.

Steps:

1. Download the mercurial binary distribution 1.4.2 from http://mercurial.selenic.com and install it. (I installed it under “C:\Program Files\Mercurial” and I’ll refer to this path as Mercurial Installation Path or MIP). Make sure mercurial is properly installed and is working, check by typing the hg command at the command prompt.

2. Notice library.zip under MIP, extract it to a folder called library in MIP.
You should also find a folder called Templates under MIP, just copy the Templates folder to the library folder. (this being a HOW-TO & not a WHY-TO, don’t worry why)

3. Now you need hgwebdir.cgi script but, unfortunately the binary distribution doesn’t have it. You need to get it from source for which you can download the tar.gz or you could clone the mercurial repository (like I did) with the command:

hg clone http://selenic.com/repo/hg

4. You will find the script under the root folder, decide where you want to have your cgi script and place it there. For instance I created a folder called webdir under C drive and copied the hgwebdir.cgi script to that.

5. You need to make appropriate changes to the script similar to what I have done:

First line should have the path to python.exe my line looks like this:

#!c:/Python25/python.exe

Then I uncommented the following lines :

#import sys
#sys.path.insert(0, “/path/to/python/lib”)

and changed them to

import sys
sys.path.insert(0, “C:\Program Files\Mercurial\library”)

I also uncommented the following lines for debugging purpose (this is optional)

#import cgitb
#cgitb.enable()

6. You need to create the hgweb.config file and add the paths to the repositories. I added just the 2 lines listed below to the file hgweb.config which I have placed under C:\webdir (where I have my hgwebdir.cgi). Note that hgwebdir.cgi shows other patterns of specifying repositories.

[paths]
repos = C:\Users\Rajeev\RND\*

(I am exposing the repositories under C:\Users\Rajeev\RND)

7. Configuring Apache is the last mile. There are many ways that you can configure it but, I am just showing what I done. To httpd.conf file I added the following:

Alias /hg “C:/webdir”
<Directory “C:/webdir”>
Options +ExecCGI
AddHandler cgi-script .cgi
Order deny,allow
Allow from all
</Directory>

Note that I haven’t taken care of access control and I am not yet bothered by the ugly URL that I use to access the repositories.

8. Thats it, when I access the URL http://localhost:8080/hg/hgwebdir.cgi it lists me the repositories under my RND folder. I cloned my helloworld repository using the command:

hg clone http://localhost:8080/hg/hgwebdir.cgi/repos/helloworld

P.S. I still need to figure out how to manage access rights to repositories and how to avoid hgwebdir.cgi in the URL.

    Posted 6 months ago

    Able to publish Mercurial Repositories over HTTP using hgwebdir.cgi

    I need to figure out how to manage access rights to published repositories.