Class: RSCM::Cvs

Inherits:
Object
  • Object
show all
Defined in:
lib/Wiki2Go/Install/make_repository.rb

Instance Method Summary collapse

Instance Method Details

#checkout(to_identifier = nil, simulate = false) ⇒ Object

The extra simulate parameter is not in accordance with the AbstractSCM API, but it’s optional and is only being used from within this class (uptodate? method).



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/Wiki2Go/Install/make_repository.rb', line 47

def checkout(to_identifier=nil, simulate=false)
  checked_out_files = []
  if(checked_out?)
    path_regex = /^([U|P|C]) (.*)/
    cvs(@checkout_dir, update_command(to_identifier), simulate) do |line|
      if(line =~ path_regex)
        event = $1
        path = $2.chomp
        yield event,path if block_given?
        checked_out_files << path
      end
    end
  else
    prefix = File.basename(@checkout_dir)
    path_regex = /^([U|P|C]) #{prefix}\/(.*)/
    # This is a workaround for the fact that -d . doesn't work - must be an existing sub folder.
    FileUtils::mkdir_p(@checkout_dir) unless File.exist?(@checkout_dir)
    target_dir = File.basename(@checkout_dir)
    run_checkout_command_dir = File.dirname(@checkout_dir)
    # -D is sticky, but subsequent updates will reset stickiness with -A
    cvs(run_checkout_command_dir, checkout_command(target_dir, to_identifier), simulate) do |line|
      if(line =~ path_regex)
        event = $1
        path = $2.chomp
        yield event,path if block_given?
        checked_out_files << path
      end
    end
  end
  checked_out_files
end

#command_line(cmd, password = nil, simulate = false) ⇒ Object



79
80
81
82
83
84
# File 'lib/Wiki2Go/Install/make_repository.rb', line 79

def command_line(cmd, password=nil, simulate=false)
  cvs_options = simulate ? "-n" : ""
  dev_null = WIN32 ? "nul" : "/dev/null"
  cmd = "cvs -f \"-d#{root_with_password(password)}\" #{cvs_options} -q #{cmd}"
  cmd
end