Class: PVN::Diff::LocalPath

Inherits:
Path
  • Object
show all
Defined in:
lib/pvn/diff/local_path.rb

Instance Attribute Summary

Attributes inherited from Path

#changes, #name, #url

Instance Method Summary collapse

Methods inherited from Path

#<=>, #add_change, #to_revision, #to_s

Constructor Details

#initialize(entry) ⇒ LocalPath

that’s a Status::Entry



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pvn/diff/local_path.rb', line 10

def initialize entry
  @entry = entry
  @elmt = PVN::IO::Element.new :local => @entry.path
  name = entry.path
  action = SVNx::Action.new @entry.status
  info "action: #{action}".color('#4addaf')
  revision = if action.added?
               0
             elsif action.unversioned?
               nil
             else
               @elmt.get_info.revision
             end
  super name, revision, action, nil
end

Instance Method Details

#get_latest_revisionObject



49
50
51
52
# File 'lib/pvn/diff/local_path.rb', line 49

def get_latest_revision
  svninfo = @elmt.get_info
  svninfo.revision
end

#get_remote_linesObject



54
55
56
57
# File 'lib/pvn/diff/local_path.rb', line 54

def get_remote_lines
  # revision = nil; use_cache = false
  @elmt.cat nil, false
end

#read_working_copyObject



44
45
46
47
# File 'lib/pvn/diff/local_path.rb', line 44

def read_working_copy
  pn = Pathname.new @entry.path
  pn.readlines
end

#run_diff(from_lines, from_rev, to_lines, to_rev, whitespace) ⇒ Object



59
60
61
# File 'lib/pvn/diff/local_path.rb', line 59

def run_diff from_lines, from_rev, to_lines, to_rev, whitespace
  super @entry.path, from_lines, from_rev, to_lines, to_rev, whitespace
end

#show_as_addedObject



63
64
65
# File 'lib/pvn/diff/local_path.rb', line 63

def show_as_added
  run_diff nil, 0, read_working_copy, 0, nil
end

#show_as_deletedObject



67
68
69
70
# File 'lib/pvn/diff/local_path.rb', line 67

def show_as_deleted
  fromrev = changes[0].revision
  run_diff get_remote_lines, fromrev, nil, nil, nil
end

#show_as_modified(whitespace) ⇒ Object



72
73
74
75
# File 'lib/pvn/diff/local_path.rb', line 72

def show_as_modified whitespace
  fromrev = changes[0].revision
  run_diff get_remote_lines, fromrev, read_working_copy, nil, whitespace
end

#show_diff(whitespace = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pvn/diff/local_path.rb', line 26

def show_diff whitespace = nil
  info "@entry.status: #{@entry.status}".color('#22c3c3')
  # crappy programming here. this should be pushed into PVN::Element.
  st = @entry.status
  if st.modified?
    show_as_modified whitespace
  elsif st.deleted?
    show_as_deleted
  elsif st.added?
    show_as_added
  end
end

#use_cache?Boolean

$$$ todo: integrate these, from old diff/diffcmd

Returns:

  • (Boolean)


40
41
42
# File 'lib/pvn/diff/local_path.rb', line 40

def use_cache?
  super && !against_head?
end