77
by mbp at sourcefrog
- split info command out into separate file |
1 |
# Copyright (C) 2004, 2005 by Martin Pool
|
2 |
# Copyright (C) 2005 by Canonical Ltd
|
|
3 |
||
4 |
||
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.
|
|
9 |
||
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.
|
|
14 |
||
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
|
|
18 |
||
19 |
import time |
|
20 |
||
21 |
from osutils import format_date |
|
22 |
||
462
by Martin Pool
- New form 'file_id in tree' to check if the file is present |
23 |
|
24 |
def _countiter(it): |
|
25 |
# surely there's a builtin for this?
|
|
26 |
i = 0 |
|
27 |
for j in it: |
|
28 |
i += 1 |
|
29 |
return i |
|
30 |
||
31 |
||
32 |
||
77
by mbp at sourcefrog
- split info command out into separate file |
33 |
def show_info(b): |
462
by Martin Pool
- New form 'file_id in tree' to check if the file is present |
34 |
import diff |
35 |
||
77
by mbp at sourcefrog
- split info command out into separate file |
36 |
print 'branch format:', b.controlfile('branch-format', 'r').readline().rstrip('\n') |
37 |
||
38 |
def plural(n, base='', pl=None): |
|
39 |
if n == 1: |
|
40 |
return base |
|
187
by mbp at sourcefrog
fix inverted sense introduced in previous pychecker fixup |
41 |
elif pl != None: |
77
by mbp at sourcefrog
- split info command out into separate file |
42 |
return pl |
43 |
else: |
|
44 |
return 's' |
|
45 |
||
46 |
count_version_dirs = 0 |
|
47 |
||
462
by Martin Pool
- New form 'file_id in tree' to check if the file is present |
48 |
basis = b.basis_tree() |
49 |
working = b.working_tree() |
|
50 |
work_inv = working.inventory |
|
470
by Martin Pool
- remove dead code for cmd_compare_trees |
51 |
delta = diff.compare_trees(basis, working, want_unchanged=True) |
462
by Martin Pool
- New form 'file_id in tree' to check if the file is present |
52 |
|
77
by mbp at sourcefrog
- split info command out into separate file |
53 |
print
|
54 |
print 'in the working tree:' |
|
463
by Martin Pool
- compare_trees() also reports unchanged files |
55 |
print ' %8s unchanged' % len(delta.unchanged) |
462
by Martin Pool
- New form 'file_id in tree' to check if the file is present |
56 |
print ' %8d modified' % len(delta.modified) |
57 |
print ' %8d added' % len(delta.added) |
|
58 |
print ' %8d removed' % len(delta.removed) |
|
59 |
print ' %8d renamed' % len(delta.renamed) |
|
60 |
||
61 |
ignore_cnt = unknown_cnt = 0 |
|
62 |
for path in working.extras(): |
|
63 |
if working.is_ignored(path): |
|
64 |
ignore_cnt += 1 |
|
65 |
else: |
|
66 |
unknown_cnt += 1 |
|
67 |
||
68 |
print ' %8d unknown' % unknown_cnt |
|
69 |
print ' %8d ignored' % ignore_cnt |
|
70 |
||
71 |
dir_cnt = 0 |
|
72 |
for file_id in work_inv: |
|
73 |
if work_inv.get_file_kind(file_id) == 'directory': |
|
74 |
dir_cnt += 1 |
|
75 |
print ' %8d versioned %s' \ |
|
76 |
% (dir_cnt, |
|
77 |
plural(dir_cnt, 'subdirectory', 'subdirectories')) |
|
77
by mbp at sourcefrog
- split info command out into separate file |
78 |
|
79 |
print
|
|
80 |
print 'branch history:' |
|
81 |
history = b.revision_history() |
|
82 |
revno = len(history) |
|
111
by mbp at sourcefrog
Make fields wider in 'bzr info' output to accomodate big trees |
83 |
print ' %8d revision%s' % (revno, plural(revno)) |
540
by Martin Pool
- use builtin set object in python2.4 |
84 |
committers = {} |
77
by mbp at sourcefrog
- split info command out into separate file |
85 |
for rev in history: |
542
by Martin Pool
- fix typo |
86 |
committers[b.get_revision(rev).committer] = True |
111
by mbp at sourcefrog
Make fields wider in 'bzr info' output to accomodate big trees |
87 |
print ' %8d committer%s' % (len(committers), plural(len(committers))) |
77
by mbp at sourcefrog
- split info command out into separate file |
88 |
if revno > 0: |
89 |
firstrev = b.get_revision(history[0]) |
|
90 |
age = int((time.time() - firstrev.timestamp) / 3600 / 24) |
|
111
by mbp at sourcefrog
Make fields wider in 'bzr info' output to accomodate big trees |
91 |
print ' %8d day%s old' % (age, plural(age)) |
78
by mbp at sourcefrog
align fields in info output |
92 |
print ' first revision: %s' % format_date(firstrev.timestamp, |
93 |
firstrev.timezone) |
|
77
by mbp at sourcefrog
- split info command out into separate file |
94 |
|
95 |
lastrev = b.get_revision(history[-1]) |
|
96 |
print ' latest revision: %s' % format_date(lastrev.timestamp, |
|
97 |
lastrev.timezone) |
|
80
by mbp at sourcefrog
show_info: Show number of entries in the branch stores |
98 |
|
99 |
print
|
|
100 |
print 'text store:' |
|
81
by mbp at sourcefrog
show space usage for various stores in the info command |
101 |
c, t = b.text_store.total_size() |
111
by mbp at sourcefrog
Make fields wider in 'bzr info' output to accomodate big trees |
102 |
print ' %8d file texts' % c |
103 |
print ' %8d kB' % (t/1024) |
|
80
by mbp at sourcefrog
show_info: Show number of entries in the branch stores |
104 |
|
105 |
print
|
|
106 |
print 'revision store:' |
|
81
by mbp at sourcefrog
show space usage for various stores in the info command |
107 |
c, t = b.revision_store.total_size() |
111
by mbp at sourcefrog
Make fields wider in 'bzr info' output to accomodate big trees |
108 |
print ' %8d revisions' % c |
109 |
print ' %8d kB' % (t/1024) |
|
81
by mbp at sourcefrog
show space usage for various stores in the info command |
110 |
|
80
by mbp at sourcefrog
show_info: Show number of entries in the branch stores |
111 |
|
112 |
print
|
|
113 |
print 'inventory store:' |
|
81
by mbp at sourcefrog
show space usage for various stores in the info command |
114 |
c, t = b.inventory_store.total_size() |
111
by mbp at sourcefrog
Make fields wider in 'bzr info' output to accomodate big trees |
115 |
print ' %8d inventories' % c |
116 |
print ' %8d kB' % (t/1024) |
|
81
by mbp at sourcefrog
show space usage for various stores in the info command |
117 |