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."""
69
if working.bzrdir != b.bzrdir:
70
print 'working tree format:', working._format
71
print 'branch location:', b.bzrdir.root_transport.base
73
b._format.get_format_string()
75
except NotImplementedError:
76
format = b.bzrdir._format
77
print 'branch format:', format
79
if b.get_bound_location():
80
print 'bound to branch:', b.get_bound_location()
82
count_version_dirs = 0
84
basis = working.basis_tree()
85
work_inv = working.inventory
86
delta = diff.compare_trees(basis, working, want_unchanged=True)
87
history = b.revision_history()
49
def _show_location_info(repository=None, branch=None, working=None):
50
"""Show known locations for working, branch and repository."""
52
if working and branch and working.bzrdir != branch.bzrdir:
53
# Lightweight checkout
54
print ' checkout root: %s' % (
55
working.bzrdir.root_transport.base)
56
print ' checkout of branch: %s' % (
57
branch.bzrdir.root_transport.base)
59
# Standalone or bound branch (normal checkout)
60
print ' branch root: %s' % (
61
branch.bzrdir.root_transport.base)
62
if branch.get_bound_location():
63
print ' bound to branch: %s' % branch.get_bound_location()
65
if repository and (not branch or repository.bzrdir != branch.bzrdir):
66
if repository.is_shared():
67
print ' shared repository: %s' % (
68
repository.bzrdir.root_transport.base)
70
print ' repository: %s' % (
71
repository.bzrdir.root_transport.base)
74
if branch.get_parent():
75
print ' parent branch: %s' % branch.get_parent()
76
if branch.get_push_location():
77
print ' push to branch: %s' % branch.get_push_location()
80
def _show_format_info(control=None, repository=None, branch=None, working=None):
81
"""Show known formats for control, working, branch and repository."""
85
print ' control: %s' % control._format.get_format_description()
87
print ' working tree: %s' % working._format.get_format_description()
89
print ' branch: %s' % branch._format.get_format_description()
91
print ' repository: %s' % repository._format.get_format_description()
94
def _show_missing_revisions_branch(branch):
95
"""Show missing master revisions in branch."""
90
96
# Try with inaccessible branch ?
91
master = b.get_master_branch()
97
master = branch.get_master_branch()
93
local_extra, remote_extra = find_unmerged(b, b.get_master_branch())
99
local_extra, remote_extra = find_unmerged(branch, master)
95
102
print 'Branch is out of date: missing %d revision%s.' % (
96
103
len(remote_extra), plural(len(remote_extra)))
98
if len(history) and working.last_revision() != history[-1]:
100
missing_count = len(history) - history.index(working.last_revision())
102
# consider it all out of date
103
missing_count = len(history)
106
def _show_missing_revisions_working(working):
107
"""Show missing revisions in working tree."""
108
branch = working.branch
109
basis = working.basis_tree()
110
work_inv = working.inventory
111
delta = diff.compare_trees(basis, working, want_unchanged=True)
112
history = branch.revision_history()
113
tree_last_id = working.last_revision()
115
if len(history) and tree_last_id != history[-1]:
116
tree_last_revno = branch.revision_id_to_revno(tree_last_id)
117
missing_count = len(history) - tree_last_revno
104
119
print 'Working tree is out of date: missing %d revision%s.' % (
105
120
missing_count, plural(missing_count))
106
print 'in the working tree:'
123
def _show_working_stats(working):
124
"""Show statistics about a working tree."""
125
basis = working.basis_tree()
126
work_inv = working.inventory
127
delta = diff.compare_trees(basis, working, want_unchanged=True)
130
print 'In the working tree:'
107
131
print ' %8s unchanged' % len(delta.unchanged)
108
132
print ' %8d modified' % len(delta.modified)
109
133
print ' %8d added' % len(delta.added)
129
152
plural(dir_cnt, 'subdirectory', 'subdirectories'))
155
def _show_branch_stats(branch, verbose):
156
"""Show statistics about a branch."""
157
repository = branch.repository
158
history = branch.revision_history()
132
print 'branch history:'
161
print 'Branch history:'
133
162
revno = len(history)
134
163
print ' %8d revision%s' % (revno, plural(revno))
137
committers[b.repository.get_revision(rev).committer] = True
138
print ' %8d committer%s' % (len(committers), plural(len(committers)))
167
committers[repository.get_revision(rev).committer] = True
168
print ' %8d committer%s' % (len(committers), plural(len(committers)))
140
firstrev = b.repository.get_revision(history[0])
170
firstrev = repository.get_revision(history[0])
141
171
age = int((time.time() - firstrev.timestamp) / 3600 / 24)
142
172
print ' %8d day%s old' % (age, plural(age))
143
173
print ' first revision: %s' % format_date(firstrev.timestamp,
144
174
firstrev.timezone)
146
lastrev = b.repository.get_revision(history[-1])
176
lastrev = repository.get_revision(history[-1])
147
177
print ' latest revision: %s' % format_date(lastrev.timestamp,
148
178
lastrev.timezone)
151
# print 'text store:'
152
# c, t = b.text_store.total_size()
181
# print 'Text store:'
182
# c, t = branch.text_store.total_size()
153
183
# print ' %8d file texts' % c
154
# print ' %8d kB' % (t/1024)
157
print 'revision store:'
158
c, t = b.repository._revision_store.total_size(b.repository.get_transaction())
159
print ' %8d revision%s' % (c, plural(c))
160
print ' %8d kB' % (t/1024)
184
# print ' %8d KiB' % (t/1024)
164
# print 'inventory store:'
165
# c, t = b.inventory_store.total_size()
187
# print 'Inventory store:'
188
# c, t = branch.inventory_store.total_size()
166
189
# print ' %8d inventories' % c
167
# print ' %8d kB' % (t/1024)
172
print 'parent location:'
190
# print ' %8d KiB' % (t/1024)
193
def _show_repository_info(repository):
194
"""Show settings of a repository."""
195
if repository.make_working_trees():
197
print 'Create working tree for new branches inside the repository.'
200
def _show_repository_stats(repository):
201
"""Show statistics about a repository."""
202
if repository.bzrdir.root_transport.listable():
204
print 'Revision store:'
205
c, t = repository._revision_store.total_size(repository.get_transaction())
206
print ' %8d revision%s' % (c, plural(c))
207
print ' %8d KiB' % (t/1024)
210
@deprecated_function(zero_eight)
212
"""Please see show_bzrdir_info."""
213
return show_bzrdir_info(b.bzrdir)
216
def show_bzrdir_info(a_bzrdir, verbose=False):
217
"""Output to stdout the 'info' for a_bzrdir."""
219
working = a_bzrdir.open_workingtree()
222
show_tree_info(working, verbose)
226
except (NoWorkingTree, NotLocalUrl):
230
branch = a_bzrdir.open_branch()
233
show_branch_info(branch, verbose)
237
except NotBranchError:
241
repository = a_bzrdir.open_repository()
242
repository.lock_read()
244
show_repository_info(repository, verbose)
248
except NoRepositoryPresent:
251
# Return silently, cmd_info returns NotBranchError if no bzrdir
255
def show_tree_info(working, verbose):
256
"""Output to stdout the 'info' for working."""
257
branch = working.branch
258
repository = branch.repository
259
control = working.bzrdir
261
_show_location_info(repository, branch, working)
262
_show_format_info(control, repository, branch, working)
263
_show_missing_revisions_branch(branch)
264
_show_missing_revisions_working(working)
265
_show_working_stats(working)
266
_show_branch_stats(branch, verbose)
267
_show_repository_stats(repository)
270
def show_branch_info(branch, verbose):
271
"""Output to stdout the 'info' for branch."""
272
repository = branch.repository
273
control = branch.bzrdir
275
_show_location_info(repository, branch)
276
_show_format_info(control, repository, branch)
277
_show_missing_revisions_branch(branch)
278
_show_branch_stats(branch, verbose)
279
_show_repository_stats(repository)
282
def show_repository_info(repository, verbose):
283
"""Output to stdout the 'info' for branch."""
284
control = repository.bzrdir
286
_show_location_info(repository)
287
_show_format_info(control, repository)
288
_show_repository_info(repository)
289
_show_repository_stats(repository)