source: valtobtest/subversion-1.6.2/tools/bdb/whatis-rep.py @ 3

Last change on this file since 3 was 3, checked in by valtob, 15 years ago

subversion source 1.6.2 as test

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1#!/usr/bin/env python
2#
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).
7
8# Standard modules
9import sys, os, re, codecs
10
11# Local support modules
12import skel, svnfs
13
14def 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.stderr.flush()
22      sys.exit(1)
23    rep_ids = sys.argv[2:]
24  else:
25    sys.stderr.write("Usage: %s <svn-repository> <rep-id>...\n" % progname)
26    sys.stderr.flush()
27    sys.exit(1)
28
29  print("%s running on repository '%s'" % (progname, dbhome))
30  print("")
31  rep_ids = dict.fromkeys(rep_ids)
32  ctx = svnfs.Ctx(dbhome)
33  try:
34    cur = ctx.nodes_db.cursor()
35    try:
36      rec = cur.first()
37      while rec:
38        if rec[0] != 'next-key':
39          nid, cid, tid = rec[0].split(".")
40          nd = skel.Node(rec[1])
41          if nd.datarep in rep_ids:
42            rev = skel.Txn(ctx.txns_db[tid]).rev
43            print("%s: data of '%s%s' in r%s" % (nd.datarep,
44                nd.createpath, {"dir":'/', "file":''}[nd.kind], rev))
45          if nd.proprep in rep_ids:
46            rev = skel.Txn(ctx.txns_db[tid]).rev
47            print("%s: properties of '%s%s' in r%s" % (nd.datarep,
48                nd.createpath, {"dir":'/', "file":''}[nd.kind], rev))
49        rec = cur.next()
50    finally:
51      cur.close()
52  finally:
53    ctx.close()
54
55if __name__ == '__main__':
56  main()
Note: See TracBrowser for help on using the repository browser.