Fix compiler warning due to missing function prototype.
[svn.git] / tools / examples / revplist.py
blobcbcf19b1bccaae74d21efa938862ccc71fdf7e5c
1 #!/usr/bin/env python
3 # revplist.py : display revision properties
5 ######################################################################
7 # Copyright (c) 2000-2004 CollabNet. All rights reserved.
9 # This software is licensed as described in the file COPYING, which
10 # you should have received as part of this distribution. The terms
11 # are also available at http://subversion.tigris.org/license-1.html.
12 # If newer versions of this license are posted there, you may use a
13 # newer version instead, at your option.
15 ######################################################################
18 import sys
19 import os
20 import getopt
21 try:
22 my_getopt = getopt.gnu_getopt
23 except AttributeError:
24 my_getopt = getopt.getopt
26 from svn import fs, core
28 def plist(rev=None, home='.', *props):
30 db_path = os.path.join(home, 'db')
31 if not os.path.exists(db_path):
32 db_path = home
34 fs_ptr = fs.new(None)
35 fs.open_berkeley(fs_ptr, db_path)
37 if rev is None:
38 rev = fs.youngest_rev(fs_ptr)
40 print 'Properties for revision:', rev
41 if props:
42 for propname in props:
43 value = fs.revision_prop(fs_ptr, rev, propname)
44 if value is None:
45 print '%s: <not present>' % propname
46 else:
47 print '%s: %s' % (propname, value)
48 else:
49 proplist = fs.revision_proplist(fs_ptr, rev)
50 for propname, value in proplist.items():
51 print '%s: %s' % (propname, value)
53 def usage():
54 print "USAGE: %s [-r REV] [-h DBHOME] [PROP1 [PROP2 ...]]" % sys.argv[0]
55 sys.exit(1)
57 def main():
58 ### how to invoke usage() ?
59 opts, args = my_getopt(sys.argv[1:], 'r:h:')
60 rev = None
61 home = '.'
62 for name, value in opts:
63 if name == '-r':
64 rev = int(value)
65 elif name == '-h':
66 home = value
68 apply(plist, (rev, home) + tuple(args))
70 if __name__ == '__main__':
71 main()