daff 1.2.6 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/bin/daff.rb +0 -0
- data/lib/daff.rb +6 -0
- data/lib/lib/coopy/alignment.rb +146 -169
- data/lib/lib/coopy/cell_builder.rb +1 -1
- data/lib/lib/coopy/cell_info.rb +2 -1
- data/lib/lib/coopy/column_change.rb +16 -0
- data/lib/lib/coopy/compare_flags.rb +33 -5
- data/lib/lib/coopy/compare_table.rb +219 -99
- data/lib/lib/coopy/coopy.rb +205 -99
- data/lib/lib/coopy/csv.rb +17 -22
- data/lib/lib/coopy/diff_render.rb +16 -8
- data/lib/lib/coopy/flat_cell_builder.rb +11 -8
- data/lib/lib/coopy/highlight_patch.rb +363 -63
- data/lib/lib/coopy/highlight_patch_unit.rb +1 -1
- data/lib/lib/coopy/index.rb +21 -8
- data/lib/lib/coopy/index_item.rb +7 -3
- data/lib/lib/coopy/index_pair.rb +13 -10
- data/lib/lib/coopy/merger.rb +3 -3
- data/lib/lib/coopy/meta.rb +17 -0
- data/lib/lib/coopy/mover.rb +7 -5
- data/lib/lib/coopy/ndjson.rb +2 -2
- data/lib/lib/coopy/nested_cell_builder.rb +7 -7
- data/lib/lib/coopy/ordering.rb +6 -2
- data/lib/lib/coopy/property_change.rb +16 -0
- data/lib/lib/coopy/row.rb +1 -0
- data/lib/lib/coopy/row_change.rb +42 -0
- data/lib/lib/coopy/row_stream.rb +11 -0
- data/lib/lib/coopy/simple_table.rb +84 -30
- data/lib/lib/coopy/simple_view.rb +8 -8
- data/lib/lib/coopy/sparse_sheet.rb +1 -1
- data/lib/lib/coopy/sql_column.rb +22 -10
- data/lib/lib/coopy/sql_compare.rb +397 -85
- data/lib/lib/coopy/sql_database.rb +2 -0
- data/lib/lib/coopy/sql_helper.rb +5 -0
- data/lib/lib/coopy/sql_table.rb +122 -19
- data/lib/lib/coopy/sql_table_name.rb +1 -1
- data/lib/lib/coopy/sqlite_helper.rb +250 -3
- data/lib/lib/coopy/table.rb +1 -0
- data/lib/lib/coopy/table_diff.rb +643 -464
- data/lib/lib/coopy/table_io.rb +19 -6
- data/lib/lib/coopy/table_modifier.rb +1 -1
- data/lib/lib/coopy/table_stream.rb +102 -0
- data/lib/lib/coopy/terminal_diff_render.rb +4 -3
- data/lib/lib/coopy/unit.rb +22 -2
- data/lib/lib/coopy/viterbi.rb +4 -4
- data/lib/lib/haxe/ds/int_map.rb +1 -1
- data/lib/lib/haxe/ds/string_map.rb +1 -1
- data/lib/lib/haxe/format/json_parser.rb +1 -1
- data/lib/lib/haxe/format/json_printer.rb +1 -1
- data/lib/lib/haxe/io/bytes.rb +2 -2
- data/lib/lib/haxe/io/eof.rb +1 -1
- data/lib/lib/haxe/io/output.rb +1 -1
- data/lib/lib/hx_overrides.rb +1 -1
- data/lib/lib/hx_sys.rb +9 -5
- data/lib/lib/lambda.rb +3 -3
- data/lib/lib/list.rb +1 -1
- data/lib/lib/rb/ruby_iterator.rb +2 -2
- data/lib/lib/reflect.rb +1 -1
- data/lib/lib/sys/io/file_output.rb +1 -1
- data/lib/lib/sys/io/hx_file.rb +1 -1
- data/lib/lib/x_list/list_iterator.rb +2 -2
- metadata +29 -25
- data/lib/lib/coopy/table_text.rb +0 -26
- data/lib/lib/haxe/io/bytes_buffer.rb +0 -19
- data/lib/lib/haxe/io/bytes_input.rb +0 -13
- data/lib/lib/haxe/io/bytes_output.rb +0 -33
- data/lib/lib/haxe/io/input.rb +0 -11
data/lib/lib/coopy/csv.rb
CHANGED
@@ -25,28 +25,23 @@ module Coopy
|
|
25
25
|
|
26
26
|
def render_table(t)
|
27
27
|
result = ""
|
28
|
-
w = t.get_width
|
29
|
-
h = t.get_height
|
30
28
|
txt = ""
|
31
29
|
v = t.get_cell_view
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
_g
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
txt += @delim if x > 0
|
43
|
-
txt += self.render_cell(v,t.get_cell(x,y))
|
44
|
-
end
|
30
|
+
stream = ::Coopy::TableStream.new(t)
|
31
|
+
w = stream.width
|
32
|
+
while(stream.fetch)
|
33
|
+
begin
|
34
|
+
_g = 0
|
35
|
+
while(_g < w)
|
36
|
+
x = _g
|
37
|
+
_g+=1
|
38
|
+
txt += @delim if x > 0
|
39
|
+
txt += self.render_cell(v,stream.get_cell(x))
|
45
40
|
end
|
46
|
-
txt += "\r\n"
|
47
41
|
end
|
42
|
+
txt += "\r\n"
|
48
43
|
end
|
49
|
-
|
44
|
+
txt
|
50
45
|
end
|
51
46
|
|
52
47
|
def render_cell(v,d)
|
@@ -89,7 +84,7 @@ module Coopy
|
|
89
84
|
end
|
90
85
|
end
|
91
86
|
result += "\"" if need_quote
|
92
|
-
|
87
|
+
result
|
93
88
|
end
|
94
89
|
|
95
90
|
def parse_table(txt,tab)
|
@@ -120,13 +115,13 @@ module Coopy
|
|
120
115
|
end
|
121
116
|
@cursor+=1
|
122
117
|
end
|
123
|
-
|
118
|
+
true
|
124
119
|
end
|
125
120
|
|
126
121
|
def make_table(txt)
|
127
122
|
tab = ::Coopy::SimpleTable.new(0,0)
|
128
123
|
self.parse_table(txt,tab)
|
129
|
-
|
124
|
+
tab
|
130
125
|
end
|
131
126
|
|
132
127
|
protected
|
@@ -191,7 +186,7 @@ module Coopy
|
|
191
186
|
return result[1..-1] if result[del..-1] == "NULL"
|
192
187
|
end
|
193
188
|
end
|
194
|
-
|
189
|
+
result
|
195
190
|
end
|
196
191
|
|
197
192
|
public
|
@@ -200,7 +195,7 @@ module Coopy
|
|
200
195
|
@cursor = 0
|
201
196
|
@row_ended = false
|
202
197
|
@has_structure = false
|
203
|
-
|
198
|
+
self.parse_cell_part(txt)
|
204
199
|
end
|
205
200
|
|
206
201
|
haxe_me ["coopy", "Csv"]
|
@@ -85,11 +85,11 @@ module Coopy
|
|
85
85
|
public
|
86
86
|
|
87
87
|
def html
|
88
|
-
|
88
|
+
@text_to_insert.join("")
|
89
89
|
end
|
90
90
|
|
91
91
|
def to_s
|
92
|
-
|
92
|
+
self.html
|
93
93
|
end
|
94
94
|
|
95
95
|
def render(tab)
|
@@ -121,7 +121,7 @@ module Coopy
|
|
121
121
|
::Coopy::DiffRender.examine_cell(off,row,view,txt,"",txt,corner,cell,off)
|
122
122
|
row_mode = cell.category
|
123
123
|
change_row = row if row_mode == "spec"
|
124
|
-
if row_mode == "header" || row_mode == "spec" || row_mode == "index"
|
124
|
+
if row_mode == "header" || row_mode == "spec" || row_mode == "index" || row_mode == "meta"
|
125
125
|
self.set_section("head")
|
126
126
|
else
|
127
127
|
self.set_section("body")
|
@@ -141,11 +141,11 @@ module Coopy
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
render.end_table
|
144
|
-
|
144
|
+
self
|
145
145
|
end
|
146
146
|
|
147
147
|
def sample_css
|
148
|
-
|
148
|
+
".highlighter .add { \n background-color: #7fff7f;\n}\n\n.highlighter .remove { \n background-color: #ff7f7f;\n}\n\n.highlighter td.modify { \n background-color: #7f7fff;\n}\n\n.highlighter td.conflict { \n background-color: #f00;\n}\n\n.highlighter .spec { \n background-color: #aaa;\n}\n\n.highlighter .move { \n background-color: #ffa;\n}\n\n.highlighter .null { \n color: #888;\n}\n\n.highlighter table { \n border-collapse:collapse;\n}\n\n.highlighter td, .highlighter th {\n border: 1px solid #2D4068;\n padding: 3px 7px 2px;\n}\n\n.highlighter th, .highlighter .header, .highlighter .meta {\n background-color: #aaf;\n font-weight: bold;\n padding-bottom: 4px;\n padding-top: 5px;\n text-align:left;\n}\n\n.highlighter tr.header th {\n border-bottom: 2px solid black;\n}\n\n.highlighter tr.index td, .highlighter .index, .highlighter tr.header th.index {\n background-color: white;\n border: none;\n}\n\n.highlighter .gap {\n color: #888;\n}\n\n.highlighter td {\n empty-cells: show;\n}\n"
|
149
149
|
end
|
150
150
|
|
151
151
|
def complete_html
|
@@ -165,12 +165,20 @@ module Coopy
|
|
165
165
|
cell.pretty_separator = ""
|
166
166
|
cell.conflicted = false
|
167
167
|
cell.updated = false
|
168
|
-
cell.pvalue = cell.lvalue = cell.rvalue = nil
|
168
|
+
cell.meta = cell.pvalue = cell.lvalue = cell.rvalue = nil
|
169
169
|
cell.value = value
|
170
170
|
cell.value = "" if cell.value == nil
|
171
171
|
cell.pretty_value = cell.value
|
172
172
|
vrow = "" if vrow == nil
|
173
173
|
vcol = "" if vcol == nil
|
174
|
+
if vrow.length >= 3 && vrow[0] == "@" && vrow[1] != "@"
|
175
|
+
idx = vrow.index("@",1 || 0) || -1
|
176
|
+
if idx >= 0
|
177
|
+
cell.meta = vrow[1,idx - 1]
|
178
|
+
vrow = vrow[idx + 1,vrow.length]
|
179
|
+
cell.category = "meta"
|
180
|
+
end
|
181
|
+
end
|
174
182
|
removed_column = false
|
175
183
|
cell.category = "move" if vrow == ":"
|
176
184
|
cell.category = "index" if vrow == "" && offset == 1 && y == 0
|
@@ -278,7 +286,7 @@ module Coopy
|
|
278
286
|
il+=1
|
279
287
|
end
|
280
288
|
end
|
281
|
-
|
289
|
+
slo
|
282
290
|
end
|
283
291
|
|
284
292
|
public
|
@@ -293,7 +301,7 @@ module Coopy
|
|
293
301
|
off = 0
|
294
302
|
end
|
295
303
|
::Coopy::DiffRender.examine_cell(x,y,view,tab.get_cell(x,y),view.to_s(tab.get_cell(x,off)),view.to_s(tab.get_cell(off,y)),corner,cell,off)
|
296
|
-
|
304
|
+
cell
|
297
305
|
end
|
298
306
|
|
299
307
|
haxe_me ["coopy", "DiffRender"]
|
@@ -4,7 +4,8 @@
|
|
4
4
|
module Coopy
|
5
5
|
class FlatCellBuilder
|
6
6
|
|
7
|
-
def initialize
|
7
|
+
def initialize(flags)
|
8
|
+
@flags = flags
|
8
9
|
end
|
9
10
|
|
10
11
|
# protected - in ruby this doesn't play well with static/inline methods
|
@@ -12,11 +13,12 @@ module Coopy
|
|
12
13
|
attr_accessor :view
|
13
14
|
attr_accessor :separator
|
14
15
|
attr_accessor :conflict_separator
|
16
|
+
attr_accessor :flags
|
15
17
|
|
16
18
|
public
|
17
19
|
|
18
20
|
def need_separator
|
19
|
-
|
21
|
+
true
|
20
22
|
end
|
21
23
|
|
22
24
|
def set_separator(separator)
|
@@ -32,19 +34,20 @@ module Coopy
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def update(local,remote)
|
35
|
-
|
37
|
+
@view.to_datum(_hx_str(::Coopy::FlatCellBuilder.quote_for_diff(@view,local)) + _hx_str(@separator) + _hx_str(::Coopy::FlatCellBuilder.quote_for_diff(@view,remote)))
|
36
38
|
end
|
37
39
|
|
38
40
|
def conflict(parent,local,remote)
|
39
|
-
|
41
|
+
_hx_str(@view.to_s(parent)) + _hx_str(@conflict_separator) + _hx_str(@view.to_s(local)) + _hx_str(@conflict_separator) + _hx_str(@view.to_s(remote))
|
40
42
|
end
|
41
43
|
|
42
44
|
def marker(label)
|
43
|
-
|
45
|
+
@view.to_datum(label)
|
44
46
|
end
|
45
47
|
|
46
|
-
def links(unit)
|
47
|
-
return @view.to_datum(unit.
|
48
|
+
def links(unit,row_like)
|
49
|
+
return @view.to_datum(unit.to_base26string) if @flags.count_like_a_spreadsheet && !row_like
|
50
|
+
@view.to_datum(unit.to_s)
|
48
51
|
end
|
49
52
|
|
50
53
|
def FlatCellBuilder.quote_for_diff(v,d)
|
@@ -63,7 +66,7 @@ module Coopy
|
|
63
66
|
end
|
64
67
|
end
|
65
68
|
str = "_" + _hx_str(str) if str[score..-1] == _nil
|
66
|
-
|
69
|
+
str
|
67
70
|
end
|
68
71
|
|
69
72
|
haxe_me ["coopy", "FlatCellBuilder"]
|
@@ -4,11 +4,14 @@
|
|
4
4
|
module Coopy
|
5
5
|
class HighlightPatch
|
6
6
|
|
7
|
-
def initialize(source,patch)
|
7
|
+
def initialize(source,patch,flags = nil)
|
8
8
|
@source = source
|
9
9
|
@patch = patch
|
10
|
+
@flags = flags
|
11
|
+
@flags = ::Coopy::CompareFlags.new if flags == nil
|
10
12
|
@view = patch.get_cell_view
|
11
13
|
@source_view = source.get_cell_view
|
14
|
+
@meta = source.get_meta
|
12
15
|
end
|
13
16
|
|
14
17
|
protected
|
@@ -35,6 +38,8 @@ module Coopy
|
|
35
38
|
attr_accessor :indexes
|
36
39
|
attr_accessor :source_in_patch_col
|
37
40
|
attr_accessor :patch_in_source_col
|
41
|
+
attr_accessor :dest_in_patch_col
|
42
|
+
attr_accessor :patch_in_dest_col
|
38
43
|
attr_accessor :patch_in_source_row
|
39
44
|
attr_accessor :last_source_row
|
40
45
|
attr_accessor :actions
|
@@ -43,6 +48,15 @@ module Coopy
|
|
43
48
|
attr_accessor :col_permutation
|
44
49
|
attr_accessor :col_permutation_rev
|
45
50
|
attr_accessor :have_dropped_columns
|
51
|
+
attr_accessor :header_row
|
52
|
+
attr_accessor :preamble_row
|
53
|
+
attr_accessor :flags
|
54
|
+
attr_accessor :meta_change
|
55
|
+
attr_accessor :process_meta
|
56
|
+
attr_accessor :prev_meta
|
57
|
+
attr_accessor :next_meta
|
58
|
+
attr_accessor :finished_columns
|
59
|
+
attr_accessor :meta
|
46
60
|
|
47
61
|
def reset
|
48
62
|
@header = {}
|
@@ -58,7 +72,7 @@ module Coopy
|
|
58
72
|
@current_row = -1
|
59
73
|
@row_info = ::Coopy::CellInfo.new
|
60
74
|
@cell_info = ::Coopy::CellInfo.new
|
61
|
-
@source_in_patch_col = @patch_in_source_col = nil
|
75
|
+
@source_in_patch_col = @patch_in_source_col = @patch_in_dest_col = nil
|
62
76
|
@patch_in_source_row = {}
|
63
77
|
@indexes = nil
|
64
78
|
@last_source_row = -1
|
@@ -68,6 +82,17 @@ module Coopy
|
|
68
82
|
@col_permutation = nil
|
69
83
|
@col_permutation_rev = nil
|
70
84
|
@have_dropped_columns = false
|
85
|
+
@header_row = 0
|
86
|
+
@preamble_row = 0
|
87
|
+
@meta_change = false
|
88
|
+
@process_meta = false
|
89
|
+
@prev_meta = nil
|
90
|
+
@next_meta = nil
|
91
|
+
@finished_columns = false
|
92
|
+
end
|
93
|
+
|
94
|
+
def process_meta
|
95
|
+
@process_meta = true
|
71
96
|
end
|
72
97
|
|
73
98
|
public
|
@@ -94,6 +119,7 @@ module Coopy
|
|
94
119
|
@actions.push(((str != nil) ? str : ""))
|
95
120
|
end
|
96
121
|
end
|
122
|
+
@preamble_row = @header_row = @rc_offset
|
97
123
|
begin
|
98
124
|
_g11 = 0
|
99
125
|
_g2 = @patch.get_height
|
@@ -103,9 +129,9 @@ module Coopy
|
|
103
129
|
self.apply_row(r1)
|
104
130
|
end
|
105
131
|
end
|
106
|
-
self.finish_rows
|
107
132
|
self.finish_columns
|
108
|
-
|
133
|
+
self.finish_rows
|
134
|
+
true
|
109
135
|
end
|
110
136
|
|
111
137
|
protected
|
@@ -130,6 +156,24 @@ module Coopy
|
|
130
156
|
end
|
131
157
|
end
|
132
158
|
|
159
|
+
def need_dest_columns
|
160
|
+
return if @patch_in_dest_col != nil
|
161
|
+
@patch_in_dest_col = {}
|
162
|
+
@dest_in_patch_col = {}
|
163
|
+
begin
|
164
|
+
_g = 0
|
165
|
+
_g1 = @cmods
|
166
|
+
while(_g < _g1.length)
|
167
|
+
cmod = _g1[_g]
|
168
|
+
_g+=1
|
169
|
+
if cmod.patch_row != -1
|
170
|
+
@patch_in_dest_col[cmod.patch_row] = cmod.dest_row
|
171
|
+
@dest_in_patch_col[cmod.dest_row] = cmod.patch_row
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
133
177
|
def need_source_index
|
134
178
|
return if @indexes != nil
|
135
179
|
state = ::Coopy::TableComparisonState.new
|
@@ -143,34 +187,111 @@ module Coopy
|
|
143
187
|
self.need_source_columns
|
144
188
|
end
|
145
189
|
|
190
|
+
def set_meta_prop(target,column_name,prop_name,value)
|
191
|
+
return if column_name == nil
|
192
|
+
return if prop_name == nil
|
193
|
+
if !target.include?(column_name)
|
194
|
+
value1 = Array.new
|
195
|
+
target[column_name] = value1
|
196
|
+
end
|
197
|
+
change = ::Coopy::PropertyChange.new
|
198
|
+
change.prev_name = prop_name
|
199
|
+
change.name = prop_name
|
200
|
+
value = nil if value == ""
|
201
|
+
change.val = value
|
202
|
+
target[column_name].push(change)
|
203
|
+
end
|
204
|
+
|
205
|
+
def apply_meta_row(code)
|
206
|
+
self.need_source_columns
|
207
|
+
codes = code.split("@")
|
208
|
+
prop_name = ""
|
209
|
+
prop_name = codes[codes.length - 2] if codes.length > 1
|
210
|
+
code = codes[codes.length - 1] if codes.length > 0
|
211
|
+
@prev_meta = {} if @prev_meta == nil
|
212
|
+
@next_meta = {} if @next_meta == nil
|
213
|
+
begin
|
214
|
+
_g1 = @payload_col
|
215
|
+
_g = @payload_top
|
216
|
+
while(_g1 < _g)
|
217
|
+
i = _g1
|
218
|
+
_g1+=1
|
219
|
+
txt = self.get_string(i)
|
220
|
+
idx_patch = i
|
221
|
+
idx_src = nil
|
222
|
+
if @patch_in_source_col.include?(idx_patch)
|
223
|
+
idx_src = @patch_in_source_col[idx_patch]
|
224
|
+
else
|
225
|
+
idx_src = -1
|
226
|
+
end
|
227
|
+
prev_name = nil
|
228
|
+
name = nil
|
229
|
+
prev_name = @source.get_cell(idx_src,0) if idx_src != -1
|
230
|
+
name = @header[idx_patch] if @header.include?(idx_patch)
|
231
|
+
::Coopy::DiffRender.examine_cell(0,0,@view,txt,"",code,"",@cell_info)
|
232
|
+
if @cell_info.updated
|
233
|
+
self.set_meta_prop(@prev_meta,prev_name,prop_name,@cell_info.lvalue)
|
234
|
+
self.set_meta_prop(@next_meta,name,prop_name,@cell_info.rvalue)
|
235
|
+
else
|
236
|
+
self.set_meta_prop(@prev_meta,prev_name,prop_name,@cell_info.value)
|
237
|
+
self.set_meta_prop(@next_meta,name,prop_name,@cell_info.value)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
146
243
|
def apply_row(r)
|
147
244
|
@current_row = r
|
148
245
|
code = @actions[r]
|
246
|
+
done = false
|
149
247
|
if r == 0 && @rc_offset > 0
|
248
|
+
done = true
|
150
249
|
elsif code == "@@"
|
250
|
+
@preamble_row = @header_row = r
|
151
251
|
self.apply_header
|
152
252
|
self.apply_action("@@")
|
253
|
+
done = true
|
153
254
|
elsif code == "!"
|
255
|
+
@preamble_row = @header_row = r
|
154
256
|
self.apply_meta
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
257
|
+
done = true
|
258
|
+
elsif (code.index("@",nil || 0) || -1) == 0
|
259
|
+
@flags.add_warning("cannot usefully apply diffs with metadata yet: '" + _hx_str(code) + "'")
|
260
|
+
@preamble_row = r
|
261
|
+
self.apply_meta_row(code)
|
262
|
+
if @process_meta
|
263
|
+
codes = code.split("@")
|
264
|
+
code = codes[codes.length - 1] if codes.length > 0
|
265
|
+
else
|
266
|
+
@meta_change = true
|
267
|
+
done = true
|
268
|
+
end
|
269
|
+
@meta_change = true
|
270
|
+
done = true
|
271
|
+
end
|
272
|
+
return if @process_meta
|
273
|
+
if !done
|
274
|
+
self.finish_columns
|
275
|
+
if code == "+++"
|
276
|
+
self.apply_action(code)
|
277
|
+
elsif code == "---"
|
278
|
+
self.apply_action(code)
|
279
|
+
elsif code == "+" || code == ":"
|
280
|
+
self.apply_action(code)
|
281
|
+
elsif (code.index("->",nil || 0) || -1) >= 0
|
282
|
+
self.apply_action("->")
|
283
|
+
else
|
284
|
+
@last_source_row = -1
|
285
|
+
end
|
165
286
|
end
|
166
287
|
end
|
167
288
|
|
168
289
|
def get_datum(c)
|
169
|
-
|
290
|
+
@patch.get_cell(c,@current_row)
|
170
291
|
end
|
171
292
|
|
172
293
|
def get_string(c)
|
173
|
-
|
294
|
+
@view.to_s(self.get_datum(c))
|
174
295
|
end
|
175
296
|
|
176
297
|
def apply_meta
|
@@ -224,12 +345,13 @@ module Coopy
|
|
224
345
|
end
|
225
346
|
end
|
226
347
|
end
|
227
|
-
|
348
|
+
if !self.use_meta_for_row_changes
|
349
|
+
self.apply_action("+++") if @source.get_height == 0
|
350
|
+
end
|
228
351
|
end
|
229
352
|
|
230
353
|
def look_up(del = 0)
|
231
|
-
|
232
|
-
return at if at != nil
|
354
|
+
return @patch_in_source_row[@current_row + del] if @patch_in_source_row.include?(@current_row + del)
|
233
355
|
result = -1
|
234
356
|
@current_row += del
|
235
357
|
if @current_row >= 0 && @current_row < @patch.get_height
|
@@ -239,9 +361,28 @@ module Coopy
|
|
239
361
|
idx = _g1[_g]
|
240
362
|
_g+=1
|
241
363
|
match = idx.query_by_content(self)
|
242
|
-
next if match.spot_a
|
243
|
-
|
244
|
-
|
364
|
+
next if match.spot_a == 0
|
365
|
+
if match.spot_a == 1
|
366
|
+
result = match.item_a.lst[0]
|
367
|
+
break
|
368
|
+
end
|
369
|
+
if @current_row > 0
|
370
|
+
prev = @patch_in_source_row[@current_row - 1]
|
371
|
+
if prev != nil
|
372
|
+
lst = match.item_a.lst
|
373
|
+
begin
|
374
|
+
_g2 = 0
|
375
|
+
while(_g2 < lst.length)
|
376
|
+
row = lst[_g2]
|
377
|
+
_g2+=1
|
378
|
+
if row == prev + 1
|
379
|
+
result = row
|
380
|
+
break
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
245
386
|
end
|
246
387
|
end
|
247
388
|
begin
|
@@ -249,10 +390,64 @@ module Coopy
|
|
249
390
|
result
|
250
391
|
end
|
251
392
|
@current_row -= del
|
252
|
-
|
393
|
+
result
|
394
|
+
end
|
395
|
+
|
396
|
+
def apply_action_external(code)
|
397
|
+
return if code == "@@"
|
398
|
+
rc = ::Coopy::RowChange.new
|
399
|
+
rc.action = code
|
400
|
+
self.check_act
|
401
|
+
rc.cond = {} if code != "+++"
|
402
|
+
rc.val = {} if code != "---"
|
403
|
+
have_column = false
|
404
|
+
begin
|
405
|
+
_g1 = @payload_col
|
406
|
+
_g = @payload_top
|
407
|
+
while(_g1 < _g)
|
408
|
+
i = _g1
|
409
|
+
_g1+=1
|
410
|
+
prev_name = @header[i]
|
411
|
+
name = prev_name
|
412
|
+
name = @header_rename[prev_name] if @header_rename.include?(prev_name)
|
413
|
+
cact = @modifier[i]
|
414
|
+
next if cact == "..."
|
415
|
+
next if name == nil || name == ""
|
416
|
+
txt = self.get_string(i)
|
417
|
+
updated = false
|
418
|
+
if @row_info.updated
|
419
|
+
self.get_pre_string(txt)
|
420
|
+
updated = @cell_info.updated
|
421
|
+
end
|
422
|
+
if cact == "+++" && code != "---"
|
423
|
+
if txt != nil && txt != ""
|
424
|
+
rc.val = {} if rc.val == nil
|
425
|
+
rc.val[name] = txt
|
426
|
+
have_column = true
|
427
|
+
end
|
428
|
+
end
|
429
|
+
if updated
|
430
|
+
rc.cond[name] = @cell_info.lvalue
|
431
|
+
rc.val[name] = @cell_info.rvalue
|
432
|
+
elsif code == "+++"
|
433
|
+
rc.val[name] = txt if cact != "---"
|
434
|
+
elsif cact != "+++" && cact != "---"
|
435
|
+
rc.cond[name] = txt
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
439
|
+
if rc.action == "+"
|
440
|
+
return if !have_column
|
441
|
+
rc.action = "->"
|
442
|
+
end
|
443
|
+
@meta.change_row(rc)
|
253
444
|
end
|
254
445
|
|
255
446
|
def apply_action(code)
|
447
|
+
if self.use_meta_for_row_changes
|
448
|
+
self.apply_action_external(code)
|
449
|
+
return
|
450
|
+
end
|
256
451
|
mod = ::Coopy::HighlightPatchUnit.new
|
257
452
|
mod.code = code
|
258
453
|
mod.add = code == "+++"
|
@@ -264,7 +459,14 @@ module Coopy
|
|
264
459
|
next_act = @actions[@current_row + 1]
|
265
460
|
mod.source_next_row = self.look_up(1) if next_act != "+++" && next_act != "..."
|
266
461
|
if mod.add
|
267
|
-
|
462
|
+
if @actions[@current_row - 1] != "+++"
|
463
|
+
if @actions[@current_row - 1] == "@@"
|
464
|
+
mod.source_prev_row = 0
|
465
|
+
@last_source_row = 0
|
466
|
+
else
|
467
|
+
mod.source_prev_row = self.look_up(-1)
|
468
|
+
end
|
469
|
+
end
|
268
470
|
mod.source_row = mod.source_prev_row
|
269
471
|
mod.source_row_offset = 1 if mod.source_row != -1
|
270
472
|
else
|
@@ -286,7 +488,7 @@ module Coopy
|
|
286
488
|
return txt if !@row_info.updated
|
287
489
|
::Coopy::DiffRender.examine_cell(0,0,@view,txt,"",@row_info.value,"",@cell_info)
|
288
490
|
return txt if !@cell_info.updated
|
289
|
-
|
491
|
+
@cell_info.lvalue
|
290
492
|
end
|
291
493
|
|
292
494
|
public
|
@@ -294,7 +496,11 @@ module Coopy
|
|
294
496
|
def get_row_string(c)
|
295
497
|
at = @source_in_patch_col[c]
|
296
498
|
return "NOT_FOUND" if at == nil
|
297
|
-
|
499
|
+
self.get_pre_string(self.get_string(at))
|
500
|
+
end
|
501
|
+
|
502
|
+
def is_preamble
|
503
|
+
@current_row <= @preamble_row
|
298
504
|
end
|
299
505
|
|
300
506
|
protected
|
@@ -308,11 +514,11 @@ module Coopy
|
|
308
514
|
return -1 if a.source_row + a.source_row_offset < b.source_row + b.source_row_offset
|
309
515
|
return 1 if a.patch_row > b.patch_row
|
310
516
|
return -1 if a.patch_row < b.patch_row
|
311
|
-
|
517
|
+
0
|
312
518
|
end
|
313
519
|
|
314
520
|
def process_mods(rmods,fate,len)
|
315
|
-
rmods.sort{|a,b| self.sort_mods(a,b)}
|
521
|
+
rmods.sort!{|a,b| self.sort_mods(a,b)}
|
316
522
|
offset = 0
|
317
523
|
last = -1
|
318
524
|
target = 0
|
@@ -348,7 +554,9 @@ module Coopy
|
|
348
554
|
if mod.source_row >= 0
|
349
555
|
last = mod.source_row + mod.source_row_offset
|
350
556
|
last+=1 if mod.rem
|
351
|
-
|
557
|
+
elsif mod.add && mod.source_next_row != -1
|
558
|
+
last = mod.source_next_row + mod.source_row_offset
|
559
|
+
elsif mod.rem || mod.add
|
352
560
|
last = -1
|
353
561
|
end
|
354
562
|
end
|
@@ -363,7 +571,17 @@ module Coopy
|
|
363
571
|
last+=1
|
364
572
|
end
|
365
573
|
end
|
366
|
-
|
574
|
+
len + offset
|
575
|
+
end
|
576
|
+
|
577
|
+
def use_meta_for_column_changes
|
578
|
+
return false if @meta == nil
|
579
|
+
@meta.use_for_column_changes
|
580
|
+
end
|
581
|
+
|
582
|
+
def use_meta_for_row_changes
|
583
|
+
return false if @meta == nil
|
584
|
+
@meta.use_for_row_changes
|
367
585
|
end
|
368
586
|
|
369
587
|
def compute_ordering(mods,permutation,permutation_rev,dim)
|
@@ -433,7 +651,7 @@ module Coopy
|
|
433
651
|
while(_g2 < dim)
|
434
652
|
i1 = _g2
|
435
653
|
_g2+=1
|
436
|
-
if meta_from_unit.include?(logical)
|
654
|
+
if logical != nil && meta_from_unit.include?(logical)
|
437
655
|
cursor = meta_from_unit[logical]
|
438
656
|
else
|
439
657
|
cursor = nil
|
@@ -482,7 +700,39 @@ module Coopy
|
|
482
700
|
self.compute_ordering(@mods,@row_permutation,@row_permutation_rev,@source.get_height)
|
483
701
|
end
|
484
702
|
|
703
|
+
def fill_in_new_columns
|
704
|
+
_g = 0
|
705
|
+
_g1 = @cmods
|
706
|
+
while(_g < _g1.length)
|
707
|
+
cmod = _g1[_g]
|
708
|
+
_g+=1
|
709
|
+
if !cmod.rem
|
710
|
+
if cmod.add
|
711
|
+
begin
|
712
|
+
_g2 = 0
|
713
|
+
_g3 = @mods
|
714
|
+
while(_g2 < _g3.length)
|
715
|
+
mod = _g3[_g2]
|
716
|
+
_g2+=1
|
717
|
+
if mod.patch_row != -1 && mod.dest_row != -1
|
718
|
+
d = @patch.get_cell(cmod.patch_row,mod.patch_row)
|
719
|
+
@source.set_cell(cmod.dest_row,mod.dest_row,d)
|
720
|
+
end
|
721
|
+
end
|
722
|
+
end
|
723
|
+
hdr = @header[cmod.patch_row]
|
724
|
+
@source.set_cell(cmod.dest_row,0,@view.to_datum(hdr))
|
725
|
+
end
|
726
|
+
end
|
727
|
+
end
|
728
|
+
end
|
729
|
+
|
485
730
|
def finish_rows
|
731
|
+
return if self.use_meta_for_row_changes
|
732
|
+
if @source.get_width == 0
|
733
|
+
@source.resize(0,0) if @source.get_height != 0
|
734
|
+
return
|
735
|
+
end
|
486
736
|
fate = Array.new
|
487
737
|
self.permute_rows
|
488
738
|
if @row_permutation.length > 0
|
@@ -497,6 +747,7 @@ module Coopy
|
|
497
747
|
@source.insert_or_delete_rows(@row_permutation,@row_permutation.length) if @row_permutation.length > 0
|
498
748
|
len = self.process_mods(@mods,fate,@source.get_height)
|
499
749
|
@source.insert_or_delete_rows(fate,len)
|
750
|
+
self.need_dest_columns
|
500
751
|
begin
|
501
752
|
_g2 = 0
|
502
753
|
_g11 = @mods
|
@@ -508,7 +759,7 @@ module Coopy
|
|
508
759
|
_it = ::Rb::RubyIterator.new(@header_post.values)
|
509
760
|
while(_it.has_next) do
|
510
761
|
c = _it._next
|
511
|
-
offset = @
|
762
|
+
offset = @patch_in_dest_col[c]
|
512
763
|
@source.set_cell(offset,mod1.dest_row,@patch.get_cell(c,mod1.patch_row)) if offset != nil && offset >= 0
|
513
764
|
end
|
514
765
|
elsif mod1.update
|
@@ -523,12 +774,26 @@ module Coopy
|
|
523
774
|
next if !@cell_info.updated
|
524
775
|
next if @cell_info.conflicted
|
525
776
|
d = @view.to_datum(@csv.parse_cell(@cell_info.rvalue))
|
526
|
-
@
|
777
|
+
offset1 = @patch_in_dest_col[c1]
|
778
|
+
@source.set_cell(@patch_in_dest_col[c1],mod1.dest_row,d) if offset1 != nil && offset1 >= 0
|
527
779
|
end
|
528
780
|
end
|
529
781
|
end
|
530
782
|
end
|
531
783
|
end
|
784
|
+
self.fill_in_new_columns
|
785
|
+
begin
|
786
|
+
_g12 = 0
|
787
|
+
_g3 = @source.get_width
|
788
|
+
while(_g12 < _g3)
|
789
|
+
i = _g12
|
790
|
+
_g12+=1
|
791
|
+
name = @view.to_s(@source.get_cell(i,0))
|
792
|
+
next_name = @header_rename[name]
|
793
|
+
next if next_name == nil
|
794
|
+
@source.set_cell(i,0,@view.to_datum(next_name))
|
795
|
+
end
|
796
|
+
end
|
532
797
|
end
|
533
798
|
|
534
799
|
def permute_columns
|
@@ -540,6 +805,8 @@ module Coopy
|
|
540
805
|
end
|
541
806
|
|
542
807
|
def finish_columns
|
808
|
+
return if @finished_columns
|
809
|
+
@finished_columns = true
|
543
810
|
self.need_source_columns
|
544
811
|
begin
|
545
812
|
_g1 = @payload_col
|
@@ -551,7 +818,8 @@ module Coopy
|
|
551
818
|
hdr = @header[i]
|
552
819
|
act = "" if act == nil
|
553
820
|
if act == "---"
|
554
|
-
at =
|
821
|
+
at = -1
|
822
|
+
at = @patch_in_source_col[i] if @patch_in_source_col.include?(i)
|
555
823
|
mod = ::Coopy::HighlightPatchUnit.new
|
556
824
|
mod.code = act
|
557
825
|
mod.rem = true
|
@@ -570,15 +838,17 @@ module Coopy
|
|
570
838
|
mod1.patch_row = i
|
571
839
|
@cmods.push(mod1)
|
572
840
|
elsif act != "..."
|
841
|
+
at1 = -1
|
842
|
+
at1 = @patch_in_source_col[i] if @patch_in_source_col.include?(i)
|
573
843
|
mod2 = ::Coopy::HighlightPatchUnit.new
|
574
844
|
mod2.code = act
|
575
845
|
mod2.patch_row = i
|
576
|
-
mod2.source_row =
|
846
|
+
mod2.source_row = at1
|
577
847
|
@cmods.push(mod2)
|
578
848
|
end
|
579
849
|
end
|
580
850
|
end
|
581
|
-
|
851
|
+
at2 = -1
|
582
852
|
rat = -1
|
583
853
|
begin
|
584
854
|
_g11 = 0
|
@@ -587,8 +857,8 @@ module Coopy
|
|
587
857
|
i1 = _g11
|
588
858
|
_g11+=1
|
589
859
|
icode = @cmods[i1].code
|
590
|
-
|
591
|
-
@cmods[i1 + 1].source_prev_row =
|
860
|
+
at2 = @cmods[i1].source_row if icode != "+++" && icode != "---"
|
861
|
+
@cmods[i1 + 1].source_prev_row = at2
|
592
862
|
j = @cmods.length - 1 - i1
|
593
863
|
jcode = @cmods[j].code
|
594
864
|
rat = @cmods[j].source_row if jcode != "+++" && jcode != "---"
|
@@ -608,49 +878,79 @@ module Coopy
|
|
608
878
|
mod3.source_row = @col_permutation[mod3.source_row] if mod3.source_row >= 0
|
609
879
|
end
|
610
880
|
end
|
611
|
-
@source.insert_or_delete_columns(@col_permutation,@col_permutation.length)
|
881
|
+
@source.insert_or_delete_columns(@col_permutation,@col_permutation.length) if !self.use_meta_for_column_changes
|
612
882
|
end
|
613
883
|
end
|
614
884
|
len = self.process_mods(@cmods,fate,@source.get_width)
|
615
|
-
|
885
|
+
if !self.use_meta_for_column_changes
|
886
|
+
@source.insert_or_delete_columns(fate,len)
|
887
|
+
return
|
888
|
+
end
|
889
|
+
changed = false
|
616
890
|
begin
|
617
891
|
_g4 = 0
|
618
892
|
_g13 = @cmods
|
619
893
|
while(_g4 < _g13.length)
|
620
|
-
|
894
|
+
mod4 = _g13[_g4]
|
621
895
|
_g4+=1
|
622
|
-
if
|
623
|
-
|
624
|
-
|
625
|
-
_g21 = 0
|
626
|
-
_g31 = @mods
|
627
|
-
while(_g21 < _g31.length)
|
628
|
-
mod4 = _g31[_g21]
|
629
|
-
_g21+=1
|
630
|
-
if mod4.patch_row != -1 && mod4.dest_row != -1
|
631
|
-
d = @patch.get_cell(cmod.patch_row,mod4.patch_row)
|
632
|
-
@source.set_cell(cmod.dest_row,mod4.dest_row,d)
|
633
|
-
end
|
634
|
-
end
|
635
|
-
end
|
636
|
-
hdr1 = @header[cmod.patch_row]
|
637
|
-
@source.set_cell(cmod.dest_row,0,@view.to_datum(hdr1))
|
638
|
-
end
|
896
|
+
if mod4.code != ""
|
897
|
+
changed = true
|
898
|
+
break
|
639
899
|
end
|
640
900
|
end
|
641
901
|
end
|
902
|
+
return if !changed
|
903
|
+
columns = Array.new
|
904
|
+
target = {}
|
905
|
+
inc = lambda {|x|
|
906
|
+
if x < 0
|
907
|
+
return x
|
908
|
+
else
|
909
|
+
return x + 1
|
910
|
+
end
|
911
|
+
}
|
642
912
|
begin
|
643
913
|
_g14 = 0
|
644
|
-
_g5 =
|
914
|
+
_g5 = fate.length
|
645
915
|
while(_g14 < _g5)
|
646
916
|
i2 = _g14
|
647
917
|
_g14+=1
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
918
|
+
begin
|
919
|
+
value = (inc).call(fate[i2])
|
920
|
+
target[i2] = value
|
921
|
+
end
|
922
|
+
end
|
923
|
+
end
|
924
|
+
self.need_source_columns
|
925
|
+
self.need_dest_columns
|
926
|
+
begin
|
927
|
+
_g15 = 1
|
928
|
+
_g6 = @patch.get_width
|
929
|
+
while(_g15 < _g6)
|
930
|
+
idx_patch = _g15
|
931
|
+
_g15+=1
|
932
|
+
change = ::Coopy::ColumnChange.new
|
933
|
+
idx_src = nil
|
934
|
+
if @patch_in_source_col.include?(idx_patch)
|
935
|
+
idx_src = @patch_in_source_col[idx_patch]
|
936
|
+
else
|
937
|
+
idx_src = -1
|
938
|
+
end
|
939
|
+
prev_name = nil
|
940
|
+
name = nil
|
941
|
+
prev_name = @source.get_cell(idx_src,0) if idx_src != -1
|
942
|
+
if @modifier[idx_patch] != "---"
|
943
|
+
name = @header[idx_patch] if @header.include?(idx_patch)
|
944
|
+
end
|
945
|
+
change.prev_name = prev_name
|
946
|
+
change.name = name
|
947
|
+
if @next_meta != nil
|
948
|
+
change.props = @next_meta[name] if @next_meta.include?(name)
|
949
|
+
end
|
950
|
+
columns.push(change)
|
652
951
|
end
|
653
952
|
end
|
953
|
+
@meta.alter_columns(columns)
|
654
954
|
end
|
655
955
|
|
656
956
|
haxe_me ["coopy", "HighlightPatch"]
|