/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

  • Committer: Michael Ellerman
  • Date: 2006-03-09 00:24:48 UTC
  • mto: (1610.1.8 bzr.mbp.integration)
  • mto: This revision was merged to the branch mainline in revision 1616.
  • Revision ID: michael@ellerman.id.au-20060309002448-70cce15e3d605130
Make the "ignore line" in the commit message editor the "right" width, so
that if you make your message that wide it won't wrap in bzr log output.
Just as a visual aid.

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
__all__ = ['show_bzrdir_info']
 
20
 
 
21
import time
 
22
 
 
23
 
 
24
import bzrlib.diff as diff
 
25
from bzrlib.missing import find_unmerged
 
26
from bzrlib.osutils import format_date
 
27
from bzrlib.symbol_versioning import *
 
28
 
 
29
 
 
30
def _countiter(it):
 
31
    # surely there's a builtin for this?
 
32
    i = 0
 
33
    for j in it:
 
34
        i += 1
 
35
    return i        
 
36
 
 
37
 
 
38
@deprecated_function(zero_eight)
 
39
def show_info(b):
 
40
    """Please see show_bzrdir_info."""
 
41
    return show_bzrdir_info(b.bzrdir)
 
42
 
 
43
def show_bzrdir_info(a_bzrdir):
 
44
    """Output to stdout the 'info' for a_bzrdir."""
 
45
 
 
46
    def plural(n, base='', pl=None):
 
47
        if n == 1:
 
48
            return base
 
49
        elif pl != None:
 
50
            return pl
 
51
        else:
 
52
            return 's'
 
53
 
 
54
    working = a_bzrdir.open_workingtree()
 
55
    b = a_bzrdir.open_branch()
 
56
    
 
57
    if working.bzrdir != b.bzrdir:
 
58
        print 'working tree format:', working._format
 
59
        print 'branch location:', b.bzrdir.root_transport.base
 
60
    try:
 
61
        b._format.get_format_string()
 
62
        format = b._format
 
63
    except NotImplementedError:
 
64
        format = b.bzrdir._format
 
65
    print 'branch format:', format
 
66
 
 
67
    if b.get_bound_location():
 
68
        print 'bound to branch:',  b.get_bound_location()
 
69
 
 
70
    count_version_dirs = 0
 
71
 
 
72
    basis = working.basis_tree()
 
73
    work_inv = working.inventory
 
74
    delta = diff.compare_trees(basis, working, want_unchanged=True)
 
75
    history = b.revision_history()
 
76
    
 
77
    print
 
78
    # Try with inaccessible branch ?
 
79
    master = b.get_master_branch()
 
80
    if master:
 
81
        local_extra, remote_extra = find_unmerged(b, b.get_master_branch())
 
82
        if remote_extra:
 
83
            print 'Branch is out of date: missing %d revision%s.' % (
 
84
                len(remote_extra), plural(len(remote_extra)))
 
85
 
 
86
    if len(history) and working.last_revision() != history[-1]:
 
87
        try:
 
88
            missing_count = len(history) - history.index(working.last_revision())
 
89
        except ValueError:
 
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))
 
94
    print 'in the working tree:'
 
95
    print '  %8s unchanged' % len(delta.unchanged)
 
96
    print '  %8d modified' % len(delta.modified)
 
97
    print '  %8d added' % len(delta.added)
 
98
    print '  %8d removed' % len(delta.removed)
 
99
    print '  %8d renamed' % len(delta.renamed)
 
100
 
 
101
    ignore_cnt = unknown_cnt = 0
 
102
    for path in working.extras():
 
103
        if working.is_ignored(path):
 
104
            ignore_cnt += 1
 
105
        else:
 
106
            unknown_cnt += 1
 
107
 
 
108
    print '  %8d unknown' % unknown_cnt
 
109
    print '  %8d ignored' % ignore_cnt
 
110
 
 
111
    dir_cnt = 0
 
112
    for file_id in work_inv:
 
113
        if work_inv.get_file_kind(file_id) == 'directory':
 
114
            dir_cnt += 1
 
115
    print '  %8d versioned %s' \
 
116
          % (dir_cnt,
 
117
             plural(dir_cnt, 'subdirectory', 'subdirectories'))
 
118
 
 
119
    print
 
120
    print 'branch history:'
 
121
    revno = len(history)
 
122
    print '  %8d revision%s' % (revno, plural(revno))
 
123
    committers = {}
 
124
    for rev in history:
 
125
        committers[b.repository.get_revision(rev).committer] = True
 
126
    print '  %8d committer%s' % (len(committers), plural(len(committers)))
 
127
    if revno > 0:
 
128
        firstrev = b.repository.get_revision(history[0])
 
129
        age = int((time.time() - firstrev.timestamp) / 3600 / 24)
 
130
        print '  %8d day%s old' % (age, plural(age))
 
131
        print '   first revision: %s' % format_date(firstrev.timestamp,
 
132
                                                    firstrev.timezone)
 
133
 
 
134
        lastrev = b.repository.get_revision(history[-1])
 
135
        print '  latest revision: %s' % format_date(lastrev.timestamp,
 
136
                                                    lastrev.timezone)
 
137
 
 
138
#     print
 
139
#     print 'text store:'
 
140
#     c, t = b.text_store.total_size()
 
141
#     print '  %8d file texts' % c
 
142
#     print '  %8d kB' % (t/1024)
 
143
 
 
144
    print
 
145
    print 'revision store:'
 
146
    c, t = b.repository.revision_store.total_size()
 
147
    print '  %8d revision%s' % (c, plural(c))
 
148
    print '  %8d kB' % (t/1024)
 
149
 
 
150
 
 
151
#     print
 
152
#     print 'inventory store:'
 
153
#     c, t = b.inventory_store.total_size()
 
154
#     print '  %8d inventories' % c
 
155
#     print '  %8d kB' % (t/1024)
 
156