~bzr/bzr-webserve/webserve-dev

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# web interface to a bazaar repository
#
# Copyright 2006 Goffredo Baroncelli <kreijack@inwind.it>
#
# This file is part of bazaar-webserve.
#
# bazaar-webserve is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# bazaar-webserve is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with bazaar-webserve; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import bzrlib
from bzrlib.option import Option
import test_webserve

class cmd_webserve(bzrlib.commands.Command):
    """Start the 'webserve' web interface"""

    takes_options = [
        Option('templates', type=str),
        Option('address', type=str),
        Option('port', type=int),
        Option('ipv6'),
        Option('acceslog', type=str),
        Option('errorlog', type=str),
        Option('lock'),
        Option('profile'),
        Option('tararchive'),
        Option('style', type=str),
        Option('fileserver'),
        Option('commentfilter', type=str),
        Option('encoding', type=str),
    ]
    takes_args = ['name?', 'rootrepository?']

    def run(self, name = None, rootrepository = None,
            templates = None, address = "", port = 8088, ipv6 = None,
            accesslog = '', errorlog = '', lock=None, profile=None,
            tararchive=None, style="", fileserver=None, commentfilter=None,
            encoding=None):

        import hgweb
        import os

        if rootrepository == None:
            rootrepository = os.getcwd()
        if name == None:
            name = os.path.basename(rootrepository)
        #if templates == None:
        #    templates = os.path.join( rootrepository, "templates")

        if style:
            style = "map-"+style
        else:
            style = "map"

        httpd = hgweb.create_server(
                 path=rootrepository,
                 name=name,
                 templates=templates,
                 address=address,
                 port=port,
                 use_ipv6=ipv6,
                 acceslog=accesslog,
                 errorlog=errorlog,
                 # dolock=lock, removed  22/12/2007
                 tararchive=tararchive,
                 profile=profile,
                 mapfile=style,
                 option_provide_file=fileserver,
                 commentfilter=commentfilter and commentfilter.split(";;") or [],
                 encoding=encoding)
        httpd.serve_forever()


bzrlib.commands.register_command(cmd_webserve)
bzrlib.tests.MODULES_TO_TEST.append(test_webserve)