~ubuntu-branches/ubuntu/lucid/bzr/lucid-proposed

« back to all changes in this revision

Viewing changes to bzrlib/info.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeff Bailey
  • Date: 2006-03-20 08:31:00 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060320083100-ovdi2ssuw0epcx8s
Tags: 0.8~200603200831-0ubuntu1
* Snapshot uploaded to Dapper at Martin Pool's request.

* Disable testsuite for upload.  Fakeroot and the testsuite don't
  play along.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
 
19
__all__ = ['show_bzrdir_info']
 
20
 
19
21
import time
20
22
 
 
23
 
 
24
import bzrlib.diff as diff
 
25
from bzrlib.missing import find_unmerged
21
26
from bzrlib.osutils import format_date
 
27
from bzrlib.symbol_versioning import *
22
28
 
23
29
 
24
30
def _countiter(it):
29
35
    return i        
30
36
 
31
37
 
32
 
 
 
38
@deprecated_function(zero_eight)
33
39
def show_info(b):
34
 
    import diff
35
 
    
36
 
    print 'branch format:', b.controlfile('branch-format', 'r').readline().rstrip('\n')
 
40
    """Please see show_bzrdir_info."""
 
41
    return show_bzrdir_info(b.bzrdir)
 
42
 
 
43
def show_bzrdir_info(a_bzrdir):
 
44
    """Output to stdout the 'info' for a_bzrdir."""
37
45
 
38
46
    def plural(n, base='', pl=None):
39
47
        if n == 1:
43
51
        else:
44
52
            return 's'
45
53
 
 
54
    working = a_bzrdir.open_workingtree()
 
55
    b = a_bzrdir.open_branch()
 
56
    
 
57
    if working.bzrdir != b.bzrdir:
 
58
        print 'working tree format:', working._format
 
59
        print 'branch location:', b.bzrdir.root_transport.base
 
60
    try:
 
61
        b._format.get_format_string()
 
62
        format = b._format
 
63
    except NotImplementedError:
 
64
        format = b.bzrdir._format
 
65
    print 'branch format:', format
 
66
 
 
67
    if b.get_bound_location():
 
68
        print 'bound to branch:',  b.get_bound_location()
 
69
 
46
70
    count_version_dirs = 0
47
71
 
48
 
    basis = b.basis_tree()
49
 
    working = b.working_tree()
 
72
    basis = working.basis_tree()
50
73
    work_inv = working.inventory
51
74
    delta = diff.compare_trees(basis, working, want_unchanged=True)
 
75
    history = b.revision_history()
52
76
    
53
77
    print
 
78
    # Try with inaccessible branch ?
 
79
    master = b.get_master_branch()
 
80
    if master:
 
81
        local_extra, remote_extra = find_unmerged(b, b.get_master_branch())
 
82
        if remote_extra:
 
83
            print 'Branch is out of date: missing %d revision%s.' % (
 
84
                len(remote_extra), plural(len(remote_extra)))
 
85
 
 
86
    if len(history) and working.last_revision() != history[-1]:
 
87
        try:
 
88
            missing_count = len(history) - history.index(working.last_revision())
 
89
        except ValueError:
 
90
            # consider it all out of date
 
91
            missing_count = len(history)
 
92
        print 'Working tree is out of date: missing %d revision%s.' % (
 
93
            missing_count, plural(missing_count))
54
94
    print 'in the working tree:'
55
95
    print '  %8s unchanged' % len(delta.unchanged)
56
96
    print '  %8d modified' % len(delta.modified)
78
118
 
79
119
    print
80
120
    print 'branch history:'
81
 
    history = b.revision_history()
82
121
    revno = len(history)
83
122
    print '  %8d revision%s' % (revno, plural(revno))
84
123
    committers = {}
85
124
    for rev in history:
86
 
        committers[b.get_revision(rev).committer] = True
 
125
        committers[b.repository.get_revision(rev).committer] = True
87
126
    print '  %8d committer%s' % (len(committers), plural(len(committers)))
88
127
    if revno > 0:
89
 
        firstrev = b.get_revision(history[0])
 
128
        firstrev = b.repository.get_revision(history[0])
90
129
        age = int((time.time() - firstrev.timestamp) / 3600 / 24)
91
130
        print '  %8d day%s old' % (age, plural(age))
92
131
        print '   first revision: %s' % format_date(firstrev.timestamp,
93
132
                                                    firstrev.timezone)
94
133
 
95
 
        lastrev = b.get_revision(history[-1])
 
134
        lastrev = b.repository.get_revision(history[-1])
96
135
        print '  latest revision: %s' % format_date(lastrev.timestamp,
97
136
                                                    lastrev.timezone)
98
137
 
104
143
 
105
144
    print
106
145
    print 'revision store:'
107
 
    c, t = b.revision_store.total_size()
108
 
    print '  %8d revisions' % c
 
146
    c, t = b.repository.revision_store.total_size()
 
147
    print '  %8d revision%s' % (c, plural(c))
109
148
    print '  %8d kB' % (t/1024)
110
149
 
111
150