Publishing Mercurial repositories with Sourceforge

  1. Install Mercurial. Precompiled versions of mercurial built (make local) on Fedora Core 2 (the OS used by Sourceforge's web hosting server) may be found here: 1.0.1 1.0 0.9.5 You should untar somewhere in your project directory. For example, if your project is called project, you could use /home/groups/p/pr/project/lib/hg-0.9.5. N.B. it must be somewhere in the project directory; the web server has no access to /home/users directories.

  2. Symlink the hg script into ~/bin (eg ln -s /home/groups/p/pr/project/lib/hg-0.9.5/hg ~/bin). This way you can run hg from the command line, and more importantly, over ssh. You may have to fiddle with your shell's startup scripts to ensure ~/bin is always in your path. I use zsh, so I append $HOME/bin to my path in ~/.zshenv

  3. Make a home for your project repositories, eg mkdir /home/groups/p/pr/project/hg. You might also want to create a symlink to that directory in your home directory: ln -s /home/groups/p/pr/project/hg hg

  4. Clone your repository or repositories from your local machine to sourceforge: hg clone project ssh://user@shell.sourceforge.net/hg/project

  5. Copy hgwebdir.cgi from the mercurial directory into your cgi-bin directory (cp hgwebdir.cgi /home/groups/p/pr/project/cgi-bin). Make sure it is executable: chmod +x /home/groups/p/pr/project/cgi-bin/hgwebdir.cgi

  6. Set the path to your mercurial install at the top of hgwebdir.cgi to the location where you've unpacked mercurial. Do this by uncommenting and editing the lines below # adjust python path if not a system-wide install:, for example:

    import sys
    sys.path.insert(0, "/home/groups/p/pr/project/lib/hg-0.9.5")
  7. Write an hgweb.config file in your cgi-bin directory. For example:

    [collections]
    project = /home/groups/p/pr/project/hg
    • Your repositories are now available under project.sourceforge.net/cgi-bin/hgwebdir.cgi

  8. (optional) if you'd like to make your projects available from project.sourceforge.net/hg/, create /home/groups/p/pr/project/htdocs/hg/.htaccess with the following contents:

    RewriteEngine On
    RewriteRule (.*) /cgi-bin/hgwebdir.cgi/$1
    
  9. If you want to enable other members of the same sf.net-project to push to this repo without resetting file permissions, let every user add umask 0002 to their ~/.bashrc or ~/.zshenv on sf. Allow them to write to your repo using chmod -R g+w ./.

for an example see http://mutt.sourceforge.net/hg/

Discussion

SoloTurn asked: is it possible to push via http too?

Yes, after enabling this in hgrc, but it seems that https isn't supported, so this would be insecure. -- ThomasArendsenHein 2007-03-13 07:17:34


ArneBab: I experience problems with hosting on sf.net - cloning isn't possible off the server:

$ hg clone http://rpg-1d6.sf.net/hg/heas 
destination directory: heas
real URL is http://rpg-1d6.sourceforge.net/hg/heas
requesting all changes
adding changesets
adding manifests
adding file changes
abort: premature EOF reading chunk (got 4599261 bytes, expected 4628196)
transaction abort!
rollback completed 

bug-report: http://www.selenic.com/mercurial/bts/msg4374


PeterArrenbrecht: It works for me:

$ hg clone http://jcite.sourceforge.net/hg/jcite dev-from-sf 
requesting all changes
adding changesets
adding manifests
adding file changes
added 69 changesets with 398 changes to 121 files
113 files updated, 0 files merged, 0 files removed, 0 files unresolved 


BenoitBeraud: Did anobody asked the SF Team for the allowance to host a mercurial project in the project web service ? In the help pages of SF it is written that the project web service should be used mainly for hosting web pages related to the project. A Mercurial repo is somewhat different for a web page. So it is written that we may host different contents but only with a written permission from the SF Team. Did anybody ask a support request for this ? (more information about what may be hosted on SF Project Web Service here : http://sourceforge.net/project/admin/prweb.php?group_id=214603)

ArneBab: Yes, I did. And when my Mercurial repo ( http://rpg-1d6.sf.net/hg/ )exceeded the allowed 100MiB they granted me an increase in space to 500MiB.


CategoryHowTo

MercurialOnSourceforge (last edited 2008-07-26 12:29:33 by FernandoVezzosi)