Size: 787
Comment:
|
Size: 6419
Comment: solutions for common problems
|
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:36:38.684078693 +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' |
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 = ( |
Line 25: | Line 86: |
Test it locally | Create database tables: {{{ ./manage.py syncdb }}} (You can answer "no" to create superuser now.) Test it locally |
Line 29: | Line 94: |
Note: the above patches (and some other convenient things) are in this repo: http://freehg.org/u/certik/freehg/ == 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 RewriteEngine on RewriteCond %{QUERY_STRING} .+ RewriteRule /u(/.*) /home/ondra/repos/freehg/web/hgwebdir.cgi$1 RewriteCond %{REQUEST_URI} !u/([^/]+)/([^/?]+)/?$ RewriteCond %{REQUEST_URI} !u/([^/]+)/([^/?]+)/edit/?$ RewriteCond %{REQUEST_URI} !u/([^/]+)/([^/?]+)/delete/?$ RewriteRule /u(/.*) /home/ondra/repos/freehg/web/hgwebdir.cgi$1 <Directory "/home/ondra/repos/freehg/web/"> Order allow,deny Allow from all AllowOverride All SetHandler None Options ExecCGI AddHandler cgi-script .cgi AuthUserFile /home/ondra/repos/freehg/htpasswd AuthGroupFile /dev/null AuthName "freehg.org" AuthType Basic <LimitExcept GET> Require valid-user </LimitExcept> </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. Put this into your /etc/mercurial/hgrc: {{{ [web] style = /home/ondra/repos/freehg/hgtemplates/freehg allow_archive = bz2 gz zip push_ssl = false allow_push = * }}} not working ,any details? == Problems and fixes == === Django 0.95 === FreeHG doesn't work with Django 0.95 or above. Here is how you need to change the source code to get it working with 0.95: The parameter name for "max_length" was changed to "maxlength" (without the underscore). To get "manage.py syncdb" runnig you need to change "repos/model.py" line 51 - 54 from {{{ name = models.CharField(max_length=30) long_name = models.CharField(max_length=50, blank=True) description = models.TextField(max_length=5000, blank=True) }}} to: {{{ name = models.CharField(maxlength=30) long_name = models.CharField(maxlength=50, blank=True) description = models.TextField(maxlength=5000, blank=True) }}} === Ubuntu 8.10 (and probably othe distros shiping with Django above 1.0) === If you want to install FreeHG on Ubuntu 8.10 *download Django 0.95 from http://www.djangoproject.com/download/0.95.4/tarball/ *extract the "django" directory from the tar ball *copy the "django" directory below your freehg folder *apply the changes above to "repos/model.py" |
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
Note: the above patches (and some other convenient things) are in this repo:
http://freehg.org/u/certik/freehg/
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 RewriteEngine on RewriteCond %{QUERY_STRING} .+ RewriteRule /u(/.*) /home/ondra/repos/freehg/web/hgwebdir.cgi$1 RewriteCond %{REQUEST_URI} !u/([^/]+)/([^/?]+)/?$ RewriteCond %{REQUEST_URI} !u/([^/]+)/([^/?]+)/edit/?$ RewriteCond %{REQUEST_URI} !u/([^/]+)/([^/?]+)/delete/?$ RewriteRule /u(/.*) /home/ondra/repos/freehg/web/hgwebdir.cgi$1 <Directory "/home/ondra/repos/freehg/web/"> Order allow,deny Allow from all AllowOverride All SetHandler None Options ExecCGI AddHandler cgi-script .cgi AuthUserFile /home/ondra/repos/freehg/htpasswd AuthGroupFile /dev/null AuthName "freehg.org" AuthType Basic <LimitExcept GET> Require valid-user </LimitExcept> </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. Put this into your /etc/mercurial/hgrc:
[web] style = /home/ondra/repos/freehg/hgtemplates/freehg allow_archive = bz2 gz zip push_ssl = false allow_push = *
not working ,any details?
Problems and fixes
Django 0.95
FreeHG doesn't work with Django 0.95 or above. Here is how you need to change the source code to get it working with 0.95: The parameter name for "max_length" was changed to "maxlength" (without the underscore). To get "manage.py syncdb" runnig you need to change "repos/model.py" line 51 - 54 from
name = models.CharField(max_length=30) long_name = models.CharField(max_length=50, blank=True) description = models.TextField(max_length=5000, blank=True)
to:
name = models.CharField(maxlength=30) long_name = models.CharField(maxlength=50, blank=True) description = models.TextField(maxlength=5000, blank=True)
Ubuntu 8.10 (and probably othe distros shiping with Django above 1.0)
If you want to install FreeHG on Ubuntu 8.10
download Django 0.95 from http://www.djangoproject.com/download/0.95.4/tarball/
- extract the "django" directory from the tar ball
- copy the "django" directory below your freehg folder
- apply the changes above to "repos/model.py"