Added method PersistenceManager.put_svn_commit().
[cvs2svn.git] / profile-repos.py
blob6f0b9f9d89af3ff6f0c830b401730d34d5225d7d
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 on
20 that repository. NOTE: You have to run the conversion passes
21 yourself!
22 """
24 import sys, os, os.path, string
26 # Fix things so we can import cvs2svn despite it not having a .py extension
27 import imp
28 imp.load_module('cvs2svn', open('cvs2svn', 'r'), 'cvs2svn',
29 ('', 'r', imp.PY_SOURCE))
31 from cvs2svn import CVSRevision
33 def do_it(revs_file):
34 fp = open(revs_file, 'r')
35 tags = { }
36 branches = { }
38 max_tags = 0
39 max_branches = 0
40 line_count = 0
41 total_tags = 0
42 total_branches = 0
44 while 1:
45 line_count = line_count + 1
46 line = fp.readline()
47 if not line:
48 break
50 # Get a CVSRevision to describe this line
51 c_rev = CVSRevision(None, line)
53 # Handle tags
54 num_tags = len(c_rev.tags)
55 max_tags = (num_tags > max_tags) \
56 and num_tags or max_tags
57 total_tags = total_tags + num_tags
58 for tag in c_rev.tags:
59 tags[tag] = None
61 # Handle branches
62 num_branches = len(c_rev.branches)
63 max_branches = (num_branches > max_branches) \
64 and num_branches or max_branches
65 total_branches = total_branches + num_branches
66 for branch in c_rev.branches:
67 branches[branch] = None
69 symbols = {}
70 symbols.update(tags)
71 symbols.update(branches)
73 num_symbols = len(symbols.keys())
74 num_tags = len(tags.keys())
75 num_branches = len(branches.keys())
76 avg_tags = total_tags * 1.0 / line_count
77 avg_branches = total_branches * 1.0 / line_count
79 print ' Total CVS Revisions: %d\n' \
80 ' Total Unique Tags: %d\n' \
81 ' Peak Revision Tags: %d\n' \
82 ' Avg. Tags/Revision: %2.1f\n' \
83 ' Total Unique Branches: %d\n' \
84 'Peak Revision Branches: %d\n' \
85 'Avg. Branches/Revision: %2.1f\n' \
86 ' Total Unique Symbols: %d%s\n' \
87 % (line_count,
88 num_tags,
89 max_tags,
90 avg_tags,
91 num_branches,
92 max_branches,
93 avg_branches,
94 num_symbols,
95 num_symbols == num_tags + num_branches and ' ' or ' (!)',
99 if __name__ == "__main__":
100 argc = len(sys.argv)
101 if argc < 2:
102 print 'Usage: %s /path/to/cvs2svn-data.[c-|s-|]revs' \
103 % (os.path.basename(sys.argv[0]))
104 print __doc__
105 sys.exit(0)
106 do_it(sys.argv[1])