~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to serve-branches

  • Committer: Michael Hudson
  • Date: 2009-04-27 03:22:23 UTC
  • mfrom: (332.2.8 persist-_rev_info)
  • Revision ID: michael.hudson@canonical.com-20090427032223-trt8by0ec3njgk5m
add the ability to cache the wholehistory data to disk as well as RAM.
cache a much smaller amount of wholehistory data in RAM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import sys
21
21
 
22
22
from bzrlib.plugin import load_plugins
23
 
from bzrlib.transport import get_transport
24
23
 
25
24
from paste import httpserver
26
25
from paste.httpexceptions import HTTPExceptionHandler, HTTPInternalServerError
27
26
from paste.translogger import TransLogger
28
27
 
29
28
from loggerhead import __version__
30
 
from loggerhead.apps.transport import (
31
 
    BranchesFromTransportRoot, UserBranchesFromTransportRoot)
 
29
from loggerhead.apps.filesystem import (
 
30
    BranchesFromFileSystemRoot, UserBranchesFromFileSystemRoot)
32
31
from loggerhead.config import LoggerheadConfig
33
32
from loggerhead.util import Reloader
34
33
from loggerhead.apps.error import ErrorHandlerApp
49
48
    else:
50
49
        path = '.'
51
50
 
52
 
    load_plugins()
53
 
 
54
 
    transport = get_transport(path)
 
51
    if not os.path.isdir(path):
 
52
        print "%s is not a directory" % path
 
53
        sys.exit(1)
55
54
 
56
55
    if config.get_option('trunk_dir') and not config.get_option('user_dirs'):
57
56
        print "--trunk-dir is only valid with --user-dirs"
67
66
        if not config.get_option('trunk_dir'):
68
67
            print "You didn't specify a directory for the trunk directories."
69
68
            sys.exit(1)
70
 
        app = UserBranchesFromTransportRoot(transport, config)
 
69
        app = UserBranchesFromFileSystemRoot(path, config)
71
70
    else:
72
 
        app = BranchesFromTransportRoot(transport, config)
 
71
        app = BranchesFromFileSystemRoot(path, config)
73
72
 
74
73
    # setup_logging()
75
74
    logging.basicConfig()
87
86
    logfile.setLevel(logging.DEBUG)
88
87
    logger.addHandler(logfile)
89
88
 
 
89
    if config.get_option('memory_profile'):
 
90
        memprofile = logging.getLogger('loggerhead-memprofile')
 
91
        memprofile.setLevel(logging.DEBUG)
 
92
        memprofile.addHandler(logging.FileHandler('loggerhead-memprofile'))
 
93
 
90
94
    # setup_logging() #end
91
95
 
92
96
    app = TransLogger(app, logger=logger)
94
98
        from loggerhead.middleware.profile import LSProfMiddleware
95
99
        app = LSProfMiddleware(app)
96
100
    if config.get_option('memory_profile'):
97
 
        from dozer import Dozer
98
 
        app = Dozer(app)
 
101
        from loggerhead.middleware.profile import MemoryProfileMiddleware
 
102
        app = MemoryProfileMiddleware(app)
99
103
 
100
104
    if not config.get_option('user_prefix'):
101
105
        prefix = '/'
135
139
    else:
136
140
        host = config.get_option('user_host')
137
141
 
 
142
    load_plugins()
 
143
 
138
144
    httpserver.serve(app, host=host, port=port)
139
145
 
140
146