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']
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 *
24
30
def _countiter(it):
38
@deprecated_function(zero_eight)
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)
43
def show_bzrdir_info(a_bzrdir):
44
"""Output to stdout the 'info' for a_bzrdir."""
38
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()
46
70
count_version_dirs = 0
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()
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))
54
94
print 'in the working tree:'
55
95
print ' %8s unchanged' % len(delta.unchanged)
56
96
print ' %8d modified' % len(delta.modified)
80
120
print 'branch history:'
81
history = b.revision_history()
82
121
revno = len(history)
83
122
print ' %8d revision%s' % (revno, plural(revno))
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)))
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)
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,
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)