3764
Comment:
|
4051
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
=== Introduction === For a really really simple way of publishing your Mercurial repositories on the Web without the need for Apache or IIS. |
|
Line 3: | Line 5: |
Some quotes from the !CherryPy Web site: !CherryPy is a pythonic, object-oriented HTTP framework. |
|
Line 4: | Line 8: |
=== Introduction === | !CherryPy powered web applications are in fact stand-alone Python applications embedding their own multi-threaded web server. |
Line 6: | Line 10: |
!CherryPy is a pythonic, object-oriented HTTP framework. !CherryPy powered web applications are in fact stand-alone Python applications embedding their own multi-threaded web server. !CherryPy applications run on Windows, Linux, Mac OS X and any other platform supporting Python. |
!CherryPy applications run on Windows, Linux, Mac OS X and any other platform supporting Python. |
Line 12: | Line 13: |
Line 14: | Line 14: |
Line 21: | Line 20: |
Line 23: | Line 21: |
Line 57: | Line 54: |
Host can be IP number or domain name (usually, depending on how your network is set up). | sUrlHost can be IP number or domain name (usually, depending on how your network is set up). |
Line 69: | Line 66: |
Line 71: | Line 67: |
Use this if you don't want the fancy Browser front-end. |
Use this if you don't want the fancy browser front-end. |
Line 83: | Line 78: |
# Change these to suit your repositories: | # Change this to represent your repository/ies: |
Line 115: | Line 110: |
Host can be IP number or domain name (usually, depending on how your network is set up). | sUrlHost can be IP number or domain name (usually, depending on how your network is set up). |
Line 117: | Line 112: |
Change tuples in lRepos list to suit, must have leading forward slash on first element of each tuple. | Change tuples in lRepos list to show the repositories that you want published, first element of each tuple must have a leading forward slash. |
Line 127: | Line 122: |
Example command: {{{ hg clone "http://192.168.0.10:8080/project2" }}} ---- |
Publishing Repositories Using CherryPy
Introduction
For a really really simple way of publishing your Mercurial repositories on the Web without the need for Apache or IIS.
Some quotes from the CherryPy Web site:
CherryPy is a pythonic, object-oriented HTTP framework.
CherryPy powered web applications are in fact stand-alone Python applications embedding their own multi-threaded web server.
CherryPy applications run on Windows, Linux, Mac OS X and any other platform supporting Python.
CherryPy can run WSGI compliant applications like hgweb and hgwebdir.
Pre-requisties
Python 2.4 or newer (http://www.python.org/download/)
CherryPy 3.1 or newer (http://www.cherrypy.org/)
Read PublishingRepositories and HgWebDirStepByStep first to get an understanding of hgweb, hgwebdir, the hgweb.config file and Mercurial Lib folder setup.
Using HgWebDir
Here is my sample code that utilizes the hgwebdir module. Edit this code to suit your needs:
1 # cphgwebdir.py
2
3 # Adjust host and port to suit your Web presence:
4 sUrlHost='0.0.0.0'
5 iUrlPort=8080
6
7 # Adjust encoding to suit or comment out:
8 import os
9 os.environ['HGENCODING']='UTF-8'
10
11 import sys
12 # Adjust path to your Mercurial Lib folder:
13 sys.path.append(r'C:\Program Files\Mercurial\Lib')
14 from mercurial.hgweb.hgwebdir_mod import hgwebdir
15
16 import cherrypy
17 cherrypy.config.update({
18 # Default is development environment, uncomment below when in production
19 #'environment':'production',
20 'server.socket_host':sUrlHost,
21 'server.socket_port':iUrlPort,
22 'log.error_file':'error.log',
23 'log.screen':True
24 })
25 # Use same hgweb.config file as for hgwebdir.cgi
26 cherrypy.tree.graft(hgwebdir('hgweb.config'),script_name='/')
27 cherrypy.engine.start()
28 cherrypy.engine.block()
sUrlHost can be IP number or domain name (usually, depending on how your network is set up).
Save this code into the same folder as hgweb.config. Unless you have added a path, then save to the root of that path.
Suggested filename is cphgwebdir.py
From a command line just execute the file, like this from its folder:
/path/to/python cphgwebdir.py
That's it.
Using HgWeb
Use this if you don't want the fancy browser front-end.
Here is my sample code that utilizes the hgweb module. Edit this code to suit your needs:
1 # cphgweb.py
2
3 # Adjust host and port to suit your Web presence:
4 sUrlHost='0.0.0.0'
5 iUrlPort=8080
6
7 # Change this to represent your repository/ies:
8 lRepos=[
9 ('/project1',r'C:\Program Files\DemoRepos\project1'),
10 ('/project2',r'C:\Program Files\DemoRepos\project2'),
11 ('/project3',r'C:\Program Files\DemoRepos\project3')
12 ]
13
14 # Adjust encoding to suit or comment out:
15 import os
16 os.environ['HGENCODING']='UTF-8'
17
18 import sys
19 # Adjust path to your Mercurial Lib folder:
20 sys.path.append(r'C:\Program Files\Mercurial\Lib')
21 from mercurial.hgweb.hgweb_mod import hgweb
22
23 import cherrypy
24 cherrypy.config.update({
25 # Default is development environment, uncomment below when in production
26 #'environment':'production',
27 'engine.autoreload.on':True,
28 'server.socket_host':sUrlHost,
29 'server.socket_port':iUrlPort,
30 'log.error_file':'error.log',
31 'log.screen':True
32 })
33 for (sName,sPath) in lRepos:
34 cherrypy.tree.graft(hgweb(sPath),script_name=sName)
35 cherrypy.engine.start()
36 cherrypy.engine.block()
sUrlHost can be IP number or domain name (usually, depending on how your network is set up).
Change tuples in lRepos list to show the repositories that you want published, first element of each tuple must have a leading forward slash.
Suggested filename is cphgweb.py
From a command line just execute the file, like this from its folder:
/path/to/python cphgweb.py
You can make changes to the lRepos list while it is running, saving changes will initiate a restart.
Example command:
hg clone "http://192.168.0.10:8080/project2"