Class RSCM::Revision
In: lib/rscm/revision.rb
Parent: Object

Represents a collection of RevisionFile that were committed at the same time, or "more or less at the same time" for non-atomic SCMs (such as CVS and StarTeam). See Revisions for how to emulate atomicity for non-atomic SCMs.

Methods

==   []   add   each   empty?   identifier   length   new   pop   time   time=   to_s  

Included Modules

Enumerable

Attributes

developer  [RW] 
identifier  [W] 
message  [RW] 

Public Class methods

[Source]

    # File lib/rscm/revision.rb, line 17
17:     def initialize(identifier=nil, time=nil)
18:       @identifier = identifier
19:       @time = time
20:       @files = []
21:     end

Public Instance methods

[Source]

    # File lib/rscm/revision.rb, line 63
63:     def ==(other)
64:       self.to_s == other.to_s
65:     end

[Source]

    # File lib/rscm/revision.rb, line 86
86:     def [](n)
87:       @files[n]
88:     end

[Source]

    # File lib/rscm/revision.rb, line 23
23:     def add(file)
24:       raise "Can't add #{file} to this revision" unless accept? file
25:       @files << file
26:       self.developer = file.developer if file.developer
27:       self.message = file.message if file.message
28:     end

[Source]

    # File lib/rscm/revision.rb, line 82
82:     def each(&block)
83:       @files.each(&block)
84:     end

[Source]

     # File lib/rscm/revision.rb, line 98
 98:     def empty?
 99:       @files.empty?
100:     end

[Source]

    # File lib/rscm/revision.rb, line 30
30:     def identifier(min_or_max = :max)
31:       @identifier || time(min_or_max)
32:     end

[Source]

    # File lib/rscm/revision.rb, line 90
90:     def length
91:       @files.length
92:     end

[Source]

    # File lib/rscm/revision.rb, line 94
94:     def pop
95:       @files.pop
96:     end

The time of this revision. Depending on the value of min_or_max, (should be :min or :max), returns the min or max time of this revision. (min or max only matters for non-transactional scms)

[Source]

    # File lib/rscm/revision.rb, line 37
37:     def time(min_or_max = :max)
38:       @time || self.collect{|file| file.time}.__send__(min_or_max)
39:     end

Sets the time for this revision. Should only be used by atomic SCMs. Non-atomic SCMs should not invoke this method, but instead create revisions by adding RscmFile objects to a Revisions object.

[Source]

    # File lib/rscm/revision.rb, line 44
44:     def time=(t)
45:       raise "time must be a Time object - it was a #{t.class.name} with the string value #{t}" unless t.is_a?(Time)
46:       raise "can't set time to an inferiour value than the previous value" if @time && (t < @time)
47:       @time = t
48:     end

String representation that can be used for debugging.

[Source]

    # File lib/rscm/revision.rb, line 68
68:     def to_s
69:       if(@to_s.nil?)
70:         min = time(:min)
71:         max = time(:max)
72:         t = (min==max) ? min : "#{min}-#{max}"
73:         @to_s = "#{identifier} | #{developer} | #{t} | #{message}\n"
74:         self.each do |file|
75:           @to_s << " " << file.to_s << "\n"
76:         end
77:         @to_s
78:       end
79:       @to_s
80:     end

[Validate]