Differences between revisions 6 and 13 (spanning 7 versions)
Revision 6 as of 2008-07-03 13:33:07
Size: 1278
Editor: certik
Comment:
Revision 13 as of 2008-07-03 20:15:12
Size: 4614
Editor: certik
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
How to setup FreeHg on your own server
======================================
= How to setup FreeHg on your own server =
Line 13: Line 12:
# HG changeset patch
# User Ondrej Certik <ondrej@certik.cz>
# Date 1215091794 -7200
# Node ID e2055dc9678e37e8ec0e140ee76dfcefd0245ffe
# Parent 9de77539abe2c32a2a1bdc35cc87fa872b96b3af
summary view adapted to the latest mercurial

diff --git a/repos/views.py b/repos/views.py
--- a/repos/views.py
+++ b/repos/views.py
@@ -78,6 +78,7 @@ def summary(request, username, reponame)
     from mercurial.hgweb.hgweb_mod import hgweb
     from mercurial.hgweb.common import style_map
     from mercurial import templater
+ from mercurial.templatefilters import filters as common_filters
     from django.conf import settings
     web = hgweb(hgrepo, name=repo.get_long_name())
     web.refresh()
@@ -85,7 +86,7 @@ def summary(request, username, reponame)
         yield web.config("web", "motd", "")
     templatepath = settings.HG_TEMPLATE_PATH
     mapfile = mapfile = style_map(templatepath, "freehg")
- web.t = templater.templater(mapfile, templater.common_filters,
+ tmpl = templater.templater(mapfile, common_filters,
                                      defaults={"url": request.build_absolute_uri(),
                                                "staticurl": "/static/",
                                                "urlbase": "/",
@@ -106,7 +107,7 @@ def summary(request, username, reponame)
             else:
                 # FIXME I have a feeling that this isn't correct.
                 content.append(str(thing).decode('utf8'))
- write(web.summary())
+ write(web.summary(tmpl))
 
     return render_to_response('repos/summary.html',
         dict(
}}}
And also this patch:
{{{
Line 14: Line 52:
+++ settings.py 2008-07-03 14:51:36.343034650 +0200
@@ -23,6 +23,8 @@
 # system time zone.
 TIME_ZONE = 'America/Chicago'
+++ settings.py 2008-07-03 15:18:54.245187159 +0200
@@ -7,10 +7,13 @@
     # ('Your Name', 'your_email@domain.com'),
 )
Line 19: Line 57:
+REPO_PATH = "/tmp" +import os
Line 21: Line 59:
 # Language code for this installation. All choices can be found here:
 # http://www.i18nguy.com/unicode/language-identifiers.html
 LANGUAGE_CODE = 'en-us'
@@ -63,10 +65,13 @@
 MANAGERS = ADMINS
 
-DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = '' # Or path to database file if using sqlite3.
+DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+#DATABASE_NAME = '' # Or path to database file if using sqlite3.
+DATABASE_NAME = os.path.join(os.path.dirname(__file__), 'database.dat')
 DATABASE_USER = '' # Not used with sqlite3.
 DATABASE_PASSWORD = '' # Not used with sqlite3.
 DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
@@ -63,10 +66,15 @@
Line 28: Line 73:
+import os +HTPASSWD_FILE = os.path.join(os.path.dirname(__file__), 'htpasswd')
+HG_TEMPLATE_PATH = os.path.join(os.path.dirname(__file__), 'hgtemplates')
+REPO_PATH = "/tmp/po"
Line 47: Line 94:

== Installing in apache ==

Apache config:
{{{
<VirtualHost *>
    ServerName freehg.org
    ServerAdmin your@email.com
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE freehg.settings
    PythonPath "['/home/ondra/repos/'] + sys.path"
        <Location "/static">
            SetHandler None
        </Location>
        Alias /static /home/ondra/repos/freehg/htdocs/static
        <Location "/u">
            SetHandler None
        </Location>
        RewriteEngine on
        RewriteRule u(/.*) /home/ondra/repos/freehg/web/hgwebdir.cgi$1
          <Directory "/home/ondra/repos/freehg/web/">
            Order allow,deny
            Allow from all
            AllowOverride All
            Options ExecCGI
            AddHandler cgi-script .cgi
          </Directory>
</VirtualHost>
}}}
Then setup permissions
{{{
$ chmod o+x freehg
$ cd freehg
$ chmod o+x database.dat
}}}
so that Apache can write to the database and create files in the freehg dir.

How to setup FreeHg on your own server

Assuming you are using Debian unstable (it should be similar on other distributions).

sudo apt-get install -t experimental python-django
hg clone http://freehg.org/u/mmarshall/freehg/
cd freehg
cp default_settings.py settings.py

Apply the following patch:

# HG changeset patch
# User Ondrej Certik <ondrej@certik.cz>
# Date 1215091794 -7200
# Node ID e2055dc9678e37e8ec0e140ee76dfcefd0245ffe
# Parent  9de77539abe2c32a2a1bdc35cc87fa872b96b3af
summary view adapted to the latest mercurial

diff --git a/repos/views.py b/repos/views.py
--- a/repos/views.py
+++ b/repos/views.py
@@ -78,6 +78,7 @@ def summary(request, username, reponame)
     from mercurial.hgweb.hgweb_mod import hgweb
     from mercurial.hgweb.common import style_map
     from mercurial import templater
+    from mercurial.templatefilters import filters as common_filters
     from django.conf import settings
     web = hgweb(hgrepo, name=repo.get_long_name())
     web.refresh()
@@ -85,7 +86,7 @@ def summary(request, username, reponame)
         yield web.config("web", "motd", "")
     templatepath = settings.HG_TEMPLATE_PATH
     mapfile = mapfile = style_map(templatepath, "freehg")
-    web.t = templater.templater(mapfile, templater.common_filters,
+    tmpl = templater.templater(mapfile, common_filters,
                                      defaults={"url": request.build_absolute_uri(),
                                                "staticurl": "/static/",
                                                "urlbase": "/",
@@ -106,7 +107,7 @@ def summary(request, username, reponame)
             else:
                 # FIXME I have a feeling that this isn't correct.
                 content.append(str(thing).decode('utf8'))
-    write(web.summary())
+    write(web.summary(tmpl))
 
     return render_to_response('repos/summary.html',
         dict(

And also this patch:

--- default_settings.py 2008-06-15 11:41:43.658803990 +0200
+++ settings.py 2008-07-03 15:18:54.245187159 +0200
@@ -7,10 +7,13 @@
     # ('Your Name', 'your_email@domain.com'),
 )
 
+import os
+
 MANAGERS = ADMINS
 
-DATABASE_ENGINE = ''           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = ''             # Or path to database file if using sqlite3.
+DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+#DATABASE_NAME = ''             # Or path to database file if using sqlite3.
+DATABASE_NAME = os.path.join(os.path.dirname(__file__), 'database.dat')
 DATABASE_USER = ''             # Not used with sqlite3.
 DATABASE_PASSWORD = ''         # Not used with sqlite3.
 DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
@@ -63,10 +66,15 @@
 
 ROOT_URLCONF = 'freehg.urls'
 
+HTPASSWD_FILE = os.path.join(os.path.dirname(__file__), 'htpasswd')
+HG_TEMPLATE_PATH = os.path.join(os.path.dirname(__file__), 'hgtemplates')
+REPO_PATH = "/tmp/po"
+
 TEMPLATE_DIRS = (
     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
     # Always use forward slashes, even on Windows.
     # Don't forget to use absolute paths, not relative paths.
+    os.path.join(os.path.dirname(__file__), 'templates'),
 )
 
 INSTALLED_APPS = (

Create database tables:

./manage.py syncdb

(You can answer "no" to create superuser now.) Test it locally

./manage.py runserver

Installing in apache

Apache config:

<VirtualHost *>
    ServerName freehg.org
    ServerAdmin your@email.com
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE freehg.settings
    PythonPath "['/home/ondra/repos/'] + sys.path"
        <Location "/static">
            SetHandler None
        </Location>
        Alias /static /home/ondra/repos/freehg/htdocs/static
        <Location "/u">
            SetHandler None
        </Location>
        RewriteEngine on
        RewriteRule u(/.*) /home/ondra/repos/freehg/web/hgwebdir.cgi$1
          <Directory "/home/ondra/repos/freehg/web/">
            Order allow,deny
            Allow from all
            AllowOverride All
            Options ExecCGI
            AddHandler cgi-script .cgi
          </Directory>
</VirtualHost>

Then setup permissions

$ chmod o+x freehg
$ cd freehg
$ chmod o+x database.dat

so that Apache can write to the database and create files in the freehg dir.

HowToSetupFreeHg (last edited 2013-09-02 01:53:25 by KevinBot)