Reorganize the output to "svnserve --help".
[svn.git] / tools / bdb / whatis-rep.py
blobf49a7f0972331ef1845dcc25500976244b042071
1 #!/usr/bin/env python
3 # Print a description (including data, path, and revision) of the
4 # specified node reps in a Subversion filesystem. Walks as much of
5 # the reps table as necessary to locate the data (e.g. does a table
6 # scan).
8 # Standard modules
9 import sys, os, re, codecs
11 # Local support modules
12 import skel, svnfs
14 def main():
15 progname = os.path.basename(sys.argv[0])
16 if len(sys.argv) >= 3:
17 dbhome = os.path.join(sys.argv[1], 'db')
18 if not os.path.exists(dbhome):
19 sys.stderr.write("%s: '%s' is not a valid svn repository\n" %
20 (sys.argv[0], dbhome))
21 sys.exit(1)
22 rep_ids = sys.argv[2:]
23 else:
24 print >> sys.stderr, "Usage: %s <svn-repository> <rep-id>..." % progname
25 sys.exit(1)
27 print "%s running on repository '%s'" % (progname, dbhome)
28 print
29 rep_ids = dict.fromkeys(rep_ids)
30 ctx = svnfs.Ctx(dbhome)
31 try:
32 cur = ctx.nodes_db.cursor()
33 try:
34 rec = cur.first()
35 while rec:
36 if rec[0] != 'next-key':
37 nid, cid, tid = rec[0].split(".")
38 nd = skel.Node(rec[1])
39 if nd.datarep in rep_ids:
40 rev = skel.Txn(ctx.txns_db[tid]).rev
41 print "%s: data of '%s%s' in r%s" % (nd.datarep,
42 nd.createpath, {"dir":'/', "file":''}[nd.kind], rev)
43 if nd.proprep in rep_ids:
44 rev = skel.Txn(ctx.txns_db[tid]).rev
45 print "%s: properties of '%s%s' in r%s" % (nd.datarep,
46 nd.createpath, {"dir":'/', "file":''}[nd.kind], rev)
47 rec = cur.next()
48 finally:
49 cur.close()
50 finally:
51 ctx.close()
53 if __name__ == '__main__':
54 main()