Sha256: d8aa5bae445fc9340c6f9a5d45329cda00b63fe7021121dfb87fcba07152ded1

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

module Mercurial

  #
  # The class represents Mercurial diff. Obtained by running an +hg diff+ command.
  #
  # The class represents Diff object itself, {Mercurial::DiffFactory DiffFactory} is responsible
  # for assembling instances of Diff. For the list of all possible diff-related operations 
  # check {Mercurial::DiffFactory DiffFactory}.
  #
  class Diff
    
    # SHA1 hash of version a of the file.
    attr_reader :hash_a
    
    # SHA1 hash of version b of the file.
    attr_reader :hash_b
    
    # Version a of the file name.
    attr_reader :file_a
    
    # Version b of the file name.
    attr_reader :file_b
    
    # Diff body.
    attr_reader :body
    
    def initialize(opts={})
      @hash_a = opts[:hash_a]
      @hash_b = opts[:hash_b]
      @file_a = opts[:file_a]
      @file_b = opts[:file_b]
      @body   = opts[:body]
      @binary = opts[:binary]

      if RUBY_VERSION >= '1.9.1'
        @file_a.force_encoding('utf-8') if @file_a
        @file_b.force_encoding('utf-8') if @file_b
      end
    end
    
    def file_name
      file_b || file_a
    end
    
    def binary?
      !! @binary
    end
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mercurial-ruby-0.7.12 lib/mercurial-ruby/diff.rb
mercurial-ruby-0.7.11 lib/mercurial-ruby/diff.rb
mercurial-ruby-0.7.10 lib/mercurial-ruby/diff.rb
mercurial-ruby-0.7.9 lib/mercurial-ruby/diff.rb