Esempio n. 1
0
def main():
    if len(sys.argv) == 2:
        dbhome = os.path.join(sys.argv[1], 'db')
        for i in ('', 'uuids', 'revisions', 'transactions', 'representations',
                  'strings', 'changes', 'copies', 'nodes'):
            if not os.path.exists(os.path.join(dbhome, i)):
                sys.stderr.write(
                    "%s: '%s' is not a valid bdb svn repository\n" %
                    (sys.argv[0], sys.argv[1]))
                sys.exit(1)
    else:
        sys.stderr.write("Usage: %s <bdb-svn-repository>\n" % sys.argv[0])
        sys.exit(1)

    print "WARNING!: This program will destroy all text data in the subversion"
    print "repository '%s'" % sys.argv[1]
    print "Do not proceed unless this is a *COPY* of your real repository"
    print "If this is really what you want to do, " \
        "type 'YESERASE' and press Return"
    confirmation = raw_input("Confirmation string> ")
    if confirmation != "YESERASE":
        print "Cancelled - confirmation string not matched"
        sys.exit(0)
    print "Opening database environment..."
    cur = None
    ctx = svnfs.Ctx(dbhome)
    try:
        cur = ctx.nodes_db.cursor()
        nodecount = 0
        newrep = skel.Rep()
        newrep.str = "empty"
        empty_fulltext_rep_skel = newrep.unparse()
        del newrep
        ctx.strings_db['empty'] = ""
        rec = cur.first()
        while rec:
            if rec[0] != "next-key":
                if (nodecount % 10000 == 0) and nodecount != 0:
                    print "Processed %d nodes..." % nodecount
                nodecount += 1
                node = skel.Node(rec[1])
                if node.kind == "file":
                    rep = skel.Rep(ctx.reps_db[node.datarep])
                    if rep.kind == "fulltext":
                        if ctx.strings_db.has_key(rep.str):
                            del ctx.strings_db[rep.str]
                        ctx.reps_db[node.datarep] = empty_fulltext_rep_skel
                    else:
                        for w in rep.windows:
                            if ctx.strings_db.has_key(w.str):
                                del ctx.strings_db[w.str]
                        ctx.reps_db[node.datarep] = empty_fulltext_rep_skel
            rec = cur.next()
        print "Processed %d nodes" % nodecount
    finally:
        if cur:
            cur.close()
        ctx.close()
    print "Done"
Esempio n. 2
0
def am_nodes(ctx):
  "nodes"
  cur = ctx.nodes_db.cursor()
  try:
    print "next-key: %s" % ctx.txns_db['next-key']
    rec = cur.first()
    data = {}
    while rec:
      if rec[0] == 'next-key':
        rec = cur.next()
        continue
      nd = skel.Node(rec[1])
      nid,cid,tid = rec[0].split(".")
      data[tid.rjust(20)+nd.createpath] = (rec[0], nd)
      rec = cur.next()
    k = data.keys()
    k.sort()
    reptype = {"fulltext":"F", "delta":"D"}
    for i in k:
      nd = data[i][1]
      prkind = drkind = " "
      if nd.proprep:
        try:
          rep = skel.Rep(ctx.reps_db[nd.proprep])
          prkind = reptype[rep.kind]
          if ctx.bad_reps.has_key(nd.proprep):
            prkind += " *** BAD ***"
        except KeyError:
          prkind = "*** MISSING ***"
      if nd.datarep:
        try:
          rep = skel.Rep(ctx.reps_db[nd.datarep])
          drkind = reptype[rep.kind]
          if ctx.bad_reps.has_key(nd.datarep):
            drkind += " *** BAD ***"
        except KeyError:
          drkind = "*** MISSING ***"
      stringdata = "%s: %s %s pred %s count %s prop %s %s data %s %s edit %s" \
          % ( data[i][0], {"file":"F", "dir":"D"}[nd.kind], nd.createpath,
          nd.prednode or "-", nd.predcount, prkind, nd.proprep or "-",
          drkind, nd.datarep or "-", nd.editrep or "-")
      if nd.createpath == "/":
        print
      print stringdata
  finally:
    cur.close()
Esempio n. 3
0
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.stderr.flush()
            sys.exit(1)
        rep_ids = sys.argv[2:]
    else:
        sys.stderr.write("Usage: %s <svn-repository> <rep-id>...\n" % progname)
        sys.stderr.flush()
        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()
Esempio n. 4
0
def am_copies(ctx):
  "copies"
  cur = ctx.copies_db.cursor()
  try:
    print "next-key: %s" % ctx.copies_db['next-key']
    rec = cur.first()
    while rec:
      if rec[0] != 'next-key':
        cp = skel.Copy(rec[1])
        destnode = ctx.nodes_db.get(cp.destnode)
        if not destnode:
          destpath = "*** MISSING NODE ***"
        else:
          destpath = skel.Node(destnode).createpath
        print "cpy %s: %s %s @txn %s to %s (%s)" % (rec[0],
            {'copy':'C','soft-copy':'S'}[cp.kind], cp.srcpath or "-",
            cp.srctxn or "-", cp.destnode, destpath)
      rec = cur.next()
  finally:
    cur.close()