11
10
from paste import httpexceptions
13
12
from loggerhead.apps import static_app
13
from loggerhead.controllers.changelog_ui import ChangeLogUI
14
from loggerhead.controllers.inventory_ui import InventoryUI
14
15
from loggerhead.controllers.annotate_ui import AnnotateUI
16
from loggerhead.controllers.revision_ui import RevisionUI
15
17
from loggerhead.controllers.atom_ui import AtomUI
16
from loggerhead.controllers.changelog_ui import ChangeLogUI
17
from loggerhead.controllers.diff_ui import DiffUI
18
18
from loggerhead.controllers.download_ui import DownloadUI
19
from loggerhead.controllers.filediff_ui import FileDiffUI
20
from loggerhead.controllers.inventory_ui import InventoryUI
21
from loggerhead.controllers.revision_ui import RevisionUI
22
from loggerhead.controllers.revlog_ui import RevLogUI
23
19
from loggerhead.controllers.search_ui import SearchUI
24
20
from loggerhead.history import History
25
21
from loggerhead import util
30
24
class BranchWSGIApp(object):
32
26
def __init__(self, branch, friendly_name=None, config={},
33
graph_cache=None, branch_link=None, is_root=False,
34
served_url=_DEFAULT, use_cdn=False):
27
graph_cache=None, branch_link=None):
35
28
self.branch = branch
36
29
self._config = config
37
30
self.friendly_name = friendly_name
38
31
self.branch_link = branch_link # Currently only used in Launchpad
39
self.log = logging.getLogger('loggerhead.%s' % friendly_name)
32
self.log = logging.getLogger('loggerhead.%s' % (friendly_name,))
40
33
if graph_cache is None:
41
graph_cache = bzrlib.lru_cache.LRUCache(10)
34
graph_cache = bzrlib.lru_cache.LRUCache()
42
35
self.graph_cache = graph_cache
43
self.is_root = is_root
44
self.served_url = served_url
45
self.use_cdn = use_cdn
47
37
def get_history(self):
49
revinfo_disk_cache = None
38
_history = History(self.branch, self.graph_cache)
50
39
cache_path = self._config.get('cachepath', None)
51
40
if cache_path is not None:
52
41
# Only import the cache if we're going to use it.
53
42
# This makes sqlite optional
55
from loggerhead.changecache import (
56
FileChangeCache, RevInfoDiskCache)
44
from loggerhead.changecache import FileChangeCache
57
45
except ImportError:
58
46
self.log.debug("Couldn't load python-sqlite,"
59
47
" continuing without using a cache")
61
file_cache = FileChangeCache(cache_path)
62
revinfo_disk_cache = RevInfoDiskCache(cache_path)
64
self.branch, self.graph_cache, file_cache=file_cache,
65
revinfo_disk_cache=revinfo_disk_cache, cache_key=self.friendly_name)
49
_history.use_file_cache(
50
FileChangeCache(_history, cache_path))
67
53
def url(self, *args, **kw):
68
54
if isinstance(args[0], list):
118
94
if self._static_url_base is None:
119
95
self._static_url_base = self._url_base
120
96
self._environ = environ
121
if self.served_url is _DEFAULT:
122
public_branch = self.branch_url()
123
if public_branch is not None:
124
self.served_url = public_branch
126
self.served_url = self.url([])
127
97
path = request.path_info_pop(environ)
129
99
raise httpexceptions.HTTPMovedPermanently(