Class: PVN::Diff::StatusPaths

Inherits:
Paths
  • Object
show all
Includes:
Loggable
Defined in:
lib/pvn/diff/status_paths.rb

Overview

represents the log entries from one revision through another.

Instance Method Summary collapse

Methods inherited from Paths

#[], #each, #initialize, #size, #to_map

Constructor Details

This class inherits a constructor from PVN::Diff::Paths

Instance Method Details

#add(elmt, url) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pvn/diff/status_paths.rb', line 20

def add elmt, url
  status = elmt.find_files_by_status
  info "status: #{status}"
  status.entries.each do |entry|
    # we don't care about unversioned entries for diffing.
    next if entry.status == 'unversioned'
    
    info "@revision: #{@revision}"
    info "entry: #{entry}"
    # svn log prepends /; svn status does not
    name = '/' + entry.path
    info "name: #{name}"
    rev = :working_copy
    info "rev: #{rev}"

    # what Status::Entry calls a status, we call an action, unifying it with
    # svn log representation.
    action = entry.status
    info "action: #{action}"
    revisions = get_status_revisions entry
    info "revisions: #{revisions}"

    info "status.revision: #{entry.status_revision}"

    @elements << Path.new(name, entry.status_revision, action, url)
  end
end

#add_for_path(path) ⇒ Object



13
14
15
16
17
18
# File 'lib/pvn/diff/status_paths.rb', line 13

def add_for_path path
  pathelmt = PVN::IO::Element.new :local => path
  pathinfo = pathelmt.get_info
  elmt = PVN::IO::Element.new :local => path
  add elmt, pathinfo.url
end

#get_status_revisions(status_entry) ⇒ Object

this may belong in Status::Entry



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/pvn/diff/status_paths.rb', line 49

def get_status_revisions status_entry
  # the printing revision in svn (svn diff -r20) are confusing, but this
  # is what it looks like:

  # when a file is added locally
  #     the revisions are (0, 0)
  # when a file is modified:
  #     if the file is modified in other revisions since givenfromrev
  #         the revision is (most recent rev, working copy)
  #     otherwise
  #         the revision is (previous revision, working copy)
  # when a file is deleted:
  #     the revision is (given from rev, working copy)

  # okay, summary #2:

  # if a file is modified,
  #     if the file existed at fromrev
  #         it is compared with fromrev
  #     else
  #         it is compared to BASE

  info "status_entry.status: #{status_entry.status}"

  action = SVNx::Action.new status_entry.status
  case
  when action.added?
    info "added"
    [ 0, 0 ]
  when action.deleted?
    info "deleted"
    [ @revision.from, :working_copy ]
  when action.modified?
    info "modified"
    [ status_entry.status_revision, :working_copy ]
  end
end