Sha256: 012194d7a05cd3914612ef30ea155f2610bc7d1de35f39f4e15b252827b13767

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

require 'svn_commands'
require 'digg_module'

class Changeset
  include Comparable
  attr_reader :revision
  attr_accessor :wcBasePath, :releaseBranch
  def initialize(rev, wc_base_path=SvnCommands::DIGG_DEFAULT_WC_PATH, release_branch="9.4")
    @revision = Integer(rev)
    @modified = {}
    @affectedModules = {}
    self.wcBasePath=wc_base_path
    self.releaseBranch=release_branch
  end
  
  def modifiedPaths(relativeStartPath = self.wcBasePath)
    @modified[relativeStartPath] ||= begin
      SvnCommands::Log.new(relativeStartPath,"-r #{self.revision.abs}", true).entries.first.paths.map {|p| p.to_s}
    rescue
      []
    end
  end
  
  def affectedModulesbak(modulePath = "LOLz/trunk")
    @affectedModules[modulePath] ||= self.modifiedPaths(modulePath).inject(Set.new) { |memo, modifiedPath|
      (modifiedPath =~ /#{modulePath}\/([^\/]*)/) ?  memo << DiggModule.new($1, self.wcBasePath, self.releaseBranch) : memo
    }
  end
  
  def affectedModules(modulePath = "LOLz/trunk")
    @affectedModules[modulePath] ||= begin
      self.modifiedPaths(modulePath).inject(Set.new) { |memo, modifiedPath|
        if modifiedPath =~ /#{modulePath}\/([^\/]*)/
          moduleName = $1
          unless (memo.detect{ |m| m.moduleName == moduleName })
            memo << DiggModule.new($1, self.wcBasePath, self.releaseBranch)
          end
        end
        memo
      }
    end
  end
  
  def to_s
    "r#{revision}"
  end
  
  def <=>(other)
    self.revision <=> other.revision
  end
  
  def hash
    self.revision.hash
  end
  
  def eql?(other)
    self.revision == other.revision
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motomike-bnr_tools-0.0.6 lib/bnr_tools/changeset.rb
motomike-bnr_tools-0.0.7 lib/bnr_tools/changeset.rb