Recursively remove CVS or Subversion files from folders
find -d . -name 'CVS' -exec rm -rf '{}' \; -print
12388 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
find -d . -name 'CVS' -exec rm -rf '{}' \; -print
#! /usr/bin/ruby -W0 require 'Time' require 'Find' require 'optparse' def splitEntryLine(line) re = /\/(.*)\/(.*)\/(.*)\/(.*)\/(.*)/ m=re.match(line) if m return m[1..-1] else return nil end end def parseCvsEntries(dirname, modified) #print "CVS: ", dirname array = [] File.open(File.join(dirname,"CVS", "Entries"), "r") { | entriesFile | entriesFile.each_line { | line | name, ver, date, k, t=splitEntryLine(line) if name file=File.join(dirname, name) if File.exists?(file) and not File.directory?(file) orig=Time.parse(date) orig = orig+orig.gmt_offset mtime = File.new(file).mtime if mtime != orig if modified array.push(file) end else if not modified array.push(file) end end end end } } return array end def checkFile(dirname, filename, modified) array = [] path = File.join(dirname, filename) if File.directory?(path) if filename == "CVS" array += parseCvsEntries(dirname, modified); elsif not filename == "." and not filename == ".." array += checkDir(path, modified) end end return array end def checkDir(dirname, modified) array = Array.new Dir.entries(dirname).each do |filename| array += checkFile(dirname, filename, modified); end return array end def removeUnmodified() list = checkDir(".", false) list.each { |file| cmd = "rm -vf "+ file system(cmd) } end def printModified() list = checkDir(".", true) list.each { |file| print file, "\n" } end def change_root(new_root) print new_root, "\n" Find.find(".") do |path| if File.basename(path) == "Root" and File.basename(File.dirname(path)) == "CVS" print path, "\n" File.open(path, "w") do |fout| fout << new_root << "\n" end end end print new_root, "\n" end def hello() print "Hi\n" end def usage() puts "cvs.rb" puts " options:" puts " --removeUnmodified" puts " --chroot(-d)" puts " --printModified(-m)" puts " --help(-h)" exit 1 end def main() opts = OptionParser.new {|opts| opts.on("-e", "--eval [TEXT]" ,"evaluate ruby code") do |text| eval(text) end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on("--removeUnmodified","delete unmodified cvs files") do removeUnmodified end opts.on("--printModified","-m", "print modified cvs files") do printModified end opts.on("-d", "--chroot [ROOT]" ,"change CVS root") do |root| change_root(root) end }.parse! end main
import pexpect def update(): child = pexpect.spawn('cvs update -dP') for line in child: if not line.startswith('?') and not line.startswith('cvs update'): print line[:-1]
find . -type d ! \( -name "*CVS" \) -exec python cvsAdd.py {} \; find . -name "*.py" -exec python cvsAdd.py {} \;
import sys, pexpect, getpass PASS='myPass' def cvsAdd(fname): global PASS if not PASS: PASS = getpass.getpass() child = pexpect.spawn('cvs add "%s"' % fname) child.expect("me@my-cvs-host password:") child.sendline(PASS) for line in child: print line cvsAdd(sys.argv[1])
def deleteDir(dir) puts "cd #{dir}" Dir.chdir(dir) Dir.foreach(dir) do |file| if file != "." and file != ".." if File.directory?(file) deleteDir("#{dir}/#{file}") else puts "delete file #{file}" File.delete(file) end end end Dir.chdir("..") puts "delete directory #{dir}" Dir.delete(dir) end def processDir(dir) #puts "Processing directory #{dir}" Dir.chdir(dir) Dir.foreach(dir) do |file| if File.directory?(file) if file == "CVS" puts "Deleting directory #{dir}/#{file}" deleteDir("#{dir}/#{file}") elsif file != "." and file != ".." processDir("#{dir}/#{file}") end end end Dir.chdir("..") end puts "Working directory: #{Dir.pwd}" processDir(Dir.pwd)
cvs status 2>&1 | egrep "(^\? |Status: )" | grep -v Up-to-date