~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/info.py

  • Committer: Martin Pool
  • Date: 2010-02-25 06:17:27 UTC
  • mfrom: (5055 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5057.
  • Revision ID: mbp@sourcefrog.net-20100225061727-4sd9lt0qmdc6087t
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
__all__ = ['show_bzrdir_info']
18
18
 
19
19
from cStringIO import StringIO
 
20
import os
20
21
import time
21
22
import sys
22
23
 
23
24
from bzrlib import (
24
25
    bzrdir,
 
26
    diff,
25
27
    errors,
26
28
    hooks as _mod_hooks,
27
29
    osutils,
78
80
 
79
81
def gather_location_info(repository, branch=None, working=None):
80
82
    locs = {}
81
 
    repository_path = repository.user_url
 
83
    repository_path = repository.bzrdir.root_transport.base
82
84
    if branch is not None:
83
 
        branch_path = branch.user_url
 
85
        branch_path = branch.bzrdir.root_transport.base
84
86
        master_path = branch.get_bound_location()
85
87
        if master_path is None:
86
88
            master_path = branch_path
88
90
        branch_path = None
89
91
        master_path = None
90
92
    if working:
91
 
        working_path = working.user_url
 
93
        working_path = working.bzrdir.root_transport.base
92
94
        if working_path != branch_path:
93
95
            locs['light checkout root'] = working_path
94
96
        if master_path != branch_path:
221
223
    """Show missing revisions in working tree."""
222
224
    branch = working.branch
223
225
    basis = working.basis_tree()
 
226
    work_inv = working.inventory
224
227
    branch_revno, branch_last_revision = branch.last_revision_info()
225
228
    try:
226
229
        tree_last_id = working.get_parent_ids()[0]
238
241
def _show_working_stats(working, outfile):
239
242
    """Show statistics about a working tree."""
240
243
    basis = working.basis_tree()
 
244
    work_inv = working.inventory
241
245
    delta = working.changes_from(basis, want_unchanged=True)
242
246
 
243
247
    outfile.write('\n')
258
262
    outfile.write('  %8d ignored\n' % ignore_cnt)
259
263
 
260
264
    dir_cnt = 0
261
 
    root_id = working.get_root_id()
262
 
    for path, entry in working.iter_entries_by_dir():
263
 
        if entry.kind == 'directory' and entry.file_id != root_id:
 
265
    for file_id in work_inv:
 
266
        if (work_inv.get_file_kind(file_id) == 'directory' and
 
267
            not work_inv.is_root(file_id)):
264
268
            dir_cnt += 1
265
269
    outfile.write('  %8d versioned %s\n' % (dir_cnt,
266
270
        plural(dir_cnt, 'subdirectory', 'subdirectories')))
416
420
        if branch is None and tree is not None:
417
421
            phrase = "branchless tree"
418
422
        else:
419
 
            if (tree is not None and tree.user_url !=
420
 
                branch.user_url):
 
423
            if (tree is not None and tree.bzrdir.root_transport.base !=
 
424
                branch.bzrdir.root_transport.base):
421
425
                independence = ''
422
426
                phrase = "Lightweight checkout"
423
427
            elif branch.get_bound_location() is not None:
442
446
    """
443
447
    candidates  = []
444
448
    if (branch is not None and tree is not None and
445
 
        branch.user_url != tree.user_url):
 
449
        branch.bzrdir.root_transport.base !=
 
450
        tree.bzrdir.root_transport.base):
446
451
        branch = None
447
452
        repository = None
448
453
    non_aliases = set(bzrdir.format_registry.keys())
479
484
    """Hooks for the info command."""
480
485
 
481
486
    def __init__(self):
482
 
        super(InfoHooks, self).__init__("bzrlib.info", "hooks")
483
 
        self.add_hook('repository',
 
487
        super(InfoHooks, self).__init__()
 
488
        self.create_hook(_mod_hooks.HookPoint('repository',
484
489
            "Invoked when displaying the statistics for a repository. "
485
490
            "repository is called with a statistics dictionary as returned "
486
 
            "by the repository and a file-like object to write to.", (1, 15))
 
491
            "by the repository and a file-like object to write to.", (1, 15), 
 
492
            None))
487
493
 
488
494
 
489
495
hooks = InfoHooks()