Sha256: 5b1ee178f014e9ac37452882ebaa1c079dbc4b48578e8346dd94684b666bcf0f

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module RSCM
  # Represents the full history of a single file or directory.
  class HistoricFile
    attr_reader :relative_path
    
    def initialize(relative_path, directory, scm)
      @relative_path, @directory, @scm = relative_path, directory, scm
    end
    
    def directory?
      @directory
    end
    
    # Returns an Array of RevisionFile - from Time.epoch until Time.infinity (now)
    def revision_files
      @scm.revisions(Time.epoch, Time.infinity, @relative_path).collect do |revision|
        if revision.files.length != 1
          files_s = revision.files.collect{|f| f.to_s}.join("\n")
          raise "The file-specific revision didn't have exactly one file, but #{revision.files.length}:\n#{files_s}"
        end
        if(revision.files[0].path != @relative_path)
          raise "The file-specific revision didn't have expected path #{@relative_path}, but #{revision.files[0].path}"
        end
        revision.files[0]
      end
    end
    
    def children
      raise "Not a directory" unless directory?
      @scm.ls(@relative_path)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rscm-0.3.15 lib/rscm/historic_file.rb