~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: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

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