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
19
__all__ = ['show_bzrdir_info']
23
from osutils import format_date
24
import bzrlib.diff as diff
25
from bzrlib.missing import find_unmerged
26
from bzrlib.osutils import format_date
27
from bzrlib.symbol_versioning import *
31
# surely there's a builtin for this?
38
@deprecated_function(zero_eight)
26
print 'branch format:', b.controlfile('branch-format', 'r').readline().rstrip('\n')
40
"""Please see show_bzrdir_info."""
41
return show_bzrdir_info(b.bzrdir)
43
def show_bzrdir_info(a_bzrdir):
44
"""Output to stdout the 'info' for a_bzrdir."""
28
46
def plural(n, base='', pl=None):
54
working = a_bzrdir.open_workingtree()
55
b = a_bzrdir.open_branch()
57
if working.bzrdir != b.bzrdir:
58
print 'working tree format:', working._format
59
print 'branch location:', b.bzrdir.root_transport.base
61
b._format.get_format_string()
63
except NotImplementedError:
64
format = b.bzrdir._format
65
print 'branch format:', format
67
if b.get_bound_location():
68
print 'bound to branch:', b.get_bound_location()
36
70
count_version_dirs = 0
38
count_status = {'A': 0, 'D': 0, 'M': 0, 'R': 0, '?': 0, 'I': 0, '.': 0}
39
for st_tup in bzrlib.diff_trees(b.basis_tree(), b.working_tree()):
42
if fs not in ['I', '?'] and st_tup[4] == 'directory':
43
count_version_dirs += 1
72
basis = working.basis_tree()
73
work_inv = working.inventory
74
delta = diff.compare_trees(basis, working, want_unchanged=True)
75
history = b.revision_history()
78
# Try with inaccessible branch ?
79
master = b.get_master_branch()
81
local_extra, remote_extra = find_unmerged(b, b.get_master_branch())
83
print 'Branch is out of date: missing %d revision%s.' % (
84
len(remote_extra), plural(len(remote_extra)))
86
if len(history) and working.last_revision() != history[-1]:
88
missing_count = len(history) - history.index(working.last_revision())
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))
46
94
print 'in the working tree:'
47
for name, fs in (('unchanged', '.'),
48
('modified', 'M'), ('added', 'A'), ('removed', 'D'),
49
('renamed', 'R'), ('unknown', '?'), ('ignored', 'I'),
51
print ' %8d %s' % (count_status[fs], name)
52
print ' %8d versioned subdirector%s' % (count_version_dirs,
53
plural(count_version_dirs, 'y', 'ies'))
95
print ' %8s unchanged' % len(delta.unchanged)
96
print ' %8d modified' % len(delta.modified)
97
print ' %8d added' % len(delta.added)
98
print ' %8d removed' % len(delta.removed)
99
print ' %8d renamed' % len(delta.renamed)
101
ignore_cnt = unknown_cnt = 0
102
for path in working.extras():
103
if working.is_ignored(path):
108
print ' %8d unknown' % unknown_cnt
109
print ' %8d ignored' % ignore_cnt
112
for file_id in work_inv:
113
if work_inv.get_file_kind(file_id) == 'directory':
115
print ' %8d versioned %s' \
117
plural(dir_cnt, 'subdirectory', 'subdirectories'))
56
120
print 'branch history:'
57
history = b.revision_history()
58
121
revno = len(history)
59
122
print ' %8d revision%s' % (revno, plural(revno))
61
124
for rev in history:
62
committers.add(b.get_revision(rev).committer)
125
committers[b.repository.get_revision(rev).committer] = True
63
126
print ' %8d committer%s' % (len(committers), plural(len(committers)))
65
firstrev = b.get_revision(history[0])
128
firstrev = b.repository.get_revision(history[0])
66
129
age = int((time.time() - firstrev.timestamp) / 3600 / 24)
67
130
print ' %8d day%s old' % (age, plural(age))
68
131
print ' first revision: %s' % format_date(firstrev.timestamp,
69
132
firstrev.timezone)
71
lastrev = b.get_revision(history[-1])
134
lastrev = b.repository.get_revision(history[-1])
72
135
print ' latest revision: %s' % format_date(lastrev.timestamp,
77
c, t = b.text_store.total_size()
78
print ' %8d file texts' % c
79
print ' %8d kB' % (t/1024)
139
# print 'text store:'
140
# c, t = b.text_store.total_size()
141
# print ' %8d file texts' % c
142
# print ' %8d kB' % (t/1024)
82
145
print 'revision store:'
83
c, t = b.revision_store.total_size()
84
print ' %8d revisions' % c
85
print ' %8d kB' % (t/1024)
89
print 'inventory store:'
90
c, t = b.inventory_store.total_size()
91
print ' %8d inventories' % c
92
print ' %8d kB' % (t/1024)
146
c, t = b.repository.revision_store.total_size()
147
print ' %8d revision%s' % (c, plural(c))
148
print ' %8d kB' % (t/1024)
152
# print 'inventory store:'
153
# c, t = b.inventory_store.total_size()
154
# print ' %8d inventories' % c
155
# print ' %8d kB' % (t/1024)