Class: Svn::Revision

Inherits:
Root
  • Object
show all
Includes:
Comparable
Defined in:
lib/svn/revisions.rb

Defined Under Namespace

Modules: C

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Root

#pool, release

Constructor Details

#initialize(ptr, repo, pool) ⇒ Revision

Returns a new instance of Revision.



18
19
20
21
22
23
# File 'lib/svn/revisions.rb', line 18

def initialize( ptr, repo, pool )
  super( ptr )
  @repo = repo
  @pool = pool
  @num = revnum
end

Instance Attribute Details

#numObject (readonly)

Returns the value of attribute num.



15
16
17
# File 'lib/svn/revisions.rb', line 15

def num
  @num
end

#repoObject (readonly)

Returns the value of attribute repo.



16
17
18
# File 'lib/svn/revisions.rb', line 16

def repo
  @repo
end

Instance Method Details

#<=>(other) ⇒ Object



29
30
31
# File 'lib/svn/revisions.rb', line 29

def <=>( other )
  to_i <=> other.to_i
end

#authorObject



88
89
90
# File 'lib/svn/revisions.rb', line 88

def author
  prop( AUTHOR_PROP_NAME )
end

#diff(path, options = {}) ⇒ Object

diffs path with another revision. if no revision is specified, the previous revision is used.

Raises:



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/svn/revisions.rb', line 98

def diff( path, options={} )
  raise Svn::Error, "cannot diff directory #{path}@#{to_s}" if dir? path

  other = options[:with] if options[:with].is_a? Root
  other = repo.revision(options[:with]) if options[:with].is_a? Numeric
  other ||= repo.revision(to_i - 1)

  return other.diff( path, :with => self ) if other < self

  content = ""
  begin
    content = file_content_stream( path ).to_counted_string
  rescue Svn::Error => err
    raise if options[:raise_errors]
  end

  other_content = ""
  begin
    other_content= other.file_content_stream( path ).to_counted_string
  rescue Svn::Error => err
    raise if options[:raise_errors]
  end

  Diff.string_diff( content, other_content ).unified(
      :original_header => "#{path}@#{to_s}",
      :modified_header => "#{path}@#{other}"
    )
end

#messageObject Also known as: log



83
84
85
# File 'lib/svn/revisions.rb', line 83

def message
  prop( LOG_PROP_NAME )
end

#timestampObject



92
93
94
# File 'lib/svn/revisions.rb', line 92

def timestamp
  Time.parse( prop( TIMESTAMP_PROP_NAME ) )
end

#to_iObject



25
26
27
# File 'lib/svn/revisions.rb', line 25

def to_i
  @num
end

#to_sObject



127
128
129
# File 'lib/svn/revisions.rb', line 127

def to_s
  "r#{to_i}"
end