~beuno/loggerhead/zpt.cleaner_urls

« back to all changes in this revision

Viewing changes to loggerhead/branchview.py

  • Committer: Martin Albisetti
  • Date: 2008-06-18 04:08:52 UTC
  • mfrom: (128.22.4 trunk)
  • Revision ID: argentina@gmail.com-20080618040852-qess1m7633apk3h5
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from cherrypy import HTTPRedirect
30
30
 
31
31
from loggerhead import util
32
 
from loggerhead.changecache import ChangeCache, FileChangeCache
 
32
from loggerhead.changecache import FileChangeCache
33
33
from loggerhead.history import History
34
 
from loggerhead.textindex import TextIndex
35
34
from loggerhead.controllers.changelog_ui import ChangeLogUI
36
35
from loggerhead.controllers.atom_ui import AtomUI
37
36
from loggerhead.controllers.revision_ui import RevisionUI
59
58
        # branch history
60
59
        self._history_lock = threading.RLock()
61
60
        self._history = None
62
 
        self._closed = False
63
61
 
64
62
        self.changes = ChangeLogUI(self)
65
63
        self.revision = RevisionUI(self)
72
70
        # force history object to be loaded:
73
71
        self.get_history()
74
72
 
75
 
        turbogears.startup.call_on_shutdown.append(self.close)
76
 
 
77
 
    @with_history_lock
78
 
    def close(self):
79
 
        # it's important that we cleanly detach the history, so the cache
80
 
        # files can be closed correctly and hopefully remain uncorrupted.
81
 
        # this should also stop any ongoing indexing.
82
 
        self._history.detach()
83
 
        self._history = None
84
 
        self._closed = True
85
 
 
86
73
    config = property(lambda self: self._config)
87
74
 
88
75
    name = property(lambda self: self._name)
143
130
        calls.  but if the bazaar branch on-disk has been updated since this
144
131
        History was created, a new object will be created and returned.
145
132
        """
146
 
        if self._closed:
147
 
            return None
148
133
        if (self._history is None) or self._history.out_of_date():
149
134
            self.log.debug('Reload branch history...')
150
 
            if self._history is not None:
151
 
                self._history.detach()
152
135
            _history = self._history = History.from_folder(
153
136
                self._absfolder, self._name)
154
137
            cache_path = self._config.get('cachepath', None)
156
139
                # try the project config
157
140
                cache_path = self._project_config.get('cachepath', None)
158
141
            if cache_path is not None:
159
 
                _history.use_cache(ChangeCache(_history, cache_path))
160
142
                _history.use_file_cache(FileChangeCache(_history, cache_path))
161
 
                _history.use_search_index(TextIndex(_history, cache_path))
162
143
        return self._history
163
144
 
164
 
    def check_rebuild(self):
165
 
        h = self.get_history()
166
 
        if h is not None:
167
 
            h.check_rebuild()
168
 
 
169
145
    def url(self, elements, **kw):
170
146
        "build an url relative to this branch"
171
147
        if not isinstance(elements, list):