1
# Copyright (C) 2004, 2005 by Martin Pool
2
# Copyright (C) 2005 by Canonical Ltd
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
__all__ = ['show_bzrdir_info']
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
def plural(n, base='', pl=None):
47
@deprecated_function(zero_eight)
49
"""Please see show_bzrdir_info."""
50
return show_bzrdir_info(b.bzrdir)
53
def show_bzrdir_info(a_bzrdir):
54
"""Output to stdout the 'info' for a_bzrdir."""
56
working = a_bzrdir.open_workingtree()
59
show_tree_info(working)
64
def show_tree_info(working):
65
"""Output to stdout the 'info' for working."""
67
branch = working.branch
68
repository = branch.repository
69
control_format = working.bzrdir._format.get_format_description()
70
working_format = working._format.get_format_description()
71
branch_format = branch._format.get_format_description()
72
repository_format = repository._format.get_format_description()
75
if working.bzrdir != branch.bzrdir:
76
# Lightweight checkout
77
print ' checkout root: %s' % (
78
working.bzrdir.root_transport.base)
79
print ' checkout of branch: %s' % (
80
branch.bzrdir.root_transport.base)
82
# Standalone or bound branch (normal checkout)
83
print ' branch root: %s' % (
84
branch.bzrdir.root_transport.base)
85
if branch.get_bound_location():
86
print ' bound to branch: %s' % branch.get_bound_location()
88
if repository.bzrdir != branch.bzrdir:
89
if repository.is_shared():
90
print ' shared repository: %s' % (
91
repository.bzrdir.root_transport.base)
93
print ' repository: %s' % (
94
repository.bzrdir.root_transport.base)
96
if branch.get_parent():
97
print ' parent branch: %s' % branch.get_parent()
98
if branch.get_push_location():
99
print ' push to branch: %s' % branch.get_push_location()
103
print ' control: %s' % control_format
104
print ' working tree: %s' % working_format
105
print ' branch: %s' % branch_format
106
print ' repository: %s' % repository_format
108
basis = working.basis_tree()
109
work_inv = working.inventory
110
delta = diff.compare_trees(basis, working, want_unchanged=True)
111
history = branch.revision_history()
114
# Try with inaccessible branch ?
115
master = branch.get_master_branch()
117
local_extra, remote_extra = find_unmerged(branch, master)
119
print 'Branch is out of date: missing %d revision%s.' % (
120
len(remote_extra), plural(len(remote_extra)))
123
tree_last_id = working.last_revision()
124
if len(history) and tree_last_id != history[-1]:
125
tree_last_revno = branch.revision_id_to_revno(tree_last_id)
126
missing_count = len(history) - tree_last_revno
127
print 'Working tree is out of date: missing %d revision%s.' % (
128
missing_count, plural(missing_count))
131
print 'In the working tree:'
132
print ' %8s unchanged' % len(delta.unchanged)
133
print ' %8d modified' % len(delta.modified)
134
print ' %8d added' % len(delta.added)
135
print ' %8d removed' % len(delta.removed)
136
print ' %8d renamed' % len(delta.renamed)
138
ignore_cnt = unknown_cnt = 0
139
for path in working.extras():
140
if working.is_ignored(path):
144
print ' %8d unknown' % unknown_cnt
145
print ' %8d ignored' % ignore_cnt
148
for file_id in work_inv:
149
if work_inv.get_file_kind(file_id) == 'directory':
151
print ' %8d versioned %s' \
153
plural(dir_cnt, 'subdirectory', 'subdirectories'))
156
print 'Branch history:'
158
print ' %8d revision%s' % (revno, plural(revno))
161
committers[repository.get_revision(rev).committer] = True
162
print ' %8d committer%s' % (len(committers), plural(len(committers)))
164
firstrev = repository.get_revision(history[0])
165
age = int((time.time() - firstrev.timestamp) / 3600 / 24)
166
print ' %8d day%s old' % (age, plural(age))
167
print ' first revision: %s' % format_date(firstrev.timestamp,
170
lastrev = repository.get_revision(history[-1])
171
print ' latest revision: %s' % format_date(lastrev.timestamp,
175
# print 'Text store:'
176
# c, t = branch.text_store.total_size()
177
# print ' %8d file texts' % c
178
# print ' %8d KiB' % (t/1024)
181
print 'Revision store:'
182
c, t = repository._revision_store.total_size(repository.get_transaction())
183
print ' %8d revision%s' % (c, plural(c))
184
print ' %8d KiB' % (t/1024)
187
# print 'Inventory store:'
188
# c, t = branch.inventory_store.total_size()
189
# print ' %8d inventories' % c
190
# print ' %8d KiB' % (t/1024)