Class: XMigra::SubversionSpecifics::VersionComparator
- Defined in:
- lib/xmigra/vcs_support/svn.rb
Instance Method Summary collapse
-
#initialize(vcs_object, options = {}) ⇒ VersionComparator
constructor
vcs_object.kind_of?(SubversionSpecifics).
- #relative_version(file_path) ⇒ Object
- #relative_version_by_content(file_path) ⇒ Object
Constructor Details
#initialize(vcs_object, options = {}) ⇒ VersionComparator
vcs_object.kind_of?(SubversionSpecifics)
232 233 234 235 236 237 238 239 240 |
# File 'lib/xmigra/vcs_support/svn.rb', line 232 def initialize(vcs_object, ={}) @object = vcs_object @expected_content_method = [:expected_content_method] @path_status = Hash.new do |h, file_path| file_path = Pathname(file_path). next h[file_path] if h.has_key?(file_path) h[file_path] = @object.subversion_retrieve_status(file_path) end end |
Instance Method Details
#relative_version(file_path) ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/xmigra/vcs_support/svn.rb', line 242 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' 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) ⇒ Object
281 282 283 284 285 286 287 288 |
# File 'lib/xmigra/vcs_support/svn.rb', line 281 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 |