Class: PVN::Diff::RepositoryDiffer
- Inherits:
-
Differ
- Object
- Differ
- PVN::Diff::RepositoryDiffer
show all
- Includes:
- Loggable
- Defined in:
- lib/pvn/diff/repository_differ.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Differ
#run_diff, #run_diff_command, #to_revision_string, #write_to_temp
Constructor Details
Returns a new instance of RepositoryDiffer.
18
19
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/pvn/diff/repository_differ.rb', line 18
def initialize options
paths = options.paths
paths = %w{ . } if paths.empty?
@whitespace = options.whitespace
rev = options.revision
change = options.change
if rev[1].nil? || rev[1].to == :working_copy
end
fromrev = if change
change.to_i - 1
else
rev[0].to_i
end
@revision = RevisionRange.new change, rev
logpaths = LogPaths.new @revision, paths
name_to_logpath = logpaths.to_map
name_to_logpath.sort.each do |name, logpath|
if is_revision_later_than? logpath, fromrev
diff_logpath logpath
end
end
return if true
if @revision.working_copy?
statuspaths = StatusPaths.new @revision, paths
info "statuspaths: #{statuspaths}".on_blue
statuspaths.each do |stpath|
info "stpath: #{stpath}".on_green
end
end
end
|
Instance Attribute Details
#revision ⇒ Object
Returns the value of attribute revision.
16
17
18
|
# File 'lib/pvn/diff/repository_differ.rb', line 16
def revision
@revision
end
|
#whitespace ⇒ Object
Returns the value of attribute whitespace.
15
16
17
|
# File 'lib/pvn/diff/repository_differ.rb', line 15
def whitespace
@whitespace
end
|
Instance Method Details
#diff_logpath(logpath) ⇒ Object
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/pvn/diff/repository_differ.rb', line 93
def diff_logpath logpath
info "logpath.name: #{logpath.name}"
name = logpath.name
revisions = logpath.path_revisions
svnurl = logpath.url
info "svnurl: #{svnurl}"
svnpath = svnurl + name
info "svnpath: #{svnpath}"
elmt = PVN::IO::Element.new :svn => svnpath
displaypath = name[1 .. -1]
info "displaypath: #{displaypath}"
firstrev = revisions[0].revision
info "firstrev: #{firstrev}".yellow
lastrev = revisions[-1].revision
action = logpath.action
info "action: #{action}".on_blue
pathrevs = logpath.path_revisions
info "pathrevs: #{pathrevs}".green
info "@revision.from: #{@revision.from}".cyan
pathrevs = logpath.path_revisions.select do |rev|
info "rev.revision: #{rev.revision.inspect}".cyan
revarg = PVN::Revision::Argument.new rev.revision
revarg > @revision.from
end
info "pathrevs: #{pathrevs}".green
firstaction = pathrevs[0].action
case
when firstaction.added?
show_as_added elmt, displaypath
when firstaction.deleted?
show_as_deleted elmt, displaypath
when firstaction.modified?
fromrev, torev = if firstrev == lastrev
[ @revision.from.value.to_i - 1, @revision.to ]
else
[ firstrev.to_i - 1, lastrev ]
end
info "firstrev: #{firstrev.inspect}"
info "torev: #{torev.inspect}"
show_as_modified elmt, displaypath, firstrev, torev
end
end
|
#is_revision_later_than?(logpath, revision) ⇒ Boolean
63
64
65
66
67
68
69
70
|
# File 'lib/pvn/diff/repository_differ.rb', line 63
def is_revision_later_than? logpath, revision
logpath.path_revisions.detect do |rev|
info "rev.revision: #{rev.revision.inspect}".cyan
x = PVN::Revision::Argument.new rev.revision
y = PVN::Revision::Argument.new revision
x > y
end
end
|
#show_as_added(elmt, path) ⇒ Object
80
81
82
83
84
|
# File 'lib/pvn/diff/repository_differ.rb', line 80
def show_as_added elmt, path
info "elmt: #{elmt}"
tolines = elmt.cat @revision.to
run_diff path, nil, 0, tolines, @revision.to
end
|
#show_as_deleted(elmt, path) ⇒ Object
86
87
88
89
90
91
|
# File 'lib/pvn/diff/repository_differ.rb', line 86
def show_as_deleted elmt, path
info "elmt: #{elmt}"
fromrev = @revision.from.value.to_i
fromlines = elmt.cat fromrev
run_diff path, fromlines, fromrev, nil, @revision.to
end
|
#show_as_modified(elmt, path, fromrev, torev) ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/pvn/diff/repository_differ.rb', line 72
def show_as_modified elmt, path, fromrev, torev
info "elmt: #{elmt}"
fromlines = elmt.cat fromrev
tolines = elmt.cat torev
fromrev = @revision.from.value.to_i
run_diff path, fromlines, fromrev, tolines, @revision.to
end
|