CVS add

M

Martin DeMello

Just learning my way around CVS - is this missing anything? It seems to
work, but that's just programming by coincidence :)

# 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)
}
}
 
B

Brian Candler

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)
}
}
 
M

Martin DeMello

Brian Candler said:
Normally when adding a whole existing project to CVS you'd use 'cvs import'.

I thought of that, but a friend advised against it. Quoting him:

| Never use cvs import on existing files. you'll get lost in a maze
| of vendor ids and repository ids all alike.
|
| do the following: suppose your project name is foo.
|
| mkdir tmp; cd tmp # any empty directory
| cvs import foo foo start # will prompt for message, can leave blank
| cd ..; rmdir tmp
| cvs co foo # creates foo and foo/CVS and stuff inside it
| cd foo
| cp whatever_existing_project_files_and_dirs .
| cvs add *
| cvs commit # this is your real importing

And when I went to do that, I found out that CVS had no recursive add.

martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,279
Latest member
LaRoseDermaBottle

Latest Threads

Top