Is there any command line trick to get SVN to add in all the missing files from svn stat
interactively?
For example, something like:
svn add --interactive
$ new file: file1.tmp (Add / Ignore) ?
$ missing file: file.tmp (Remove / Ignore) ?
EDIT:
A script that could achieve this would also work.
Select any file and/or folders you want to commit, then TortoiseSVN → Commit.... The commit dialog will show you every changed file, including added, deleted and unversioned files. If you don't want a changed file to be committed, just uncheck that file.
To add an existing file to a Subversion repository and put it under revision control, change to the directory with its working copy and run the following command: svn add file… Similarly, to add a directory and all files that are in it, type: svn add directory…
Right-click in an empty area of the folder and select Refresh. You'll see “+” icons on the folders/files, now. Right-click an empty area in the folder once again and select SVN Commit. Add a message regarding what you are committing and click OK.
Read the SVN book, or at least the chapter about fundamental concepts and basic usage. Update means: "take all the new stuff in the repository and apply them in my working copy". Commit means: "take all the changes I've made in my working copy and apply them in the repository"
I wrote a little Ruby script to do this:
require 'fileutils'
buffer = ""
CACHE_DIR = File.join(ENV['HOME'], '.svn_interactive_temp')
FileUtils.mkdir_p(CACHE_DIR)
data = IO.popen 'svn stat' do |process|
while process.read(512, buffer)
end
end
def handle_file(file)
system("stty raw")
print "new file: #{file} [a]dd/[i]gnore/[s]kip? "
c = STDIN.getc
system("stty cooked")
exit if c == 3
c = c.chr
success = true
puts
case c
when 'a'
puts "adding the file: #{file}"
system "svn add #{file}"
when 'i'
puts "adding svn:ignore for #{file}"
cache_filename = File.join(CACHE_DIR, (1..10).map{(rand * 10).to_i}.to_s)
p file
parent = File.dirname(file)
system("svn propget svn:ignore #{parent} >> #{cache_filename}")
File.open(cache_filename, 'a') do |f|
f.puts(File.basename(file))
end
system("svn propset svn:ignore -F #{cache_filename} #{parent}")
system("rm #{cache_filename}")
when 's'
puts "skipping: #{file}"
else
success = false
end
success
end
buffer.scan(/\?\s*(.*)$/).each do |file|
while !(handle_file(file.to_s))
sleep(0.01)
end
end
For example,
sam@sam-ubuntu:~/Source/stuff$ ruby ../scripts/svn_interactive.rb
new file: test.txt [a]dd/[i]gnore/[s]kip? i
adding svn:ignore for test.txt
"test.txt"
property 'svn:ignore' set on '.'
The following line on a Unix shell adds all missing files.
svn status | grep '?' | sed 's/^.* /svn add /' | bash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With