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.
developer | [RW] | |
identifier | [W] | |
message | [RW] |
# File lib/rscm/revision.rb, line 17 17: def initialize(identifier=nil, time=nil) 18: @identifier = identifier 19: @time = time 20: @files = [] 21: end
# 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
# File lib/rscm/revision.rb, line 30 30: def identifier(min_or_max = :max) 31: @identifier || time(min_or_max) 32: 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)
# 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.
# 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.
# 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