Sha256: 01b890164f9d430480dbf71f4c24c0dc39b473bf4a8f7d5fd00804695083f412

Contents?: true

Size: 880 Bytes

Versions: 22

Compression:

Stored size: 880 Bytes

Contents

module Churn

  #analizes Hg / Mercurial SCM to find recently changed files, and what lines have been altered
  class HgAnalyzer < SourceControl
    def get_logs
      `hg log -v#{date_range}`.split("\n").reject{|line| line !~ /^files:/}.map{|line| line.split(" ")[1..-1]}.flatten
    end

    def get_revisions
      `hg log#{date_range}`.split("\n").reject{|line| line !~ /^changeset:/}.map{|line| line[/:(\S+)$/, 1] }
    end

    private

    def get_diff(revision, previous_revision)
      `hg diff -r #{revision}:#{previous_revision} -U 0`.split(/\n/).select{|line| line.match(/^@@/) || line.match(/^---/) || line.match(/^\+\+\+/) }
    end

    def date_range
      if @start_date
        date = Chronic.parse(@start_date)
        " -d \"> #{date.strftime('%Y-%m-%d')}\""
      end
    end

    def get_recent_file(line)
      super(line).split("\t")[0]
    end

  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
churn-0.0.14 lib/churn/hg_analyzer.rb
churn-0.0.13 lib/churn/hg_analyzer.rb