Mercurial: Revision Control on Circe

We’ve had stand-alone Mercurial support for a while, but we’ve never had it integrated with the MyWeb system for sharing your source trees with other users.  Now, we do.  Using some interesting cgi tools and Mercurial’s own hgwebdir cgi, we’ve been able to hack together a really simple tool that allows a user to publish his/her source trees — SSL and password protected, of course — over the web with full read/write access and the ability to control which users have read/write access.

To set this up, simply run

[user@circe ~]$ share-repos

This will cook up everything needed to share out your source trees. Now, all you need to do is move your trees into the ~/repo directory and they will show up here:

https://myweb.usf.edu/~[netid]/cgi-bin/hgwebdir.cgi

By default, only you will be able to access your source trees this way. It will request a username and password when you access this URL. You can use your USF NetID and Password. If you want to change this behavior — for instance, to allow anyone to pull/clone, but only certain users to push — read the comments in ~/public_html/cgi-bin/.htaccess

Adding Users

To add users that have a USF NetID, simply append the NetID to the end of the following line in ~/public_html/cgi-bin/.htaccess:


Require ldap-user [netid] [netid] ...

Don’t remove yourself of you could get locked out :)

To add users that do not have a USF NetID, simply run the following command:


[user@circe ~]$ htpasswd ~/repo/htpasswd [username]

Where [username] is the desired username. You will be prompted to create and verify a password.

From your client system, you should be able to push/pull/clone from your source trees using the same ‘hg’ command you’ve been using for a while.


[user@circe ~]$ hg clone https://myweb.usf.edu/~[netid]/cgi-bin/hgwebdir.cgi/[repo]

Happy coding!

2 comments to Mercurial: Revision Control on Circe

  • brs

    By default, only users that authenticate can clone the repository. If you wish to control who has access to what repositories, take a look at the syntax for the .hg/hgrc file that exists inside each one of your repos. You can specify options like:

    [web]
    allow_push = …
    allow_pull = …

    They may authenticate with the web server, but HG has to give them authorization at that point.

    Hope this helps!

    http://www.selenic.com/mercurial/hgrc.5.html#web

  • mjuha

    This is wonderful and useful. Thank you, Brian.
    But I have a two questions:

    1) Does everybody could clone the repository?

    2) If I have three repositories, then all the user in “Require ldap-user [netid] [netid] …” could access the three repositories? Is there a way to control it?

You must be logged in to post a comment.