Class: Svnx::Revision::RelativeArgument

Inherits:
IndexArgument show all
Defined in:
lib/svnx/revision/argument.rb

Instance Attribute Summary

Attributes inherited from Argument

#value

Instance Method Summary collapse

Methods inherited from Argument

#<=>, create, #to_s

Constructor Details

#initialize(value, args) ⇒ RelativeArgument

Returns a new instance of RelativeArgument.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/svnx/revision/argument.rb', line 67

def initialize value, args
  unless entries = args[:entries]
    raise RevisionError.new "cannot determine relative revision without entries"
  end
  
  nentries = entries.size

  # logentries are in descending order, so the most recent one is index 0

  if value.abs > nentries
    raise RevisionError.new "ERROR: no entry for revision: #{value.abs}; number of entries: #{nentries}"
  else
    idx = value < 0 ? value.abs - 1 : nentries - value
    log_entry = entries[idx]
    super log_entry.revision.to_i
  end
end