diff --git a/railties/helpers/bzrignore b/railties/helpers/bzrignore new file mode 100644 index 0000000..7d9590d --- /dev/null +++ b/railties/helpers/bzrignore @@ -0,0 +1,7 @@ +log/*.log +db/*.sqlite3 +db/schema.rb +tmp/cache/* +tmp/pids/* +tmp/sessions/* +tmp/sockets/* diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb index 440bab2..68f3f3f 100644 --- a/railties/lib/rails_generator/commands.rb +++ b/railties/lib/rails_generator/commands.rb @@ -247,6 +247,7 @@ HELP # Optionally add file to subversion or git system("svn add #{destination}") if options[:svn] system("git add -v #{relative_destination}") if options[:git] + system("bzr add #{relative_destination}") if options[:bzr] end # Checks if the source and the destination file are identical. If @@ -318,6 +319,8 @@ HELP svn_path = destination_path(rel_path) system("svn add -N #{svn_path}") unless File.directory?(File.join(svn_path, '.svn')) end + elsif options[:bzr] + system("bzr add #{relative_path}") end end end @@ -434,6 +437,19 @@ end_message # has no modifications so we can simply remove it system("git rm #{relative_destination}") end + elsif options[:bzr] + if options[:bzr][:added][relative_destination] + # File has been added, but not yet committed + system("bzr rm --delete #{relative_destination}") + FileUtils.rm(destination) + elsif options[:bzr][:modified][relative_destination] + # File is committed and modified + system("bzr revert #{relative_destination} --no-backup") + else + # If the directory is not in the status list, it + # has no modifications so we can simply remove it + system("bzr rm #{relative_destination}") + end else FileUtils.rm(destination) end diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index 2f2dd82..af3bfa3 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -43,6 +43,8 @@ class AppGenerator < Rails::Generator::Base m.directory '' BASEDIRS.each { |path| m.directory path } + m.template "helpers/bzrignore", ".bzrignore" if options[:bzr] + # Root m.file "fresh_rakefile", "Rakefile" m.file "README", "README" diff --git a/railties/lib/rails_generator/options.rb b/railties/lib/rails_generator/options.rb index 5f6aefa..a326d59 100644 --- a/railties/lib/rails_generator/options.rb +++ b/railties/lib/rails_generator/options.rb @@ -143,6 +143,21 @@ module Rails opt end end + opt.on('--bzr', 'Modify files with bazaar. (Note: bzr must be in path)') do + state = nil + options[:bzr] = `bzr status`.inject({:added => {}, :modified => {}}) do |opt, e| + case e + when /added:/ + state = :added + when /modified:/ + state = :modified + when /^ (.+)/ + opt[state][$1] = true if state + else + state = nil + end + end + end end end