class XMigra::SubversionSpecifics::VersionComparator
Public Class Methods
new(vcs_object, options={})
click to toggle source
vcs_object.kind_of?(SubversionSpecifics
)
# File lib/xmigra/vcs_support/svn.rb, line 237 def initialize(vcs_object, options={}) @object = vcs_object @expected_content_method = options[:expected_content_method] @path_status = Hash.new do |h, file_path| file_path = Pathname(file_path).expand_path next h[file_path] if h.has_key?(file_path) h[file_path] = @object.subversion_retrieve_status(file_path) end end
Public Instance Methods
relative_version(file_path)
click to toggle source
# File lib/xmigra/vcs_support/svn.rb, line 247 def relative_version(file_path) # Comparing @object.file_path (a) to file_path (b) # # returns: :newer, :equal, :older, or :missing b_status = @path_status[file_path].elements['entry/wc-status'] return :missing if b_status.nil? || ['deleted', 'missing'].include?(b_status.attributes['item']) a_status = @path_status[@object.file_path].elements['entry/wc-status'] if ['unversioned', 'added'].include? a_status.attributes['item'] if ['unversioned', 'added', 'modified'].include? b_status.attributes['item'] return relative_version_by_content(file_path) end return :older elsif a_status.attributes['item'] == 'normal' # Look for re-introduction of a declarative that was previously destroyed or renounced if (['unversioned', 'added'].include? b_status.attributes['item']) && [:renunciation, :destruction].include?(@object.goal) return :unimplemented end return :newer unless b_status.attributes['item'] == 'normal' return begin a_revision = a_status.elements['commit'].attributes['revision'].to_i b_revision = b_status.elements['commit'].attributes['revision'].to_i if a_revision < b_revision :newer elsif b_revision < a_revision :older else :equal end end elsif b_status.attributes['item'] == 'normal' return :older else return relative_version_by_content(file_path) end end
relative_version_by_content(file_path)
click to toggle source
# File lib/xmigra/vcs_support/svn.rb, line 291 def relative_version_by_content(file_path) ec_method = @expected_content_method if !ec_method || @object.send(ec_method, file_path) return :equal else return :newer end end