Class: PVN::Diff::LogPath
- Inherits:
-
Path
- Object
- Path
- PVN::Diff::LogPath
show all
- Defined in:
- lib/pvn/diff/log_path.rb
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
#changes, #name, #url
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, changes, revision, whitespace) ⇒ Object
the “path” parameter is the displayed name; “logpath” is the LogPath.
Methods inherited from Path
#<=>, #add_change, #initialize, #run_diff, #to_revision, #to_s
Instance Method Details
#diff_revision_to_revision(revision, whitespace) ⇒ Object
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
|
# File 'lib/pvn/diff/log_path.rb', line 45
def diff_revision_to_revision revision, whitespace
svnpath = url + name
elmt = PVN::IO::Element.new :svn => svnpath
displaypath = get_display_path
rev_change = changes.detect do |chg|
revarg = SVNx::Revision::Argument.create chg.revision
revarg > revision.from
end
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?
show_as_modified elmt, displaypath, changes, revision, whitespace
end
end
|
#diff_revision_to_working_copy(revision, whitespace) ⇒ Object
88
89
90
91
92
93
94
95
96
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
|
# File 'lib/pvn/diff/log_path.rb', line 88
def diff_revision_to_working_copy revision, whitespace
fromrev = revision.from.value.to_i
change = revisions_later_than(fromrev).first
info "change: #{change}".color(:red)
diffrev = get_diff_revision change, revision
displaypath = get_display_path
pn = Pathname.new displaypath
info "url: #{url}"
info "name: #{name}"
svnpath = url + name
info "svnpath: #{svnpath}"
elmt = PVN::IO::Element.new :svn => svnpath
if change.action.added?
show_as_added elmt, displaypath, revision, whitespace
else
fromlines = elmt.cat diffrev
info "fromlines.size: #{fromlines.size}"
tolines = pn.readlines
info "tolines.size: #{tolines.size}"
run_diff displaypath, fromlines, diffrev, tolines, nil, whitespace
end
end
|
#get_diff_revision(change, revision) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/pvn/diff/log_path.rb', line 74
def get_diff_revision change, revision
info "change: #{change.class}"
info "change.action: #{change.action}"
if change.action.added?
change.revision.to_i
elsif change.revision.to_i >= revision.from.value
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.
41
42
43
|
# File 'lib/pvn/diff/log_path.rb', line 41
def get_display_path
name[1 .. -1]
end
|
#is_revision_later_than?(revision) ⇒ Boolean
126
127
128
|
# File 'lib/pvn/diff/log_path.rb', line 126
def is_revision_later_than? revision
revisions_later_than(revision).first
end
|
#revisions_later_than(revision) ⇒ Object
130
131
132
133
134
135
136
|
# File 'lib/pvn/diff/log_path.rb', line 130
def revisions_later_than revision
changes.select do |chg|
x = SVNx::Revision::Argument.create chg.revision
y = SVNx::Revision::Argument.create revision
x > y
end
end
|
#show_as_added(elmt, path, revision, whitespace) ⇒ Object
29
30
31
32
|
# File 'lib/pvn/diff/log_path.rb', line 29
def show_as_added elmt, path, revision, whitespace
tolines = elmt.cat revision.to
run_diff path, nil, 0, tolines, revision.to, whitespace
end
|
#show_as_deleted(elmt, path, revision, whitespace) ⇒ Object
34
35
36
37
38
|
# File 'lib/pvn/diff/log_path.rb', line 34
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, changes, revision, whitespace) ⇒ Object
the “path” parameter is the displayed name; “logpath” is the LogPath. These are in the process of being refactored.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/pvn/diff/log_path.rb', line 14
def show_as_modified elmt, path, changes, revision, whitespace
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
fromlines = elmt.cat firstrev
tolines = elmt.cat torev
fromrev = revision.from.value.to_i
run_diff path, fromlines, fromrev, tolines, revision.to, whitespace
end
|