mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-26 13:12:30 -06:00
45 lines
1.1 KiB
Text
45 lines
1.1 KiB
Text
|
##############################################################################
|
||
|
#
|
||
|
# cleancvstree
|
||
|
#
|
||
|
# Cleancvstree searches a CVS tree for files that are not in CVS, and
|
||
|
# deletes them. Be careful using it --- it's very aggressive.
|
||
|
#
|
||
|
##############################################################################
|
||
|
|
||
|
import sys,os
|
||
|
|
||
|
def cleanCvsTree(dir):
|
||
|
try:
|
||
|
sub = os.listdir(dir)
|
||
|
except:
|
||
|
print "Could not read directory: "+dir
|
||
|
return
|
||
|
valid = {}
|
||
|
try:
|
||
|
readentries = 0
|
||
|
cvsent = open(dir + "/CVS/Entries")
|
||
|
for line in cvsent:
|
||
|
words = line.split("/")
|
||
|
if (len(words) > 1):
|
||
|
valid[words[1]] = 1
|
||
|
cvsent.close()
|
||
|
readentries = 1
|
||
|
except:
|
||
|
print "Could not read "+dir+"/CVS/Entries"
|
||
|
if (readentries):
|
||
|
for file in sub:
|
||
|
if (os.path.isfile(dir+"/"+file)):
|
||
|
if (valid.has_key(file)==0):
|
||
|
os.unlink(dir+"/"+file)
|
||
|
for file in sub:
|
||
|
if (file != "CVS"):
|
||
|
if (os.path.isdir(dir+"/"+file)):
|
||
|
cleanCvsTree(dir+"/"+file)
|
||
|
|
||
|
if (os.path.isdir(sys.argv[1])==0):
|
||
|
print "Not a directory: "+sys.argv[1]
|
||
|
os.exit(1)
|
||
|
|
||
|
cleanCvsTree(sys.argv[1])
|