require File.expand_path(File.dirname(__FILE__) + "/../lib/darcs") @root = File.expand_path(File.dirname(__FILE__) + "/../../../../") @darcs = Darcs.new namespace :darcs do desc "Prepare a fresh rails environment for usage with darcs" task :bootstrap do @darcs.init end desc "Get the latest patches from the default remote repository" task :pull do puts @darcs.pull end desc "Show all changes and new files (pending addition)" task :new do puts @darcs.changes_and_new_files end desc "Add all new files" task :add do puts @darcs.add_all_new_files end desc "Record all available changes for a new patch" task :record do name = get_value_and_set_name_if_needed("What's the name for the new patch?") puts @darcs.record(name) end namespace :record do desc "Add all files (pending addition) and create a patch for all changes" task :smart do Rake::Task['darcs:add'].invoke Rake::Task['darcs:record'].invoke end end desc "Ignore default files for a rails project" task :ignore do Rake::Task['darcs:ignore:db'].invoke Rake::Task['darcs:ignore:log'].invoke Rake::Task['darcs:ignore:tmp'].invoke end namespace :ignore do desc "Setup database.example.yml and ignore database.yml" task :db do @darcs.ignore(@root, :db) end desc "Ignore contents of LOG directory" task :log do @darcs.ignore(@root, :log) end desc "Ignore contents of TMP directory" task :tmp do @darcs.ignore(@root, :tmp) end end desc "Create a TAG patch including checkpoint" task :tag do name = get_value_and_set_name_if_needed("What's the version name?") puts @darcs.tag(name) end def get_value_and_set_name_if_needed(question) unless @darcs.get_author(@root) puts "What's your email address?" email = STDIN.gets.chomp @darcs.set_author(@root, email) end puts question STDIN.gets.chomp end end