Fix handling of "branch ;" in RCS file.
[cvs2svn.git] / dump-db.py
blob723b96e5bf61709e4795f415b31a9c5c07ec4111
1 #!/usr/bin/env python2
3 import anydbm
4 import marshal
5 import sys
6 import os.path
9 def usage():
10 cmd = sys.argv[0]
11 sys.stderr.write("Usage: %s DBFILE [...]\n\n" % os.path.basename(cmd))
12 sys.stderr.write("Dump .db database files created by cvs2svn.\n")
13 sys.exit(1)
16 def main():
17 argc = len(sys.argv)
18 if argc < 2:
19 usage()
20 for db_file in sys.argv[1:]:
21 print '*** ' + db_file + ' ***'
22 print ''
23 db = anydbm.open(db_file, 'r')
24 keys = db.keys()
25 keys.sort()
26 longest_len = 0
27 for key in keys:
28 this_len = len(key)
29 if this_len > longest_len:
30 longest_len = this_len
31 for key in keys:
32 this_len = len(key)
33 # We usually don't store raw values that happen to look like
34 # marshalled data, so this is reliable enough.
35 try:
36 value = str(marshal.loads(db[key]))
37 except:
38 value = db[key]
39 print ' ' * (longest_len - this_len) + key + ' : ' + value
40 print ''
42 if __name__ == "__main__":
43 main()