RSCM implementation for CVS.
You need a cvs executable on the PATH in order for it to work.
NOTE: On Cygwin this has to be the win32 build of cvs and not the Cygwin one.
# File lib/rscm/scm/cvs.rb, line 40 def add(relative_filename, options={}) cvs("add #{relative_filename}", options) end
# File lib/rscm/scm/cvs.rb, line 98 def apply_label(label) cvs("tag -c #{label}") end
# File lib/rscm/scm/cvs.rb, line 191 def can_create_central? begin local? rescue false end end
# File lib/rscm/scm/cvs.rb, line 182 def central_exists? if(local?) File.exists?("#{path}/CVSROOT/loginfo") else # don't know. assume yes. true end end
# File lib/rscm/scm/cvs.rb, line 203 def checked_out? rootcvs = File.expand_path("#{checkout_dir}/CVS/Root") File.exists?(rootcvs) end
# File lib/rscm/scm/cvs.rb, line 51 def commit(message, options={}) cvs(commit_command(message), options) end
# File lib/rscm/scm/cvs.rb, line 167 def create_central(options={}) options = options.dup.merge({:dir => path}) raise "Can't create central CVS repository for #{root}" unless can_create_central? File.mkpath(path) cvs("init", options) end
# File lib/rscm/scm/cvs.rb, line 174 def destroy_central if(File.exist?(path) && local?) FileUtils.rm_rf(path) else raise "Cannot destroy central repository. '#{path}' doesn't exist or central repo isn't local to this machine" end end
# File lib/rscm/scm/cvs.rb, line 80 def diff(path, from, to, options={}, &block) # IMPORTANT! CVS NT has a bug in the -N diff option # http://www.cvsnt.org/pipermail/cvsnt-bugs/2004-November/000786.html from ||= Time.epoch cmd = command_line("diff -Nu #{revision_option(from)} #{revision_option(to)} #{path}") execute(cmd, options.dup.merge({:exitstatus => 1})) do |io| block.call io end end
# File lib/rscm/scm/cvs.rb, line 33 def import_central(dir, options={}) modname = File.basename(dir) FileUtils.mkdir_p(@checkout_dir) unless File.exist?(@checkout_dir) options = options.dup.merge :dir => dir cvs("import -m \"#{options[:message]}\" #{modname} VENDOR START", options) end
# File lib/rscm/scm/cvs.rb, line 131 def install_trigger(trigger_command, trigger_files_checkout_dir, options={}) raise "mod can't be null or empty" if (mod.nil? || mod == "") trigger_command = fix_trigger_command(trigger_command) root_cvs = create_root_cvs(trigger_files_checkout_dir) root_cvs.checkout(nil, options) Dir.chdir(trigger_files_checkout_dir) do trigger_line = "#{mod} #{trigger_command}\n" File.open("loginfo", File::WRONLY | File::APPEND) do |file| file.puts(trigger_line) end end begin root_cvs.commit("Installed trigger for CVS module '#{mod}'", options) rescue Errno::EACCES raise ["Didn't have permission to commit CVSROOT/loginfo.", "Try to manually add the following line:", trigger_command, "Finally make commit the file to the repository"].join("\n") end end
# File lib/rscm/scm/cvs.rb, line 20 def installed? begin cvs("--version", {}) true rescue false end end
# File lib/rscm/scm/cvs.rb, line 44 def move(relative_src, relative_dest, options={}) FileUtils.mv(@checkout_dir + '/' + relative_src, @checkout_dir + '/' + relative_dest, :force=>true) cvs("rm #{relative_src}", options) # This will fail if the directories are new. More advanced support for adding can be added if needed. cvs("add #{relative_dest}", options) end
# File lib/rscm/scm/cvs.rb, line 90 def open(path, native_revision_identifier, options={}, &block) raise "native_revision_identifier cannot be nil" if native_revision_identifier.nil? cmd = "cvs -Q update -p -r #{native_revision_identifier} #{path}" execute(cmd, options) do |io| block.call io end end
# File lib/rscm/scm/cvs.rb, line 69 def revisions(from_identifier=Time.new.utc, options={}) raise "from_identifer cannot be nil" if from_identifier.nil? options = { :from_identifier => from_identifier, :to_identifier => Time.infinity, :relative_path => nil }.merge(options) checkout(options[:to_identifier], options) unless checked_out? # must checkout to get revisions parse_log(changes_command(options), options) end
# File lib/rscm/scm/cvs.rb, line 199 def supports_trigger? true end
# File lib/rscm/scm/cvs.rb, line 106 def trigger_installed?(trigger_command, trigger_files_checkout_dir, options={}) trigger_command = fix_trigger_command(trigger_command) loginfo_line = "#{mod} #{trigger_command}" regex = Regexp.new(Regexp.escape(loginfo_line)) root_cvs = create_root_cvs(trigger_files_checkout_dir) begin root_cvs.checkout(nil, options) loginfo = File.join(trigger_files_checkout_dir, "loginfo") return false if !File.exist?(loginfo) # returns true if commented out. doesn't modify the file. in_local_copy = LineEditor.comment_out(File.new(loginfo), regex, "# ", "") # Also verify that loginfo has been committed back to the repo entries = File.join(trigger_files_checkout_dir, "CVS", "Entries") committed = File.mtime(entries) >= File.mtime(loginfo) in_local_copy && committed rescue Exception => e $stderr.puts(e.message) $stderr.puts(e.backtrace.join("\n")) false end end
# File lib/rscm/scm/cvs.rb, line 102 def trigger_mechanism "CVSROOT/loginfo" end
# File lib/rscm/scm/cvs.rb, line 154 def uninstall_trigger(trigger_command, trigger_files_checkout_dir, options={}) trigger_command = fix_trigger_command(trigger_command) loginfo_line = "#{mod} #{trigger_command}" regex = Regexp.new(Regexp.escape(loginfo_line)) root_cvs = create_root_cvs(trigger_files_checkout_dir) root_cvs.checkout nil, options loginfo_path = File.join(trigger_files_checkout_dir, "loginfo") File.comment_out(loginfo_path, regex, "# ") root_cvs.commit("Uninstalled trigger for CVS mod '#{mod}'", options) raise "Couldn't uninstall/commit trigger to loginfo" if trigger_installed?(trigger_command, trigger_files_checkout_dir, options) end
# File lib/rscm/scm/cvs.rb, line 55 def uptodate?(identifier, options={}) if(!checked_out?) return false end checkout_silent(identifier, options.dup.merge({:simulate => true})) do |io| path_regex = /^[U|P|C] (.*)/ io.each_line do |line| return false if(line =~ path_regex) end end return true end
# File lib/rscm/scm/cvs.rb, line 214 def checkout_silent(to_identifier, options={}, &proc) to_identifier = nil if to_identifier == Time.infinity if(checked_out?) options = options.dup.merge({ :dir => @checkout_dir }) cvs(update_command(to_identifier), options, &proc) else # 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) # -D is sticky, but subsequent updates will reset stickiness with -A options = options.dup.merge({ :dir => File.dirname(@checkout_dir) }) cvs(checkout_command(target_dir, to_identifier), options, &proc) end end
Generated with the Darkfish Rdoc Generator 2.