~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

Move info branch statistics gathering into the repository to allow smart server optimisation (Robert Collins).

Show diffs side-by-side

added added

removed removed

Lines of Context:
243
243
        return self.control_files.get_physical_lock_status()
244
244
 
245
245
    @needs_read_lock
 
246
    def gather_stats(self, revid, committers=None):
 
247
        """Gather statistics from a revision id.
 
248
 
 
249
        :param revid: The revision id to gather statistics from.
 
250
        :param committers: Optional parameter controlling whether to grab
 
251
            a count of committers.
 
252
        :return: A dictionary of statistics. Currently this contains:
 
253
            committers: The number of committers if requested.
 
254
            firstrev: A tuple with timestamp, timezone for the penultimate left
 
255
                most ancestor of revid, if revid is not the NULL_REVISION.
 
256
            latestrev: A tuple with timestamp, timezone for revid, if revid is
 
257
                not the NULL_REVISION.
 
258
        """
 
259
        result = {}
 
260
        if committers:
 
261
            result['committers'] = 0
 
262
        if revid == _mod_revision.NULL_REVISION:
 
263
            return result
 
264
        all_committers = set()
 
265
        revisions = self.get_ancestry(revid)
 
266
        # pop the leading None
 
267
        revisions.pop(0)
 
268
        first_revision = None
 
269
        if not committers:
 
270
            # ignore the revisions in the middle - just grab first and last
 
271
            revisions = revisions[0], revisions[-1]
 
272
        for revision in self.get_revisions(revisions):
 
273
            if not first_revision:
 
274
                first_revision = revision
 
275
            if committers:
 
276
                all_committers.add(revision.committer)
 
277
        last_revision = revision
 
278
        if committers:
 
279
            result['committers'] = len(all_committers)
 
280
        result['firstrev'] = first_revision.timestamp, first_revision.timezone
 
281
        result['latestrev'] = last_revision.timestamp, last_revision.timezone
 
282
        return result
 
283
 
 
284
    @needs_read_lock
246
285
    def missing_revision_ids(self, other, revision_id=None):
247
286
        """Return the revision ids that other has that this does not.
248
287