3 # Erases the text of every file in a BDB repository
10 if len(sys
.argv
) == 2:
11 dbhome
= os
.path
.join(sys
.argv
[1], 'db')
12 for i
in ('', 'uuids', 'revisions', 'transactions', 'representations',
13 'strings', 'changes', 'copies', 'nodes'):
14 if not os
.path
.exists(os
.path
.join(dbhome
, i
)):
15 sys
.stderr
.write("%s: '%s' is not a valid bdb svn repository\n" %
16 (sys
.argv
[0], sys
.argv
[1]))
19 sys
.stderr
.write("Usage: %s <bdb-svn-repository>\n" % sys
.argv
[0])
22 print "WARNING!: This program will destroy all text data in the subversion"
23 print "repository '%s'" % sys
.argv
[1]
24 print "Do not proceed unless this is a *COPY* of your real repository"
25 print "If this is really what you want to do, " \
26 "type 'YESERASE' and press Return"
27 confirmation
= raw_input("Confirmation string> ")
28 if confirmation
!= "YESERASE":
29 print "Cancelled - confirmation string not matched"
31 print "Opening database environment..."
33 ctx
= svnfs
.Ctx(dbhome
)
35 cur
= ctx
.nodes_db
.cursor()
39 empty_fulltext_rep_skel
= newrep
.unparse()
41 ctx
.strings_db
['empty'] = ""
44 if rec
[0] != "next-key":
45 if (nodecount
% 10000 == 0) and nodecount
!= 0:
46 print "Processed %d nodes..." % nodecount
48 node
= skel
.Node(rec
[1])
49 if node
.kind
== "file":
50 rep
= skel
.Rep(ctx
.reps_db
[node
.datarep
])
51 if rep
.kind
== "fulltext":
52 if ctx
.strings_db
.has_key(rep
.str):
53 del ctx
.strings_db
[rep
.str]
54 ctx
.reps_db
[node
.datarep
] = empty_fulltext_rep_skel
57 if ctx
.strings_db
.has_key(w
.str):
58 del ctx
.strings_db
[w
.str]
59 ctx
.reps_db
[node
.datarep
] = empty_fulltext_rep_skel
61 print "Processed %d nodes" % nodecount
68 if __name__
== '__main__':