This repository has been archived by the owner on Oct 12, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMercurialRepositoriesPublishing
59 lines (45 loc) · 1.96 KB
/
MercurialRepositoriesPublishing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
= Publishing Mercurial Repositories =
Quote from Mercurial Web site: (http://www.selenic.com/mercurial/wiki/)
Mercurial (n) a fast, lightweight Source Control Management system designed for efficient handling of very large distributed projects.
If you are using Mercurial, or plan to, then it is very easy to publish your repositories on the Web using !CherryPy since Mercurial's `hgweb` and `hgwebdir` Python modules are WSGI compliant.
Here is my sample source code that utilizes the `hgweb` module. Edit this code to suit your needs:
{{{
#!python
# cphgweb.py
# Adjust host and port to suit your Web presence:
sUrlHost='0.0.0.0'
iUrlPort=8080
# Change this to represent your repository/ies:
lRepos=[
#('<virtual path>','<absolute path>'),
('/project1',r'C:\Program Files\DemoRepos\project1'),
('/project2',r'C:\Program Files\DemoRepos\project2'),
('/project3',r'C:\Program Files\DemoRepos\project3')
]
# Adjust encoding to suit or comment out:
import os
os.environ['HGENCODING']='UTF-8'
import sys
# Adjust path to your Mercurial Lib folder:
sys.path.append(r'C:\Program Files\Mercurial\Lib')
from mercurial.hgweb.hgweb_mod import hgweb
import cherrypy
cherrypy.config.update({
#'environment':'production',
'engine.autoreload.on':True,
'server.socket_host':sUrlHost,
'server.socket_port':iUrlPort,
'log.error_file':'error.log',
'log.screen':True
})
for (sName,sPath) in lRepos:
cherrypy.tree.graft(hgweb(sPath),script_name=sName)
cherrypy.engine.start()
cherrypy.engine.block()
}}}
Change tuples in `lRepos` list to indicate the repositories that you want published, first element of each tuple must have a leading forward slash.
Suggested filename is `cphgweb.py`
For an example using the `hgwebdir` module see my sample code at:
http://www.selenic.com/mercurial/wiki/index.cgi/PublishingRepositoriesUsingCherryPy
Now with digest authentication example and Windows Service example.
----