~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to tools/examples/revplist.py

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# revplist.py : display revision properties
 
4
#
 
5
######################################################################
 
6
#
 
7
# Copyright (c) 2000-2004 CollabNet.  All rights reserved.
 
8
#
 
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.
 
14
#
 
15
######################################################################
 
16
#
 
17
 
 
18
import sys
 
19
import os
 
20
import getopt
 
21
 
 
22
from svn import fs, core
 
23
 
 
24
def plist(pool, rev=None, home='.', *props):
 
25
 
 
26
  db_path = os.path.join(home, 'db')
 
27
  if not os.path.exists(db_path):
 
28
    db_path = home
 
29
 
 
30
  fs_ptr = fs.new(None, pool)
 
31
  fs.open_berkeley(fs_ptr, db_path)
 
32
 
 
33
  if rev is None:
 
34
    rev = fs.youngest_rev(fs_ptr, pool)
 
35
 
 
36
  print 'Properties for revision:', rev
 
37
  if props:
 
38
    for propname in props:
 
39
      value = fs.revision_prop(fs_ptr, rev, propname, pool)
 
40
      if value is None:
 
41
        print '%s: <not present>' % propname
 
42
      else:
 
43
        print '%s: %s' % (propname, value)
 
44
  else:
 
45
    proplist = fs.revision_proplist(fs_ptr, rev, pool)
 
46
    for propname, value in proplist.items():
 
47
      print '%s: %s' % (propname, value)
 
48
 
 
49
def usage():
 
50
  print "USAGE: %s [-r REV] [-h DBHOME] [PROP1 [PROP2 ...]]" % sys.argv[0]
 
51
  sys.exit(1)
 
52
 
 
53
def main():
 
54
  ### how to invoke usage() ?
 
55
  opts, args = getopt.getopt(sys.argv[1:], 'r:h:')
 
56
  rev = None
 
57
  home = '.'
 
58
  for name, value in opts:
 
59
    if name == '-r':
 
60
      rev = int(value)
 
61
    elif name == '-h':
 
62
      home = value
 
63
 
 
64
  apply(core.run_app, (plist, rev, home) + tuple(args))
 
65
 
 
66
if __name__ == '__main__':
 
67
  main()