bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
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  | 
from sets import Set  | 
|
20  | 
import time  | 
|
21  | 
||
22  | 
import bzrlib  | 
|
23  | 
from osutils import format_date  | 
|
24  | 
||
25  | 
def show_info(b):  | 
|
26  | 
print 'branch format:', b.controlfile('branch-format', 'r').readline().rstrip('\n')  | 
|
27  | 
||
28  | 
def plural(n, base='', pl=None):  | 
|
29  | 
if n == 1:  | 
|
30  | 
return base  | 
|
| 
187
by mbp at sourcefrog
 fix inverted sense introduced in previous pychecker fixup  | 
31  | 
elif pl != None:  | 
| 
77
by mbp at sourcefrog
 - split info command out into separate file  | 
32  | 
return pl  | 
33  | 
else:  | 
|
34  | 
return 's'  | 
|
35  | 
||
36  | 
count_version_dirs = 0  | 
|
37  | 
||
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()):  | 
|
40  | 
fs = st_tup[0]  | 
|
41  | 
count_status[fs] += 1  | 
|
42  | 
if fs not in ['I', '?'] and st_tup[4] == 'directory':  | 
|
43  | 
count_version_dirs += 1  | 
|
44  | 
||
45  | 
    print
 | 
|
46  | 
print 'in the working tree:'  | 
|
47  | 
for name, fs in (('unchanged', '.'),  | 
|
48  | 
('modified', 'M'), ('added', 'A'), ('removed', 'D'),  | 
|
49  | 
('renamed', 'R'), ('unknown', '?'), ('ignored', 'I'),  | 
|
50  | 
                     ):
 | 
|
| 
111
by mbp at sourcefrog
 Make fields wider in 'bzr info' output to accomodate big trees  | 
51  | 
print ' %8d %s' % (count_status[fs], name)  | 
52  | 
print ' %8d versioned subdirector%s' % (count_version_dirs,  | 
|
| 
77
by mbp at sourcefrog
 - split info command out into separate file  | 
53  | 
plural(count_version_dirs, 'y', 'ies'))  | 
54  | 
||
55  | 
    print
 | 
|
56  | 
print 'branch history:'  | 
|
57  | 
history = b.revision_history()  | 
|
58  | 
revno = len(history)  | 
|
| 
111
by mbp at sourcefrog
 Make fields wider in 'bzr info' output to accomodate big trees  | 
59  | 
print ' %8d revision%s' % (revno, plural(revno))  | 
| 
77
by mbp at sourcefrog
 - split info command out into separate file  | 
60  | 
committers = Set()  | 
61  | 
for rev in history:  | 
|
62  | 
committers.add(b.get_revision(rev).committer)  | 
|
| 
111
by mbp at sourcefrog
 Make fields wider in 'bzr info' output to accomodate big trees  | 
63  | 
print ' %8d committer%s' % (len(committers), plural(len(committers)))  | 
| 
77
by mbp at sourcefrog
 - split info command out into separate file  | 
64  | 
if revno > 0:  | 
65  | 
firstrev = b.get_revision(history[0])  | 
|
66  | 
age = int((time.time() - firstrev.timestamp) / 3600 / 24)  | 
|
| 
111
by mbp at sourcefrog
 Make fields wider in 'bzr info' output to accomodate big trees  | 
67  | 
print ' %8d day%s old' % (age, plural(age))  | 
| 
78
by mbp at sourcefrog
 align fields in info output  | 
68  | 
print ' first revision: %s' % format_date(firstrev.timestamp,  | 
69  | 
firstrev.timezone)  | 
|
| 
77
by mbp at sourcefrog
 - split info command out into separate file  | 
70  | 
|
71  | 
lastrev = b.get_revision(history[-1])  | 
|
72  | 
print ' latest revision: %s' % format_date(lastrev.timestamp,  | 
|
73  | 
lastrev.timezone)  | 
|
| 
80
by mbp at sourcefrog
 show_info: Show number of entries in the branch stores  | 
74  | 
|
75  | 
    print
 | 
|
76  | 
print 'text store:'  | 
|
| 
81
by mbp at sourcefrog
 show space usage for various stores in the info command  | 
77  | 
c, t = b.text_store.total_size()  | 
| 
111
by mbp at sourcefrog
 Make fields wider in 'bzr info' output to accomodate big trees  | 
78  | 
print ' %8d file texts' % c  | 
79  | 
print ' %8d kB' % (t/1024)  | 
|
| 
80
by mbp at sourcefrog
 show_info: Show number of entries in the branch stores  | 
80  | 
|
81  | 
    print
 | 
|
82  | 
print 'revision store:'  | 
|
| 
81
by mbp at sourcefrog
 show space usage for various stores in the info command  | 
83  | 
c, t = b.revision_store.total_size()  | 
| 
111
by mbp at sourcefrog
 Make fields wider in 'bzr info' output to accomodate big trees  | 
84  | 
print ' %8d revisions' % c  | 
85  | 
print ' %8d kB' % (t/1024)  | 
|
| 
81
by mbp at sourcefrog
 show space usage for various stores in the info command  | 
86  | 
|
| 
80
by mbp at sourcefrog
 show_info: Show number of entries in the branch stores  | 
87  | 
|
88  | 
    print
 | 
|
89  | 
print 'inventory store:'  | 
|
| 
81
by mbp at sourcefrog
 show space usage for various stores in the info command  | 
90  | 
c, t = b.inventory_store.total_size()  | 
| 
111
by mbp at sourcefrog
 Make fields wider in 'bzr info' output to accomodate big trees  | 
91  | 
print ' %8d inventories' % c  | 
92  | 
print ' %8d kB' % (t/1024)  | 
|
| 
81
by mbp at sourcefrog
 show space usage for various stores in the info command  | 
93  |