243
243
return self.control_files.get_physical_lock_status()
246
def gather_stats(self, revid, committers=None):
246
def gather_stats(self, revid=None, committers=None):
247
247
"""Gather statistics from a revision id.
249
:param revid: The revision id to gather statistics from.
249
:param revid: The revision id to gather statistics from, if None, then
250
no revision specific statistics are gathered.
250
251
:param committers: Optional parameter controlling whether to grab
251
a count of committers.
252
a count of committers from the revision specific statistics.
252
253
:return: A dictionary of statistics. Currently this contains:
253
254
committers: The number of committers if requested.
254
255
firstrev: A tuple with timestamp, timezone for the penultimate left
255
256
most ancestor of revid, if revid is not the NULL_REVISION.
256
257
latestrev: A tuple with timestamp, timezone for revid, if revid is
257
258
not the NULL_REVISION.
259
revisions: The total revision count in the repository.
260
size: An estimate disk size of the repository in bytes.
263
if revid and committers:
261
264
result['committers'] = 0
262
if revid == _mod_revision.NULL_REVISION:
264
all_committers = set()
265
revisions = self.get_ancestry(revid)
266
# pop the leading None
268
first_revision = None
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
276
all_committers.add(revision.committer)
277
last_revision = revision
279
result['committers'] = len(all_committers)
280
result['firstrev'] = first_revision.timestamp, first_revision.timezone
281
result['latestrev'] = last_revision.timestamp, last_revision.timezone
265
if revid and revid != _mod_revision.NULL_REVISION:
267
all_committers = set()
268
revisions = self.get_ancestry(revid)
269
# pop the leading None
271
first_revision = None
273
# ignore the revisions in the middle - just grab first and last
274
revisions = revisions[0], revisions[-1]
275
for revision in self.get_revisions(revisions):
276
if not first_revision:
277
first_revision = revision
279
all_committers.add(revision.committer)
280
last_revision = revision
282
result['committers'] = len(all_committers)
283
result['firstrev'] = (first_revision.timestamp,
284
first_revision.timezone)
285
result['latestrev'] = (last_revision.timestamp,
286
last_revision.timezone)
288
# now gather global repository information
289
if self.bzrdir.root_transport.listable():
290
c, t = self._revision_store.total_size(self.get_transaction())
291
result['revisions'] = c