Class: Mercurial::Diff

Inherits:
Object
  • Object
show all
Defined in:
lib/mercurial-ruby/diff.rb

Overview

The class represents Mercurial diff. Obtained by running an hg diff command.

The class represents Diff object itself, DiffFactory is responsible for assembling instances of Diff. For the list of all possible diff-related operations please look documentation for DiffFactory.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Diff

Returns a new instance of Diff.



27
28
29
30
31
32
33
34
# 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]
end

Instance Attribute Details

#bodyObject (readonly)

Diff body.



25
26
27
# File 'lib/mercurial-ruby/diff.rb', line 25

def body
  @body
end

#file_aObject (readonly)

Version a if the file name.



19
20
21
# File 'lib/mercurial-ruby/diff.rb', line 19

def file_a
  @file_a
end

#file_bObject (readonly)

Version b of the file name.



22
23
24
# File 'lib/mercurial-ruby/diff.rb', line 22

def file_b
  @file_b
end

#hash_aObject (readonly)

SHA1 hash of version a of the file.



13
14
15
# File 'lib/mercurial-ruby/diff.rb', line 13

def hash_a
  @hash_a
end

#hash_bObject (readonly)

SHA1 hash of version b of the file.



16
17
18
# File 'lib/mercurial-ruby/diff.rb', line 16

def hash_b
  @hash_b
end

Instance Method Details

#binary?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/mercurial-ruby/diff.rb', line 40

def binary?
  !! @binary
end

#file_nameObject



36
37
38
# File 'lib/mercurial-ruby/diff.rb', line 36

def file_name
  file_b || file_a
end