#-- # Copyright (C) 2008 Dimitrij Denissenko # Please read LICENSE document for more information. #++ class Change < ActiveRecord::Base belongs_to :changeset belongs_to :repository def previous_revision @previous_revision ||= repository.history(path, revision).reject do |hrev| hrev == revision end.first || 0 end def unified_diff(max_size = 512.kilobyte) if @unified_diff.nil? && diffable? node = repository.node(path, revision) if node.size < max_size @unified_diff = repository.unified_diff(path, previous_revision, revision) end end @unified_diff ||= '' end def diffable? ENABLE_SUBVERSION && self.name == 'M' end end