Correct a type and make change the value of the OPENINGS constant to 'O',
[cvs2svn.git] / profile-repos.py
blob78b6b6ecc6acd1357e3537cb0b2ba30d19256046
1 #!/usr/bin/env python
2 # ====================================================================
3 # Copyright (c) 2000-2004 CollabNet. All rights reserved.
5 # This software is licensed as described in the file COPYING, which
6 # you should have received as part of this distribution. The terms
7 # are also available at http://subversion.tigris.org/license-1.html.
8 # If newer versions of this license are posted there, you may use a
9 # newer version instead, at your option.
11 # This software consists of voluntary contributions made by many
12 # individuals. For exact contribution history, see the revision
13 # history and logs, available at http://cvs2svn.tigris.org/.
14 # ====================================================================
17 """
18 Report information about CVS revisions, tags, and branches in a CVS
19 repository by examining the results of running pass 1 of cvs2svn.py on
20 that repository. NOTE: You have to run the conversion passes
21 yourself!
22 """
24 import sys, os, os.path, string
25 from cvs2svn import CVSRevision
27 def do_it(revs_file):
28 fp = open(revs_file, 'r')
29 tags = { }
30 branches = { }
32 max_tags = 0
33 max_branches = 0
34 line_count = 0
35 total_tags = 0
36 total_branches = 0
38 while 1:
39 line_count = line_count + 1
40 line = fp.readline()
41 if not line:
42 break
44 # Get a CVSRevision to describe this line
45 c_rev = CVSRevision(None, line)
47 # Handle tags
48 num_tags = len(c_rev.tags)
49 max_tags = (num_tags > max_tags) \
50 and num_tags or max_tags
51 total_tags = total_tags + num_tags
52 for tag in c_rev.tags:
53 tags[tag] = None
55 # Handle branches
56 num_branches = len(c_rev.branches)
57 max_branches = (num_branches > max_branches) \
58 and num_branches or max_branches
59 total_branches = total_branches + num_branches
60 for branch in c_rev.branches:
61 branches[branch] = None
63 symbols = {}
64 symbols.update(tags)
65 symbols.update(branches)
67 num_symbols = len(symbols.keys())
68 num_tags = len(tags.keys())
69 num_branches = len(branches.keys())
70 avg_tags = total_tags * 1.0 / line_count
71 avg_branches = total_branches * 1.0 / line_count
73 print ' Total CVS Revisions: %d\n' \
74 ' Total Unique Tags: %d\n' \
75 ' Peak Revision Tags: %d\n' \
76 ' Avg. Tags/Revision: %2.1f\n' \
77 ' Total Unique Branches: %d\n' \
78 'Peak Revision Branches: %d\n' \
79 'Avg. Branches/Revision: %2.1f\n' \
80 ' Total Unique Symbols: %d%s\n' \
81 % (line_count,
82 num_tags,
83 max_tags,
84 avg_tags,
85 num_branches,
86 max_branches,
87 avg_branches,
88 num_symbols,
89 num_symbols == num_tags + num_branches and ' ' or ' (!)',
93 if __name__ == "__main__":
94 argc = len(sys.argv)
95 if argc < 2:
96 print 'Usage: %s /path/to/cvs2svn-data.[c-|s-|]revs' \
97 % (os.path.basename(sys.argv[0]))
98 print __doc__
99 sys.exit(0)
100 do_it(sys.argv[1])