1
# Copyright 2009 Canonical Ltd
3
# This file allows loggerhead to be treated as a plugin for bzr.
5
# XXX: Because loggerhead already contains a loggerhead directory, much of the code
6
# is going to live in bzrlib.plugins.loggerhead.loggerhead. But moving it can
7
# wait. When we do move it, we may need to guard the plugin code by __name__
8
# so it can be used as a library from other places. -- mbp 20090123
10
"""Loggerhead web viewer for Bazaar branches."""
13
from bzrlib.api import require_api
15
version_info = (1, 11, 0)
17
require_api(bzrlib, (1, 11, 0))
20
# TODO: All the following should be in a lazily-loaded module.
22
# TODO: This should provide a new type of server that can be used by bzr
23
# serve, maybe through a registry, rather than overriding the command. Though
24
# maybe we should keep the wrapper to work with older bzr releases, at least
27
# TODO: If a --port option is given, use that.
29
import bzrlib.builtins
30
from bzrlib.commands import get_cmd_object, register_command
31
from bzrlib.option import Option
33
_original_command = get_cmd_object('serve')
35
class cmd_serve(bzrlib.builtins.cmd_serve):
36
__doc__ = _original_command.__doc__
38
takes_options = _original_command.takes_options + [
40
help='Run an http (Loggerhead) server to browse code.')]
42
def run(self, *args, **kw):
44
# hack around loggerhead expecting to be loaded from the module
47
sys.path.append(os.path.dirname(__file__))
48
from loggerhead.apps.filesystem import BranchesFromFileSystemRoot
49
from paste.httpexceptions import HTTPExceptionHandler
50
from paste.httpserver import serve
51
a = HTTPExceptionHandler(BranchesFromFileSystemRoot('.'))
52
serve(a, host='0.0.0.0', port='9876')
54
super(cmd_serve, self).run(*args, **kw)
56
register_command(cmd_serve)