~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/history.py

  • Committer: Michael Hudson
  • Date: 2008-06-30 08:51:30 UTC
  • mto: This revision was merged to the branch mainline in revision 180.
  • Revision ID: michael.hudson@canonical.com-20080630085130-3a4fze0fbsf9k32x
don't recalculate the whole history the whole time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
        self._lock = threading.RLock()
193
193
 
194
194
    @classmethod
195
 
    def from_branch(cls, branch):
 
195
    def from_branch(cls, branch, graph_cache):
196
196
        z = time.time()
197
197
        self = cls()
198
198
        self._branch = branch
199
199
        self.log = logging.getLogger('loggerhead.%s' % (branch.nick,))
200
200
 
201
201
        self._last_revid = branch.last_revision()
202
 
        d = compute_whole_history_data(branch)
 
202
        d = graph_cache.get(self._last_revid)
 
203
        if d is None:
 
204
            d = compute_whole_history_data(branch)
 
205
            graph_cache[self._last_revid] = d
203
206
        (self._revision_graph, self._full_history, self._revision_info,
204
207
         self._revno_revid, self._merge_sort, self._where_merged) = d
205
208
        return self
209
212
        b = bzrlib.branch.Branch.open(path)
210
213
        return cls.from_branch(b)
211
214
 
212
 
    def out_of_date(self):
213
 
        # the branch may have been upgraded on disk, in which case we're stale.
214
 
        newly_opened = bzrlib.branch.Branch.open(self._branch.base)
215
 
        if self._branch.__class__ is not \
216
 
               newly_opened.__class__:
217
 
            return True
218
 
        if self._branch.repository.__class__ is not \
219
 
               newly_opened.repository.__class__:
220
 
            return True
221
 
        return self._branch.last_revision() != self._last_revid
222
 
 
223
215
    def use_file_cache(self, cache):
224
216
        self._file_change_cache = cache
225
217