~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/info.py

  • Committer: Martin Pool
  • Date: 2005-08-25 05:58:05 UTC
  • mfrom: (974.1.36)
  • Revision ID: mbp@sourcefrog.net-20050825055805-8c892bc3c2d75131
- merge aaron's merge improvements:

  * When merging, pull in all missing revisions from the source
    branch. 

  * Detect common ancestors by looking at the whole ancestry graph, 
    rather than just mainline history.

  Some changes to reconcile this with parallel updates to the test and
  trace code.

aaron.bentley@utoronto.ca-20050823052551-f3401a8b57d9126f

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
18
18
 
19
 
from sets import Set
20
19
import time
21
20
 
22
 
import bzrlib
23
21
from osutils import format_date
24
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
 
25
33
def show_info(b):
26
 
    # TODO: Maybe show space used by working tree, versioned files,
27
 
    # unknown files, text store.
 
34
    import diff
28
35
    
29
36
    print 'branch format:', b.controlfile('branch-format', 'r').readline().rstrip('\n')
30
37
 
31
38
    def plural(n, base='', pl=None):
32
39
        if n == 1:
33
40
            return base
34
 
        elif pl is not None:
 
41
        elif pl != None:
35
42
            return pl
36
43
        else:
37
44
            return 's'
38
45
 
39
46
    count_version_dirs = 0
40
47
 
41
 
    count_status = {'A': 0, 'D': 0, 'M': 0, 'R': 0, '?': 0, 'I': 0, '.': 0}
42
 
    for st_tup in bzrlib.diff_trees(b.basis_tree(), b.working_tree()):
43
 
        fs = st_tup[0]
44
 
        count_status[fs] += 1
45
 
        if fs not in ['I', '?'] and st_tup[4] == 'directory':
46
 
            count_version_dirs += 1
47
 
 
 
48
    basis = b.basis_tree()
 
49
    working = b.working_tree()
 
50
    work_inv = working.inventory
 
51
    delta = diff.compare_trees(basis, working, want_unchanged=True)
 
52
    
48
53
    print
49
54
    print 'in the working tree:'
50
 
    for name, fs in (('unchanged', '.'),
51
 
                     ('modified', 'M'), ('added', 'A'), ('removed', 'D'),
52
 
                     ('renamed', 'R'), ('unknown', '?'), ('ignored', 'I'),
53
 
                     ):
54
 
        print '  %8d %s' % (count_status[fs], name)
55
 
    print '  %8d versioned subdirector%s' % (count_version_dirs,
56
 
                                             plural(count_version_dirs, 'y', 'ies'))
 
55
    print '  %8s unchanged' % len(delta.unchanged)
 
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'))
57
78
 
58
79
    print
59
80
    print 'branch history:'
60
81
    history = b.revision_history()
61
82
    revno = len(history)
62
83
    print '  %8d revision%s' % (revno, plural(revno))
63
 
    committers = Set()
 
84
    committers = {}
64
85
    for rev in history:
65
 
        committers.add(b.get_revision(rev).committer)
 
86
        committers[b.get_revision(rev).committer] = True
66
87
    print '  %8d committer%s' % (len(committers), plural(len(committers)))
67
88
    if revno > 0:
68
89
        firstrev = b.get_revision(history[0])