Class: XMigra::SvnHistoryTracer

Inherits:
Object
  • Object
show all
Includes:
SubversionSpecifics
Defined in:
lib/xmigra/vcs_support/svn.rb

Constant Summary

Constants included from SubversionSpecifics

XMigra::SubversionSpecifics::PRODUCTION_PATH_PROPERTY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SubversionSpecifics

#branch_identifier, #branch_use, #check_working_copy!, #get_conflict_info, init_schema, manages, #production_pattern, #production_pattern=, #resolve_conflict!, run_svn, #subversion, #subversion_info, #subversion_retrieve_status, #vcs_changes_from, #vcs_comparator, #vcs_contents, #vcs_information, #vcs_latest_revision, #vcs_most_recent_committed_contents, #vcs_move, #vcs_production_contents, #vcs_remove, #vcs_uncommitted?

Constructor Details

#initialize(path) ⇒ SvnHistoryTracer

Returns a new instance of SvnHistoryTracer.



378
379
380
381
382
383
384
385
386
# File 'lib/xmigra/vcs_support/svn.rb', line 378

def initialize(path)
  @path = Pathname(path)
  info_doc = subversion(:info, path.to_s)
  @root_url = info_doc.elements['string(info/entry/repository/root)']
  @most_recent_commit = info_doc.elements['string(info/entry/@revision)'].to_i
  @history = []
  @next_query = [branch_identifier, @most_recent_commit]
  @history.unshift(@next_query.dup)
end

Instance Attribute Details

#historyObject (readonly)

Returns the value of attribute history.



388
389
390
# File 'lib/xmigra/vcs_support/svn.rb', line 388

def history
  @history
end

#most_recent_commitObject (readonly)

Returns the value of attribute most_recent_commit.



388
389
390
# File 'lib/xmigra/vcs_support/svn.rb', line 388

def most_recent_commit
  @most_recent_commit
end

#pathObject (readonly)

Returns the value of attribute path.



388
389
390
# File 'lib/xmigra/vcs_support/svn.rb', line 388

def path
  @path
end

Instance Method Details

#copying_element(log_doc) ⇒ Object



435
436
437
438
439
440
441
# File 'lib/xmigra/vcs_support/svn.rb', line 435

def copying_element(log_doc)
  log_doc.each_element %Q{/log/logentry/paths/path[@copyfrom-path]} do |elt|
    return elt if elt.text == @next_query[0]
    return elt if @next_query[0].start_with? (elt.text + '/')
  end
  return nil
end

#earliest_loaded_pinned_url(rel_path = nil) ⇒ Object



425
426
427
428
429
430
431
432
433
# File 'lib/xmigra/vcs_support/svn.rb', line 425

def earliest_loaded_pinned_url(rel_path=nil)
  pin_rev = @history[0][1]
  if rel_path.nil?
    [earliest_loaded_url, pin_rev.to_s].join('@')
  else
    rel_path = Pathname(rel_path)
    "#{earliest_loaded_url}/#{rel_path}@#{pin_rev}"
  end
end

#earliest_loaded_repopathObject



413
414
415
# File 'lib/xmigra/vcs_support/svn.rb', line 413

def earliest_loaded_repopath
  history[0][0]
end

#earliest_loaded_revisionObject



421
422
423
# File 'lib/xmigra/vcs_support/svn.rb', line 421

def earliest_loaded_revision
  history[0][1]
end

#earliest_loaded_urlObject



417
418
419
# File 'lib/xmigra/vcs_support/svn.rb', line 417

def earliest_loaded_url
  @root_url + history[0][0]
end

#history_exhausted?Boolean

Returns:

  • (Boolean)


409
410
411
# File 'lib/xmigra/vcs_support/svn.rb', line 409

def history_exhausted?
  @next_query[1] <= 0
end

#load_parent_commitObject



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/xmigra/vcs_support/svn.rb', line 390

def load_parent_commit
  log_doc = next_earlier_log
  if copy_elt = copying_element(log_doc)
    trailing_part = branch_identifier[copy_elt.text.length..-1]
    @next_query = [
      copy_elt.attributes['copyfrom-path'] + trailing_part,
      copy_elt.attributes['copyfrom-rev'].to_i
    ]
    @history.unshift(@next_query)
    @next_query.dup
  elsif change_elt = log_doc.elements['/log/logentry']
    @next_query[1] = change_elt.attributes['revision'].to_i - 1
    @next_query.dup if @next_query[1] > 0
  else
    @next_query[1] -= 1
    @next_query.dup if @next_query[1] > 0
  end
end

#next_earlier_logObject



443
444
445
# File 'lib/xmigra/vcs_support/svn.rb', line 443

def next_earlier_log
  subversion(:log, '-l1', '-v', "-r#{@next_query[1]}:1", self.path)
end