Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 2174

Show
Ignore:
Timestamp:
09/09/05 09:02:55 (5 years ago)
Author:
david
Message:

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]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/CHANGELOG

    r2173 r2174  
    11*SVN* 
     2 
     3* 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] 
    24 
    35* Added -c/--charset option to WEBrick controller, so you can specify a default charset (which without changes is UTF-8) #2084 [wejn@box.cz] 
  • trunk/railties/lib/rails_generator/commands.rb

    r691 r2174  
    203203            FileUtils.chmod(file_options[:chmod], destination) 
    204204          end 
     205           
     206          # Optionally add file to subversion 
     207          system("svn add #{destination}") if options[:svn] 
    205208        end 
    206209 
     
    247250            logger.create relative_path 
    248251            FileUtils.mkdir_p(path) unless options[:pretend] 
     252             
     253            # Optionally add file to subversion 
     254            system("svn add #{path}") if options[:svn] 
    249255          end 
    250256        end 
     
    295301      class Destroy < RewindBase 
    296302        # Remove a file if it exists and is a file. 
    297         def file(relative_source, relative_destination, options = {}) 
     303        def file(relative_source, relative_destination, file_options = {}) 
    298304          destination = destination_path(relative_destination) 
    299305          if File.exists?(destination) 
    300306            logger.rm relative_destination 
    301             FileUtils.rm(destination) unless options[:pretend] 
     307            unless options[:pretend] 
     308              if options[:svn] 
     309                # If the file has been marked to be added 
     310                # but has not yet been checked in, revert and elete 
     311                if options[:svn][relative_destination] 
     312                  system("svn revert #{destination}") 
     313                  FileUtils.rm(destination) 
     314                else 
     315                # If the directory is not in the status list, it 
     316                # has no modifications so we can simply remove it 
     317                  system("svn rm #{destination}") 
     318                end   
     319              else 
     320                FileUtils.rm(destination) 
     321              end 
     322            end 
    302323          else 
    303324            logger.missing relative_destination 
     
    320341              if Dir[File.join(path, '*')].empty? 
    321342                logger.rmdir partial 
    322                 FileUtils.rmdir(path) unless options[:pretend] 
     343                unless options[:pretend] 
     344                  if options[:svn] 
     345                    # If the directory has been marked to be added 
     346                    # but has not yet been checked in, revert and elete 
     347                    if options[:svn][relative_path] 
     348                      system("svn revert #{path}") 
     349                      FileUtils.rmdir(path) 
     350                    else 
     351                    # If the directory is not in the status list, it 
     352                    # has no modifications so we can simply remove it 
     353                      system("svn rm #{path}") 
     354                    end 
     355                  else 
     356                    FileUtils.rmdir(path) 
     357                  end 
     358                end 
    323359              else 
    324360                logger.notempty partial 
  • trunk/railties/lib/rails_generator/options.rb

    r1107 r2174  
    128128          opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |options[:backtrace]| } 
    129129          opt.on('-h', '--help', 'Show this help message.') { |options[:help]| } 
     130          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] } 
    130131        end 
    131132