1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
27
27
from bzrlib.errors import (NoWorkingTree, NotBranchError,
28
28
NoRepositoryPresent, NotLocalUrl)
29
29
from bzrlib.missing import find_unmerged
30
from bzrlib.symbol_versioning import (deprecated_function,
30
from bzrlib.symbol_versioning import (deprecated_function,
176
176
branch = working.branch
177
177
basis = working.basis_tree()
178
178
work_inv = working.inventory
179
delta = working.changes_from(basis, want_unchanged=True)
180
history = branch.revision_history()
179
branch_revno, branch_last_revision = branch.last_revision_info()
182
181
tree_last_id = working.get_parent_ids()[0]
183
182
except IndexError:
184
183
tree_last_id = None
186
if len(history) and tree_last_id != history[-1]:
185
if branch_revno and tree_last_id != branch_last_revision:
187
186
tree_last_revno = branch.revision_id_to_revno(tree_last_id)
188
missing_count = len(history) - tree_last_revno
187
missing_count = branch_revno - tree_last_revno
190
189
print 'Working tree is out of date: missing %d revision%s.' % (
191
190
missing_count, plural(missing_count))
227
226
def _show_branch_stats(branch, verbose):
228
227
"""Show statistics about a branch."""
229
repository = branch.repository
230
history = branch.revision_history()
228
revno, head = branch.last_revision_info()
233
230
print 'Branch history:'
235
231
print ' %8d revision%s' % (revno, plural(revno))
232
stats = branch.repository.gather_stats(head, committers=verbose)
239
committers[repository.get_revision(rev).committer] = True
240
print ' %8d committer%s' % (len(committers), plural(len(committers)))
242
firstrev = repository.get_revision(history[0])
243
age = int((time.time() - firstrev.timestamp) / 3600 / 24)
234
committers = stats['committers']
235
print ' %8d committer%s' % (committers, plural(committers))
237
timestamp, timezone = stats['firstrev']
238
age = int((time.time() - timestamp) / 3600 / 24)
244
239
print ' %8d day%s old' % (age, plural(age))
245
print ' first revision: %s' % osutils.format_date(firstrev.timestamp,
248
lastrev = repository.get_revision(history[-1])
249
print ' latest revision: %s' % osutils.format_date(lastrev.timestamp,
253
# print 'Text store:'
254
# c, t = branch.text_store.total_size()
255
# print ' %8d file texts' % c
256
# print ' %8d KiB' % (t/1024)
259
# print 'Inventory store:'
260
# c, t = branch.inventory_store.total_size()
261
# print ' %8d inventories' % c
262
# print ' %8d KiB' % (t/1024)
240
print ' first revision: %s' % osutils.format_date(timestamp,
242
timestamp, timezone = stats['latestrev']
243
print ' latest revision: %s' % osutils.format_date(timestamp,
265
248
def _show_repository_info(repository):
269
252
print 'Create working tree for new branches inside the repository.'
272
def _show_repository_stats(repository):
255
def _show_repository_stats(stats):
273
256
"""Show statistics about a repository."""
274
if repository.bzrdir.root_transport.listable():
257
if 'revisions' in stats or 'size' in stats:
276
print 'Revision store:'
277
c, t = repository._revision_store.total_size(repository.get_transaction())
278
print ' %8d revision%s' % (c, plural(c))
279
print ' %8d KiB' % (t/1024)
260
if 'revisions' in stats:
261
revisions = stats['revisions']
262
print ' %8d revision%s' % (revisions, plural(revisions))
264
print ' %8d KiB' % (stats['size']/1024)
282
267
@deprecated_function(zero_eight)
288
273
def show_bzrdir_info(a_bzrdir, verbose=False):
289
274
"""Output to stdout the 'info' for a_bzrdir."""
291
working = a_bzrdir.open_workingtree()
276
working = a_bzrdir.open_workingtree(
277
recommend_upgrade=False)
292
278
working.lock_read()
294
280
show_tree_info(working, verbose)
337
323
_show_missing_revisions_branch(branch)
338
324
_show_missing_revisions_working(working)
339
325
_show_working_stats(working)
340
_show_branch_stats(branch, verbose)
341
_show_repository_stats(repository)
326
stats = _show_branch_stats(branch, verbose)
327
_show_repository_stats(stats)
344
330
def show_branch_info(branch, verbose):
351
337
_show_format_info(control, repository, branch)
352
338
_show_locking_info(repository, branch)
353
339
_show_missing_revisions_branch(branch)
354
_show_branch_stats(branch, verbose)
355
_show_repository_stats(repository)
340
stats = _show_branch_stats(branch, verbose)
341
_show_repository_stats(stats)
358
344
def show_repository_info(repository, verbose):
363
349
_show_format_info(control, repository)
364
350
_show_locking_info(repository)
365
351
_show_repository_info(repository)
366
_show_repository_stats(repository)
352
stats = repository.gather_stats()
353
_show_repository_stats(stats)