File: whatis-rep.py

package info (click to toggle)
subversion 1.4.2dfsg1-3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 37,284 kB
  • ctags: 32,888
  • sloc: ansic: 406,472; python: 38,378; sh: 15,438; cpp: 9,604; ruby: 8,313; perl: 5,308; java: 4,576; lisp: 3,860; xml: 3,298; makefile: 856
file content (54 lines) | stat: -rwxr-xr-x 1,616 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python
#
# Print a description (including data, path, and revision) of the
# specified node reps in a Subversion filesystem.  Walks as much of
# the reps table as necessary to locate the data (e.g. does a table
# scan).

# Standard modules
import sys, os, re, codecs

# Local support modules
import skel, svnfs

def main():
  progname = os.path.basename(sys.argv[0])
  if len(sys.argv) >= 3:
    dbhome = os.path.join(sys.argv[1], 'db')
    if not os.path.exists(dbhome):
      sys.stderr.write("%s: '%s' is not a valid svn repository\n" %
          (sys.argv[0], dbhome))
      sys.exit(1)
    rep_ids = sys.argv[2:]
  else:
    print >> sys.stderr, "Usage: %s <svn-repository> <rep-id>..." % progname
    sys.exit(1)

  print "%s running on repository '%s'" % (progname, dbhome)
  print
  rep_ids = dict.fromkeys(rep_ids)
  ctx = svnfs.Ctx(dbhome)
  try:
    cur = ctx.nodes_db.cursor()
    try:
      rec = cur.first()
      while rec:
        if rec[0] != 'next-key':
          nid, cid, tid = rec[0].split(".")
          nd = skel.Node(rec[1])
          if nd.datarep in rep_ids:
            rev = skel.Txn(ctx.txns_db[tid]).rev
            print "%s: data of '%s%s' in r%s" % (nd.datarep,
                nd.createpath, {"dir":'/', "file":''}[nd.kind], rev)
          if nd.proprep in rep_ids:
            rev = skel.Txn(ctx.txns_db[tid]).rev
            print "%s: properties of '%s%s' in r%s" % (nd.datarep,
                nd.createpath, {"dir":'/', "file":''}[nd.kind], rev)
        rec = cur.next()
    finally:
      cur.close()
  finally:
    ctx.close()

if __name__ == '__main__':
  main()