Class: PVN::Revision::RelativeArgument

Inherits:
FixnumArgument show all
Defined in:
lib/pvn/revision/argument.rb

Overview

this is of the form -3, which is revision (second one from the most recent; -1 is the most recent).

Constant Summary

Constants inherited from Argument

Argument::DATE_REGEXP, Argument::SVN_ARGUMENT_WORDS

Instance Attribute Summary

Attributes inherited from Argument

#log_entry, #value

Instance Method Summary collapse

Methods inherited from Argument

#<=>, matches_relative?, new, orig_new, #to_s

Constructor Details

#initialize(value, xmllines) ⇒ RelativeArgument

Returns a new instance of RelativeArgument.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/pvn/revision/argument.rb', line 98

def initialize value, xmllines
  unless xmllines
    raise RevisionError.new "cannot determine relative revision without xmllines"
  end
  
  logentries = SVNx::Log::Entries.new :xmllines => xmllines
  nentries = logentries.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 ? -1 + value.abs : nentries - value
    @log_entry = logentries[idx]
    super @log_entry.revision.to_i
  end
end