~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/info.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-09 20:23:07 UTC
  • mfrom: (4265.1.4 bbc-merge)
  • Revision ID: pqm@pqm.ubuntu.com-20090409202307-n0depb16qepoe21o
(jam) Change _fetch_uses_deltas = False for CHK repos until we can
        write a better fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
__all__ = ['show_bzrdir_info']
18
18
 
19
 
from cStringIO import StringIO
20
19
import os
21
20
import time
22
21
import sys
25
24
    bzrdir,
26
25
    diff,
27
26
    errors,
28
 
    hooks as _mod_hooks,
29
27
    osutils,
30
28
    urlutils,
31
29
    )
301
299
            'the repository.\n')
302
300
 
303
301
 
304
 
def _show_repository_stats(repository, stats, outfile):
 
302
def _show_repository_stats(stats, outfile):
305
303
    """Show statistics about a repository."""
306
 
    f = StringIO()
 
304
    if 'revisions' in stats or 'size' in stats:
 
305
        outfile.write('\n')
 
306
        outfile.write('Repository:\n')
307
307
    if 'revisions' in stats:
308
308
        revisions = stats['revisions']
309
 
        f.write('  %8d revision%s\n' % (revisions, plural(revisions)))
 
309
        outfile.write('  %8d revision%s\n' % (revisions, plural(revisions)))
310
310
    if 'size' in stats:
311
 
        f.write('  %8d KiB\n' % (stats['size']/1024))
312
 
    for hook in hooks['repository']:
313
 
        hook(repository, stats, f)
314
 
    if f.getvalue() != "":
315
 
        outfile.write('\n')
316
 
        outfile.write('Repository:\n')
317
 
        outfile.write(f.getvalue())
 
311
        outfile.write('  %8d KiB\n' % (stats['size']/1024))
318
312
 
319
313
 
320
314
def show_bzrdir_info(a_bzrdir, verbose=False, outfile=None):
388
382
        stats = repository.gather_stats()
389
383
    if branch is None and working is None:
390
384
        _show_repository_info(repository, outfile)
391
 
    _show_repository_stats(repository, stats, outfile)
 
385
    _show_repository_stats(stats, outfile)
392
386
 
393
387
 
394
388
def describe_layout(repository=None, branch=None, tree=None):
478
472
        # do.
479
473
        candidates = new_candidates
480
474
    return ' or '.join(candidates)
481
 
 
482
 
 
483
 
class InfoHooks(_mod_hooks.Hooks):
484
 
    """Hooks for the info command."""
485
 
 
486
 
    def __init__(self):
487
 
        self.create_hook(_mod_hooks.HookPoint('repository',
488
 
            "Invoked when displaying the statistics for a repository. "
489
 
            "repository is called with a statistics dictionary as returned "
490
 
            "by the repository and a file-like object to write to.", (1, 15), 
491
 
            None))
492
 
 
493
 
 
494
 
hooks = InfoHooks()