On Sun, Aug 10, 2003 at 04:13:51PM +0900, Martin DeMello wrote:
> Just learning my way around CVS - is this missing anything? It seems to
> work, but that's just programming by coincidence :)

Normally when adding a whole existing project to CVS you'd use 'cvs import'.
I do that so rarely that I can't remember the exact details, but after doing
it I think you just checkout the entire project again so that you have all
the 'CVS' subdirectories.

Then, when at a later time you want to make sure the repository is in sync
with the files in your working directory, you run 'cvs update'. It shows
recursively for each file a status flag:

?  -- file is in working directory but not in respository; a possible
      candidate for 'cvs add'
A  -- file was added with 'cvs add' but not committed yet
M  -- file has been modified, commit will write it to repository
U  -- file had changed in repository, your local copy has been brought
      into sync (updated)

So in practice I've not found a need to run a script which does 'cvs add'
recursively across all directories. On the odd occasion when I want to add a
new subdirectory of files, I do
    cvs add subdir
    cvs add subdir/*

Regards,

Brian.


> 
> # recursive cvs add
> 
> require 'find'
>                                                                                 
> def cvs_addable?(file)
>   !(['.','..','CVS'].include?(File.basename(file)))
> end
>                                                                                 
> dirs = []
> Find.find (ARGV[0]) {|file|
>   if FileTest.directory?(file)
>     a << file if cvs_addable?(file)
>   end
> }
>                                                                                 
> dirs.each {|dir|
>   Dir.chdir(dir)
>   puts "cd #{dir}"
>   Dir.foreach('.') {|file|
>     system("cvs add #{file}") if cvs_addable?(file)
>   }
> }
>