~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/info.py

  • Committer: Martin Pool
  • Date: 2005-05-17 07:01:47 UTC
  • Revision ID: mbp@sourcefrog.net-20050517070147-c38da17418ea6711
- Add patch to give symlink support

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from sets import Set
20
20
import time
21
21
 
22
 
import bzrlib
23
22
from osutils import format_date
24
23
 
 
24
 
 
25
def _countiter(it):
 
26
    # surely there's a builtin for this?
 
27
    i = 0
 
28
    for j in it:
 
29
        i += 1
 
30
    return i        
 
31
 
 
32
 
 
33
 
25
34
def show_info(b):
26
 
    # TODO: Maybe show space used by working tree, versioned files,
27
 
    # unknown files, text store.
 
35
    import diff
28
36
    
29
37
    print 'branch format:', b.controlfile('branch-format', 'r').readline().rstrip('\n')
30
38
 
31
39
    def plural(n, base='', pl=None):
32
40
        if n == 1:
33
41
            return base
34
 
        elif pl is not None:
 
42
        elif pl != None:
35
43
            return pl
36
44
        else:
37
45
            return 's'
38
46
 
39
47
    count_version_dirs = 0
40
48
 
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
 
 
 
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
    
48
54
    print
49
55
    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'))
 
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'))
57
79
 
58
80
    print
59
81
    print 'branch history:'