diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-09 09:02:55 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-09 09:02:55 +0000 |
commit | b33557b6221c0d9f4d0a7374771b9272c48951a8 (patch) | |
tree | 9a71922e2c63535125b3d22963e8222fd2083784 /railties/lib | |
parent | 0cd7e6c1e02f9fab6939963a42b95fe2245fac19 (diff) | |
download | rails-b33557b6221c0d9f4d0a7374771b9272c48951a8.tar.gz rails-b33557b6221c0d9f4d0a7374771b9272c48951a8.tar.bz2 rails-b33557b6221c0d9f4d0a7374771b9272c48951a8.zip |
Added -c/--svn option to the generator that'll add new files and remove destroyed files using svn add/revert/remove as appropriate #2064 [kevin.clark@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2174 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails_generator/commands.rb | 42 | ||||
-rw-r--r-- | railties/lib/rails_generator/options.rb | 1 |
2 files changed, 40 insertions, 3 deletions
diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb index b851c6e70b..9b8ca01ad2 100644 --- a/railties/lib/rails_generator/commands.rb +++ b/railties/lib/rails_generator/commands.rb @@ -202,6 +202,9 @@ module Rails if file_options[:chmod] FileUtils.chmod(file_options[:chmod], destination) end + + # Optionally add file to subversion + system("svn add #{destination}") if options[:svn] end # Generate a file for a Rails application using an ERuby template. @@ -246,6 +249,9 @@ module Rails else logger.create relative_path FileUtils.mkdir_p(path) unless options[:pretend] + + # Optionally add file to subversion + system("svn add #{path}") if options[:svn] end end @@ -294,11 +300,26 @@ end_message # manifest and attempt to completely erase the results of each action. class Destroy < RewindBase # Remove a file if it exists and is a file. - def file(relative_source, relative_destination, options = {}) + def file(relative_source, relative_destination, file_options = {}) destination = destination_path(relative_destination) if File.exists?(destination) logger.rm relative_destination - FileUtils.rm(destination) unless options[:pretend] + unless options[:pretend] + if options[:svn] + # If the file has been marked to be added + # but has not yet been checked in, revert and elete + if options[:svn][relative_destination] + system("svn revert #{destination}") + FileUtils.rm(destination) + else + # If the directory is not in the status list, it + # has no modifications so we can simply remove it + system("svn rm #{destination}") + end + else + FileUtils.rm(destination) + end + end else logger.missing relative_destination return @@ -319,7 +340,22 @@ end_message if File.exists?(path) if Dir[File.join(path, '*')].empty? logger.rmdir partial - FileUtils.rmdir(path) unless options[:pretend] + unless options[:pretend] + if options[:svn] + # If the directory has been marked to be added + # but has not yet been checked in, revert and elete + if options[:svn][relative_path] + system("svn revert #{path}") + FileUtils.rmdir(path) + else + # If the directory is not in the status list, it + # has no modifications so we can simply remove it + system("svn rm #{path}") + end + else + FileUtils.rmdir(path) + end + end else logger.notempty partial end diff --git a/railties/lib/rails_generator/options.rb b/railties/lib/rails_generator/options.rb index 0872503389..5a0aa9f59c 100644 --- a/railties/lib/rails_generator/options.rb +++ b/railties/lib/rails_generator/options.rb @@ -127,6 +127,7 @@ module Rails opt.on('-q', '--quiet', 'Suppress normal output.') { |options[:quiet]| } opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |options[:backtrace]| } opt.on('-h', '--help', 'Show this help message.') { |options[:help]| } + opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') { options[:svn] = Hash[*`svn status`.collect { |e| e.chop.split.reverse unless e.chop.split.size != 2 }.flatten] } end end |