/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/info.py

 * The internal storage of history, and logical branch identity have now
   been split into Branch, and Repository. The common locking and file 
   management routines are now in bzrlib.lockablefiles. 
   (Aaron Bentley, Robert Collins, Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 bzrlib.osutils import format_date
 
22
 
 
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
 
 
33
def show_info(b):
 
34
    import diff
 
35
    
 
36
    print 'branch format:', b.control_files.get_utf8(
 
37
        'branch-format').readline().rstrip('\n')
 
38
 
 
39
    def plural(n, base='', pl=None):
 
40
        if n == 1:
 
41
            return base
 
42
        elif pl != None:
 
43
            return pl
 
44
        else:
 
45
            return 's'
 
46
 
 
47
    count_version_dirs = 0
 
48
 
 
49
    basis = b.basis_tree()
 
50
    working = b.working_tree()
 
51
    work_inv = working.inventory
 
52
    delta = diff.compare_trees(basis, working, want_unchanged=True)
 
53
    
 
54
    print
 
55
    print 'in the working tree:'
 
56
    print '  %8s unchanged' % len(delta.unchanged)
 
57
    print '  %8d modified' % len(delta.modified)
 
58
    print '  %8d added' % len(delta.added)
 
59
    print '  %8d removed' % len(delta.removed)
 
60
    print '  %8d renamed' % len(delta.renamed)
 
61
 
 
62
    ignore_cnt = unknown_cnt = 0
 
63
    for path in working.extras():
 
64
        if working.is_ignored(path):
 
65
            ignore_cnt += 1
 
66
        else:
 
67
            unknown_cnt += 1
 
68
 
 
69
    print '  %8d unknown' % unknown_cnt
 
70
    print '  %8d ignored' % ignore_cnt
 
71
 
 
72
    dir_cnt = 0
 
73
    for file_id in work_inv:
 
74
        if work_inv.get_file_kind(file_id) == 'directory':
 
75
            dir_cnt += 1
 
76
    print '  %8d versioned %s' \
 
77
          % (dir_cnt,
 
78
             plural(dir_cnt, 'subdirectory', 'subdirectories'))
 
79
 
 
80
    print
 
81
    print 'branch history:'
 
82
    history = b.revision_history()
 
83
    revno = len(history)
 
84
    print '  %8d revision%s' % (revno, plural(revno))
 
85
    committers = {}
 
86
    for rev in history:
 
87
        committers[b.repository.get_revision(rev).committer] = True
 
88
    print '  %8d committer%s' % (len(committers), plural(len(committers)))
 
89
    if revno > 0:
 
90
        firstrev = b.repository.get_revision(history[0])
 
91
        age = int((time.time() - firstrev.timestamp) / 3600 / 24)
 
92
        print '  %8d day%s old' % (age, plural(age))
 
93
        print '   first revision: %s' % format_date(firstrev.timestamp,
 
94
                                                    firstrev.timezone)
 
95
 
 
96
        lastrev = b.repository.get_revision(history[-1])
 
97
        print '  latest revision: %s' % format_date(lastrev.timestamp,
 
98
                                                    lastrev.timezone)
 
99
 
 
100
#     print
 
101
#     print 'text store:'
 
102
#     c, t = b.text_store.total_size()
 
103
#     print '  %8d file texts' % c
 
104
#     print '  %8d kB' % (t/1024)
 
105
 
 
106
    print
 
107
    print 'revision store:'
 
108
    c, t = b.repository.revision_store.total_size()
 
109
    print '  %8d revisions' % c
 
110
    print '  %8d kB' % (t/1024)
 
111
 
 
112
 
 
113
#     print
 
114
#     print 'inventory store:'
 
115
#     c, t = b.inventory_store.total_size()
 
116
#     print '  %8d inventories' % c
 
117
#     print '  %8d kB' % (t/1024)
 
118