class Mercurial::Diff

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}.

Attributes

body[R]

Diff body.

file_a[R]

Version a of the file name.

file_b[R]

Version b of the file name.

hash_a[R]

SHA1 hash of version a of the file.

hash_b[R]

SHA1 hash of version b of the file.

Public Class Methods

new(opts={}) click to toggle source
# File lib/mercurial-ruby/diff.rb, line 27
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

Public Instance Methods

binary?() click to toggle source
# File lib/mercurial-ruby/diff.rb, line 45
def binary?
  !! @binary
end
file_name() click to toggle source
# File lib/mercurial-ruby/diff.rb, line 41
def file_name
  file_b || file_a
end