class RSCM::Darcs

Attributes

Public Class Methods

new(dir=".") click to toggle source
# File lib/rscm/scm/darcs.rb, line 19
def initialize(dir=".")
  @dir = File.expand_path(dir)
end

Public Instance Methods

add(relative_filename) click to toggle source
# File lib/rscm/scm/darcs.rb, line 59
def add(relative_filename)
  with_working_dir(@checkout_dir) do
    darcs("add #{relative_filename}")
  end
end
can_create_central?() click to toggle source
# File lib/rscm/scm/darcs.rb, line 23
def can_create_central?
  true
end
checked_out?() click to toggle source
# File lib/rscm/scm/darcs.rb, line 65
def checked_out?
  File.exists?("#{@checkout_dir}/_darcs")
end
commit(message) click to toggle source
# File lib/rscm/scm/darcs.rb, line 48
def commit(message)
  logfile = Tempfile.new("darcs_logfile")
  logfile.print("something nice\n")
  logfile.print(message + "\n")
  logfile.close

  with_working_dir(@checkout_dir) do
    darcs("record --all --logfile #{PathConverter.filepath_to_nativepath(logfile.path, false)}")
  end
end
create_central() click to toggle source
# File lib/rscm/scm/darcs.rb, line 27
def create_central
  with_working_dir(@dir) do
    darcs("initialize")
  end
end
import_central(dir, message) click to toggle source
# File lib/rscm/scm/darcs.rb, line 33
def import_central(dir, message)
  ENV["EMAIL"] = "dcontrol@codehaus.org"
  FileUtils.cp_r(Dir.glob("#{dir}/*"), @dir)
  with_working_dir(@dir) do
    darcs("add --recursive .")
    
    logfile = Tempfile.new("darcs_logfile")
    logfile.print("something nice\n")
    logfile.print(message + "\n")
    logfile.close
    
    darcs("record --all --logfile #{PathConverter.filepath_to_nativepath(logfile.path, false)}")
  end
end
installed?() click to toggle source
# File lib/rscm/scm/darcs.rb, line 10
def installed?
  begin
    darcs("--version", {}) 
    true
  rescue
    false
  end
end
revisions(from_identifier, to_identifier=Time.infinity) click to toggle source
# File lib/rscm/scm/darcs.rb, line 87
def revisions(from_identifier, to_identifier=Time.infinity)
  from_identifier = Time.epoch if from_identifier.nil?
  to_identifier = Time.infinity if to_identifier.nil?
  with_working_dir(@checkout_dir) do
    darcs("changes --summary --xml-output") do |stdout|
      DarcsLogParser.new.parse_revisions(stdout, from_identifier, to_identifier)
    end
  end
end
supports_trigger?() click to toggle source
# File lib/rscm/scm/darcs.rb, line 97
def supports_trigger?
  true
end
uptodate?(from_identifier) click to toggle source
# File lib/rscm/scm/darcs.rb, line 69
def uptodate?(from_identifier)
  if (!checked_out?(@checkout_dir))
    false
  else
    with_working_dir(@checkout_dir) do
      darcs("pull --dry-run #{@dir}") do |io|
        io.each_line do |line|
          if (line =~ /No remote changes to pull in!/)
            true
          else
            false
          end
        end
      end
    end
  end
end

Protected Instance Methods

checkout_silent(to_identifier) { |file| ... } click to toggle source
# File lib/rscm/scm/darcs.rb, line 103
def checkout_silent(to_identifier) # :yield: file

  with_working_dir(File.dirname(checkout_dir)) do
    darcs("get --repo-name #{File.basename(checkout_dir)} #{@dir}")
  end
end
ignore_paths() click to toggle source
# File lib/rscm/scm/darcs.rb, line 109
def ignore_paths
  return [/_darcs/]
end

Private Instance Methods

darcs(darcs_cmd, options={}, &proc) click to toggle source
# File lib/rscm/scm/darcs.rb, line 115
def darcs(darcs_cmd, options={}, &proc)
  cmd = "darcs #{darcs_cmd}"
  execute(cmd, options, &proc)
end