+ The Oktave Forum » Technical » Engineering » Software Engineering
|-+ Mercurial http hosting
Username:
Password:

Pages: [1]
Topic Tools  
Read February 19, 2009, 04:45:41 pm #0
sri

Mercurial http hosting

Can someone give a quick step-by-step intro to making a mercurial repository available over http? Ideally it should also be password protected either using .htaccess or in any other form. Can't seem to find any good source on the web.

Thanks in advance.

(Update. Never mind. Found one here: http://www.selenic.com/mercurial/wiki/index.cgi/PublishingRepositories. But would still like to hear from others about how easy/difficult is it to set up and any common mistakes.)
« Last Edit: February 19, 2009, 05:05:53 pm by sri »
Offline  
Read February 20, 2009, 04:54:18 am #1
sids

Re: Mercurial http hosting

I had, in the past, set up a mercurial repository available at http://hg.oktave.in/. Unfortunately I don't remember exactly what I did. I'm trying to look at it and recall what I had done; will post it here once I have it figured out.


http://www.grok.in/
"Ignorance killed the cat, curiosity was framed."
Offline  
Read February 20, 2009, 05:39:54 am #2
sids

Re: Mercurial http hosting

http://www.selenic.com/mercurial/wiki/index.cgi/HgWebDirStepByStep seems to be the tutorial I had used. Here are the steps I seem to have followed:

Note: I did this quite some time ago, Mercurial might have gotten updated since and some of the steps might have changed. Mercurial is not particularly known for preserving backward compatibility.

Assumptions:
  • You want to set up Mercurial on its own sub-domain, say hg.oktave.in.
  • You want to be able to expose multiple repositories through this install.
  • You want to provide HTTP based access to all the repositories and use HTTP-based authentication to limit access.

Steps:

From the root of the webapp:
Code:
$ cat >>.htaccess
RewriteEngine                   on
RewriteBase                     /
RewriteCond %{HTTP_HOST}        ^hg.oktave.in [NC]
RewriteCond %{HTTP_HOST}        !^/hg/
RewriteRule ^(.*)               /hg/$1 [L,PT]
^D

$ mkdir hg
$ cd hg

$ wget http://www.selenic.com/repo/hg-stable/raw-file/tip/hgwebdir.cgi

$ cat >hgweb.config                   # /path/to/hg is the filesystem path of the current directory
[collections]
/path/to/hg = /path/to/hg
^D

$ cat >.htaccess
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/.htpasswd
Require valid-user

Options +Indexes
Options +ExecCGI

# Taken from http://www.pmwiki.org/wiki/Cookbook/CleanUrls#samedir
RewriteEngine On
RewriteBase /hg

RewriteRule ^$ hgwebdir.cgi  [L]

RewriteCond %{REQUEST_FILENAME} !hgwebdir.cgi
RewriteRule (.*) hgwebdir.cgi/$1  [QSA,L]
^D

$ cat >hgrc.sample
[web]
name = XXX
description = XXX
contact = FirstName LastName <email@address>
allow_push = *
push_ssl = false
allow_archive = bz2 gz zip
style = gitweb
^D

Adding a new project:
Code:
$ mkdir project
$ cd project
$ hg init
$ cp ../hgrc.sample .hg/hgrc
$ vi .hg/hgrc                 # set the name and description
Et voila!

Take a look at http://hg.oktave.in/

For authentication, use htpasswd to add some usernames/passwords to /path/to/.htpasswd


http://www.grok.in/
"Ignorance killed the cat, curiosity was framed."
Offline  
Read February 20, 2009, 06:58:40 am #3
sri

Re: Mercurial http hosting

Thanks! Let me try..
Offline  
Read February 20, 2009, 07:23:23 am #4
sids

Re: Mercurial http hosting

There does seem to be one difference with newer versions of Mercurial: http://www.selenic.com/mercurial/wiki/index.cgi/HgWebDirStepByStep#head-b4680c46eb4c7e851ba05571af3f13cd1d28be0d


http://www.grok.in/
"Ignorance killed the cat, curiosity was framed."
Offline  
Pages: [1]
Jump to: