Class: PVN::Diff::LogPath
Overview
this is a path wrapping a log entry; it could also be a RemotePath or a RepoPath.
Instance Attribute Summary
Attributes inherited from Path
Instance Method Summary collapse
- #diff_revision_to_revision(revision, whitespace) ⇒ Object
- #diff_revision_to_working_copy(revision, whitespace) ⇒ Object
- #get_diff_revision(change, revision) ⇒ Object
-
#get_display_path ⇒ Object
log entries have names of the form /foo/bar.rb, relative to the URL.
- #is_revision_later_than?(revision) ⇒ Boolean
- #revisions_later_than(revision) ⇒ Object
- #show_as_added(elmt, path, revision, whitespace) ⇒ Object
- #show_as_deleted(elmt, path, revision, whitespace) ⇒ Object
-
#show_as_modified(elmt, path, fromrev, torev, revision, whitespace) ⇒ Object
the “path” parameter is the displayed name; “logpath” is the LogPath.
Methods inherited from Path
#add_change, #initialize, #run_diff, #run_diff_command, #to_revision, #to_revision_string, #to_s
Constructor Details
This class inherits a constructor from PVN::Diff::Path
Instance Method Details
#diff_revision_to_revision(revision, whitespace) ⇒ Object
39 40 41 42 43 44 45 46 47 48 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 |
# File 'lib/pvn/diff/log_path.rb', line 39 def diff_revision_to_revision revision, whitespace logpath = self info "name: #{name}" # all the paths will be the same, so any can be selected (actually, a # logpath should have multiple changes) svnpath = url + name info "svnpath: #{svnpath}" elmt = PVN::IO::Element.new :svn => svnpath displaypath = get_display_path info "revision.from: #{revision.from}".cyan rev_change = changes.detect do |chg| revarg = PVN::Revision::Argument.new chg.revision revarg > revision.from end info "rev_change: #{rev_change}".green # we ignore unversioned logpaths # I'm sure there is a bunch of permutations here, so this is probably # overly simplistic. action = rev_change.action case when action.added? show_as_added elmt, displaypath, revision, whitespace when action.deleted? show_as_deleted elmt, displaypath, revision, whitespace when action.modified? firstrev = changes[0].revision lastrev = changes[-1].revision fromrev, torev = if firstrev == lastrev [ revision.from.value.to_i - 1, revision.to ] else [ firstrev.to_i - 1, lastrev ] end show_as_modified elmt, displaypath, firstrev, torev, revision, whitespace end end |
#diff_revision_to_working_copy(revision, whitespace) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/pvn/diff/log_path.rb', line 97 def diff_revision_to_working_copy revision, whitespace fromrev = revision.from.value.to_i ### $$$ this doesn't handle the case where a file has been added, then ### modified. change = revisions_later_than(fromrev).first info "change: #{change}".red # revision should be a class here, not a primitive diffrev = get_diff_revision change, revision display_path = get_display_path pn = Pathname.new display_path svnpath = url + name info "svnpath: #{svnpath}" elmt = PVN::IO::Element.new :svn => svnpath if change.action.added? show_as_added elmt, display_path, revision, whitespace else fromlines = elmt.cat diffrev info "fromlines.size: #{fromlines.size}" pp fromlines tolines = pn.readlines info "tolines.size: #{tolines.size}" pp tolines run_diff display_path, fromlines, diffrev, tolines, nil, whitespace end end |
#get_diff_revision(change, revision) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/pvn/diff/log_path.rb', line 83 def get_diff_revision change, revision info "change: #{change}" info "revision: #{revision}" # find the first revision where logpath was in svn, no earlier than the # revision.from value if change.action.added? return change.revision.to_i elsif change.revision.to_i >= revision.from.value return revision.from.value else nil end end |
#get_display_path ⇒ Object
log entries have names of the form /foo/bar.rb, relative to the URL.
35 36 37 |
# File 'lib/pvn/diff/log_path.rb', line 35 def get_display_path name[1 .. -1] end |
#is_revision_later_than?(revision) ⇒ Boolean
132 133 134 |
# File 'lib/pvn/diff/log_path.rb', line 132 def is_revision_later_than? revision revisions_later_than(revision).first end |
#revisions_later_than(revision) ⇒ Object
136 137 138 139 140 141 142 143 |
# File 'lib/pvn/diff/log_path.rb', line 136 def revisions_later_than revision changes.select do |chg| info "chg: #{chg.revision.inspect}" x = PVN::Revision::Argument.new chg.revision y = PVN::Revision::Argument.new revision x > y end end |
#show_as_added(elmt, path, revision, whitespace) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/pvn/diff/log_path.rb', line 21 def show_as_added elmt, path, revision, whitespace info "path: #{path}".on_blue tolines = elmt.cat revision.to info "tolines: #{tolines}".blue run_diff path, nil, 0, tolines, revision.to, whitespace end |
#show_as_deleted(elmt, path, revision, whitespace) ⇒ Object
28 29 30 31 32 |
# File 'lib/pvn/diff/log_path.rb', line 28 def show_as_deleted elmt, path, revision, whitespace fromrev = revision.from.value.to_i fromlines = elmt.cat fromrev run_diff path, fromlines, fromrev, nil, revision.to, whitespace end |
#show_as_modified(elmt, path, fromrev, torev, revision, whitespace) ⇒ Object
the “path” parameter is the displayed name; “logpath” is the LogPath. These are in the process of refactoring.
14 15 16 17 18 19 |
# File 'lib/pvn/diff/log_path.rb', line 14 def show_as_modified elmt, path, fromrev, torev, revision, whitespace fromlines = elmt.cat fromrev tolines = elmt.cat torev fromrev = revision.from.value.to_i run_diff path, fromlines, fromrev, tolines, revision.to, whitespace end |