daff 1.3.19 → 1.3.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/daff.rb +4 -2
- data/lib/lib/coopy/compare_table.rb +4 -1
- data/lib/lib/coopy/conflict_info.rb +23 -0
- data/lib/lib/coopy/coopy.rb +103 -59
- data/lib/lib/coopy/csv.rb +75 -8
- data/lib/lib/coopy/diff_summary.rb +28 -0
- data/lib/lib/coopy/merger.rb +11 -0
- data/lib/lib/coopy/mover.rb +2 -2
- data/lib/lib/coopy/table_diff.rb +67 -6
- data/lib/lib/coopy/terminal_diff_render.rb +17 -6
- data/lib/lib/rb/boot.rb +3 -3
- data/lib/lib/type.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 789c2b60552eec41ff58691630caade704b305ef
|
4
|
+
data.tar.gz: 9952f96cbeb8c69fb24ef6986bf331262a7afa45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7e34325bb072173c308b36003d75247c715b12ce43cb4f86c6cb61cd0ff7ec21ef58f9ba99ee9df03ef4e7524731b6bf5414a2788a225301ce00531398f6c5f
|
7
|
+
data.tar.gz: 0d1324b67cb9a37853fcf7af02c5357153d9b23fc9c53e7629e17ae9cc6f4415cee46d8c22a414bf425743f34fe7d90548f8c3fd550ceb4ff4fc2c8a6adb0c36
|
data/lib/daff.rb
CHANGED
@@ -16,14 +16,14 @@ def haxe_me(source_name)
|
|
16
16
|
end
|
17
17
|
old_get = instance_method(:[]) rescue nil
|
18
18
|
define_method(:[]) do |x|
|
19
|
-
return old_get.bind(self).(x) if x.is_a?(
|
19
|
+
return old_get.bind(self).(x) if x.is_a?(Integer)
|
20
20
|
tag = _haxe_vars_[x]
|
21
21
|
return instance_variable_get(tag) if tag
|
22
22
|
method x
|
23
23
|
end
|
24
24
|
old_set = instance_method(:[]=) rescue nil
|
25
25
|
define_method(:[]=) do |x,y|
|
26
|
-
return old_set.bind(self).(x,y) if x.is_a?(
|
26
|
+
return old_set.bind(self).(x,y) if x.is_a?(Integer)
|
27
27
|
instance_variable_set(_haxe_vars_[x],y)
|
28
28
|
end
|
29
29
|
define_method(:haxe_name) do
|
@@ -57,10 +57,12 @@ require_relative 'lib/coopy/combined_table_body'
|
|
57
57
|
require_relative 'lib/coopy/combined_table_head'
|
58
58
|
require_relative 'lib/coopy/compare_flags'
|
59
59
|
require_relative 'lib/coopy/compare_table'
|
60
|
+
require_relative 'lib/coopy/conflict_info'
|
60
61
|
require_relative 'lib/coopy/coopy'
|
61
62
|
require_relative 'lib/coopy/cross_match'
|
62
63
|
require_relative 'lib/coopy/csv'
|
63
64
|
require_relative 'lib/coopy/diff_render'
|
65
|
+
require_relative 'lib/coopy/diff_summary'
|
64
66
|
require_relative 'lib/coopy/flat_cell_builder'
|
65
67
|
require_relative 'lib/coopy/row'
|
66
68
|
require_relative 'lib/coopy/highlight_patch'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class ConflictInfo
|
6
|
+
|
7
|
+
def initialize(row,col,pvalue,lvalue,rvalue)
|
8
|
+
@row = row
|
9
|
+
@col = col
|
10
|
+
@pvalue = pvalue
|
11
|
+
@lvalue = lvalue
|
12
|
+
@rvalue = rvalue
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_accessor :row
|
16
|
+
attr_accessor :col
|
17
|
+
attr_accessor :pvalue
|
18
|
+
attr_accessor :lvalue
|
19
|
+
attr_accessor :rvalue
|
20
|
+
haxe_me ["coopy", "ConflictInfo"]
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/lib/coopy/coopy.rb
CHANGED
@@ -13,6 +13,7 @@ module Coopy
|
|
13
13
|
|
14
14
|
attr_accessor :format_preference
|
15
15
|
attr_accessor :delim_preference
|
16
|
+
attr_accessor :csv_eol_preference
|
16
17
|
attr_accessor :extern_preference
|
17
18
|
attr_accessor :output_format
|
18
19
|
attr_accessor :output_format_set
|
@@ -31,6 +32,7 @@ module Coopy
|
|
31
32
|
@extern_preference = false
|
32
33
|
@format_preference = nil
|
33
34
|
@delim_preference = nil
|
35
|
+
@csv_eol_preference = nil
|
34
36
|
@output_format = "copy"
|
35
37
|
@output_format_set = false
|
36
38
|
@nested_output = false
|
@@ -67,6 +69,10 @@ module Coopy
|
|
67
69
|
when "ssv"
|
68
70
|
@format_preference = "csv"
|
69
71
|
@delim_preference = ";"
|
72
|
+
@format_preference = "csv"
|
73
|
+
when "psv"
|
74
|
+
@format_preference = "csv"
|
75
|
+
@delim_preference = [128169].pack("U")
|
70
76
|
when "sqlite3"
|
71
77
|
@format_preference = "sqlite"
|
72
78
|
when "sqlite"
|
@@ -133,7 +139,7 @@ module Coopy
|
|
133
139
|
@format_preference = "csv" if @format_preference == "sqlite" && !@extern_preference
|
134
140
|
if render == nil
|
135
141
|
if @format_preference == "csv"
|
136
|
-
csv = ::Coopy::Csv.new(@delim_preference)
|
142
|
+
csv = ::Coopy::Csv.new(@delim_preference,@csv_eol_preference)
|
137
143
|
txt = csv.render_table(t)
|
138
144
|
elsif @format_preference == "ndjson"
|
139
145
|
txt = ::Coopy::Ndjson.new(t).render
|
@@ -153,12 +159,12 @@ module Coopy
|
|
153
159
|
txt
|
154
160
|
end
|
155
161
|
|
156
|
-
def save_tables(name,os,use_color)
|
162
|
+
def save_tables(name,os,use_color,is_diff)
|
157
163
|
self.set_format(@output_format) if @output_format != "copy"
|
158
164
|
txt = ""
|
159
165
|
self.check_format(name)
|
160
166
|
render = nil
|
161
|
-
render = ::Coopy::TerminalDiffRender.new(@flags) if use_color
|
167
|
+
render = ::Coopy::TerminalDiffRender.new(@flags,@delim_preference,is_diff) if use_color
|
162
168
|
order = os.get_order
|
163
169
|
return self.save_table(name,os.one,render) if order.length == 1
|
164
170
|
return self.render_tables(name,os) if @format_preference == "html" || @format_preference == "www"
|
@@ -270,22 +276,27 @@ module Coopy
|
|
270
276
|
output
|
271
277
|
end
|
272
278
|
|
273
|
-
def
|
274
|
-
ct = ::Coopy::Coopy.compare_tables3(parent,a,b,flags)
|
275
|
-
align = ct.align
|
276
|
-
td = ::Coopy::TableDiff.new(align,flags)
|
277
|
-
o = ::Coopy::SimpleTable.new(0,0)
|
278
|
-
os = ::Coopy::Tables.new(o)
|
279
|
-
td.hilite_with_nesting(os)
|
279
|
+
def use_color(flags,output)
|
280
280
|
use_color = flags.terminal_format == "ansi"
|
281
281
|
if flags.terminal_format == nil
|
282
|
-
if (output == nil || output == "-") && (@output_format == "copy" || @output_format == "csv")
|
282
|
+
if (output == nil || output == "-") && (@output_format == "copy" || @output_format == "csv" || @output_format == "psv")
|
283
283
|
if @io != nil
|
284
284
|
use_color = @io.is_tty if @io.is_tty_known
|
285
285
|
end
|
286
286
|
end
|
287
287
|
end
|
288
|
-
|
288
|
+
use_color
|
289
|
+
end
|
290
|
+
|
291
|
+
def run_diff(parent,a,b,flags,output)
|
292
|
+
ct = ::Coopy::Coopy.compare_tables3(parent,a,b,flags)
|
293
|
+
align = ct.align
|
294
|
+
td = ::Coopy::TableDiff.new(align,flags)
|
295
|
+
o = ::Coopy::SimpleTable.new(0,0)
|
296
|
+
os = ::Coopy::Tables.new(o)
|
297
|
+
td.hilite_with_nesting(os)
|
298
|
+
use_color = self.use_color(flags,output)
|
299
|
+
self.save_tables(output,os,use_color,true)
|
289
300
|
end
|
290
301
|
|
291
302
|
public
|
@@ -322,6 +333,7 @@ module Coopy
|
|
322
333
|
csv = ::Coopy::Csv.new(@delim_preference)
|
323
334
|
output = ::Coopy::SimpleTable.new(0,0)
|
324
335
|
csv.parse_table(txt,output)
|
336
|
+
@csv_eol_preference = csv.get_discovered_eol if @csv_eol_preference == nil
|
325
337
|
output.trim_blank if output != nil
|
326
338
|
output
|
327
339
|
end
|
@@ -658,6 +670,24 @@ module Coopy
|
|
658
670
|
@flags.padding_strategy = args[i + 1]
|
659
671
|
args.slice!(i,2)
|
660
672
|
break
|
673
|
+
elsif tag == "-e" || tag == "--eol"
|
674
|
+
more = true
|
675
|
+
ending = args[i + 1]
|
676
|
+
if ending == "crlf"
|
677
|
+
ending = "\r\n"
|
678
|
+
elsif ending == "lf"
|
679
|
+
ending = "\n"
|
680
|
+
elsif ending == "cr"
|
681
|
+
ending = "\r"
|
682
|
+
elsif ending == "auto"
|
683
|
+
ending = nil
|
684
|
+
else
|
685
|
+
io.write_stderr("Expected line ending of either 'crlf' or 'lf' but got " + _hx_str(ending) + "\n")
|
686
|
+
return 1
|
687
|
+
end
|
688
|
+
@csv_eol_preference = ending
|
689
|
+
args.slice!(i,2)
|
690
|
+
break
|
661
691
|
end
|
662
692
|
end
|
663
693
|
end
|
@@ -692,57 +722,69 @@ module Coopy
|
|
692
722
|
io.write_stderr("\n")
|
693
723
|
return 0
|
694
724
|
end
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
725
|
+
if args.length < 1
|
726
|
+
io.write_stderr("daff can produce and apply tabular diffs.\n")
|
727
|
+
io.write_stderr("Call as:\n")
|
728
|
+
io.write_stderr(" daff [--color] [--no-color] [--output OUTPUT.csv] a.csv b.csv\n")
|
729
|
+
io.write_stderr(" daff [--output OUTPUT.html] a.csv b.csv\n")
|
730
|
+
io.write_stderr(" daff [--output OUTPUT.csv] parent.csv a.csv b.csv\n")
|
731
|
+
io.write_stderr(" daff [--output OUTPUT.ndjson] a.ndjson b.ndjson\n")
|
732
|
+
io.write_stderr(" daff [--www] a.csv b.csv\n")
|
733
|
+
io.write_stderr(" daff patch [--inplace] [--output OUTPUT.csv] a.csv patch.csv\n")
|
734
|
+
io.write_stderr(" daff merge [--inplace] [--output OUTPUT.csv] parent.csv a.csv b.csv\n")
|
735
|
+
io.write_stderr(" daff trim [--output OUTPUT.csv] source.csv\n")
|
736
|
+
io.write_stderr(" daff render [--output OUTPUT.html] diff.csv\n")
|
737
|
+
io.write_stderr(" daff copy in.csv out.tsv\n")
|
738
|
+
io.write_stderr(" daff in.csv\n")
|
739
|
+
io.write_stderr(" daff git\n")
|
740
|
+
io.write_stderr(" daff version\n")
|
741
|
+
io.write_stderr("\n")
|
742
|
+
io.write_stderr("The --inplace option to patch and merge will result in modification of a.csv.\n")
|
743
|
+
io.write_stderr("\n")
|
744
|
+
io.write_stderr("If you need more control, here is the full list of flags:\n")
|
745
|
+
io.write_stderr(" daff diff [--output OUTPUT.csv] [--context NUM] [--all] [--act ACT] a.csv b.csv\n")
|
746
|
+
io.write_stderr(" --act ACT: show only a certain kind of change (update, insert, delete)\n")
|
747
|
+
io.write_stderr(" --all: do not prune unchanged rows or columns\n")
|
748
|
+
io.write_stderr(" --all-rows: do not prune unchanged rows\n")
|
749
|
+
io.write_stderr(" --all-columns: do not prune unchanged columns\n")
|
750
|
+
io.write_stderr(" --color: highlight changes with terminal colors (default in terminals)\n")
|
751
|
+
io.write_stderr(" --context NUM: show NUM rows of context\n")
|
752
|
+
io.write_stderr(" --id: specify column to use as primary key (repeat for multi-column key)\n")
|
753
|
+
io.write_stderr(" --ignore: specify column to ignore completely (can repeat)\n")
|
754
|
+
io.write_stderr(" --index: include row/columns numbers from original tables\n")
|
755
|
+
io.write_stderr(" --input-format [csv|tsv|ssv|psv|json]: set format to expect for input\n")
|
756
|
+
io.write_stderr(" --eol [crlf|lf|cr|auto]: separator between rows of csv output.\n")
|
757
|
+
io.write_stderr(" --no-color: make sure terminal colors are not used\n")
|
758
|
+
io.write_stderr(" --ordered: assume row order is meaningful (default for CSV)\n")
|
759
|
+
io.write_stderr(" --output-format [csv|tsv|ssv|psv|json|copy|html]: set format for output\n")
|
760
|
+
io.write_stderr(" --padding [dense|sparse|smart]: set padding method for aligning columns\n")
|
761
|
+
io.write_stderr(" --table NAME: compare the named table, used with SQL sources\n")
|
762
|
+
io.write_stderr(" --unordered: assume row order is meaningless (default for json formats)\n")
|
763
|
+
io.write_stderr(" -w / --ignore-whitespace: ignore changes in leading/trailing whitespace\n")
|
764
|
+
io.write_stderr(" -i / --ignore-case: ignore differences in case\n")
|
765
|
+
io.write_stderr("\n")
|
766
|
+
io.write_stderr(" daff render [--output OUTPUT.html] [--css CSS.css] [--fragment] [--plain] diff.csv\n")
|
767
|
+
io.write_stderr(" --css CSS.css: generate a suitable css file to go with the html\n")
|
768
|
+
io.write_stderr(" --fragment: generate just a html fragment rather than a page\n")
|
769
|
+
io.write_stderr(" --plain: do not use fancy utf8 characters to make arrows prettier\n")
|
770
|
+
io.write_stderr(" --www: send output to a browser\n")
|
771
|
+
return 1
|
772
|
+
end
|
739
773
|
end
|
740
774
|
cmd1 = args[0]
|
741
775
|
offset = 1
|
742
776
|
if !Lambda.has(["diff","patch","merge","trim","render","git","version","copy"],cmd1)
|
743
|
-
if (cmd1.index("
|
777
|
+
if (cmd1.index("--",nil || 0) || -1) == 0
|
744
778
|
cmd1 = "diff"
|
745
779
|
offset = 0
|
780
|
+
elsif (cmd1.index(".",nil || 0) || -1) != -1
|
781
|
+
if args.length == 2
|
782
|
+
cmd1 = "diff"
|
783
|
+
offset = 0
|
784
|
+
elsif args.length == 1
|
785
|
+
cmd1 = "copy"
|
786
|
+
offset = 0
|
787
|
+
end
|
746
788
|
end
|
747
789
|
end
|
748
790
|
if cmd1 == "git"
|
@@ -816,7 +858,9 @@ module Coopy
|
|
816
858
|
elsif cmd1 == "render"
|
817
859
|
self.render_table(output,a)
|
818
860
|
elsif cmd1 == "copy"
|
819
|
-
|
861
|
+
os = ::Coopy::Tables.new(a)
|
862
|
+
os.add("untitled")
|
863
|
+
self.save_tables(output,os,self.use_color(@flags,output),false)
|
820
864
|
end
|
821
865
|
if ok
|
822
866
|
return 0
|
@@ -835,7 +879,7 @@ module Coopy
|
|
835
879
|
class << self
|
836
880
|
attr_accessor :version
|
837
881
|
end
|
838
|
-
@version = "1.3.
|
882
|
+
@version = "1.3.25"
|
839
883
|
|
840
884
|
def Coopy.diff_as_html(local,remote,flags = nil)
|
841
885
|
comp = ::Coopy::TableComparisonState.new
|
data/lib/lib/coopy/csv.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
module Coopy
|
5
5
|
class Csv
|
6
6
|
|
7
|
-
def initialize(delim = ",")
|
7
|
+
def initialize(delim = ",",eol = nil)
|
8
8
|
@cursor = 0
|
9
9
|
@row_ended = false
|
10
10
|
if delim == nil
|
@@ -12,6 +12,8 @@ module Coopy
|
|
12
12
|
else
|
13
13
|
@delim = delim
|
14
14
|
end
|
15
|
+
@discovered_eol = nil
|
16
|
+
@preferred_eol = eol
|
15
17
|
end
|
16
18
|
|
17
19
|
protected
|
@@ -20,10 +22,14 @@ module Coopy
|
|
20
22
|
attr_accessor :row_ended
|
21
23
|
attr_accessor :has_structure
|
22
24
|
attr_accessor :delim
|
25
|
+
attr_accessor :discovered_eol
|
26
|
+
attr_accessor :preferred_eol
|
23
27
|
|
24
28
|
public
|
25
29
|
|
26
30
|
def render_table(t)
|
31
|
+
eol = @preferred_eol
|
32
|
+
eol = "\r\n" if eol == nil
|
27
33
|
result = ""
|
28
34
|
txt = ""
|
29
35
|
v = t.get_cell_view
|
@@ -39,7 +45,7 @@ module Coopy
|
|
39
45
|
txt += self.render_cell(v,stream.get_cell(x))
|
40
46
|
end
|
41
47
|
end
|
42
|
-
txt +=
|
48
|
+
txt += eol
|
43
49
|
end
|
44
50
|
txt
|
45
51
|
end
|
@@ -48,17 +54,45 @@ module Coopy
|
|
48
54
|
return "NULL" if d == nil
|
49
55
|
str = v.to_s(d)
|
50
56
|
need_quote = false
|
51
|
-
|
57
|
+
if str.length > 0
|
58
|
+
need_quote = true if str[0] == " " || str[str.length - 1] == " "
|
59
|
+
end
|
60
|
+
if !need_quote
|
52
61
|
_g1 = 0
|
53
62
|
_g = str.length
|
54
63
|
while(_g1 < _g)
|
55
64
|
i = _g1
|
56
65
|
_g1+=1
|
57
66
|
ch = str[i]
|
58
|
-
if ch == "\"" || ch == "'" || ch ==
|
67
|
+
if ch == "\"" || ch == "'" || ch == "\r" || ch == "\n" || ch == "\t"
|
59
68
|
need_quote = true
|
60
69
|
break
|
61
70
|
end
|
71
|
+
if ch == @delim[0]
|
72
|
+
if @delim.length == 1
|
73
|
+
need_quote = true
|
74
|
+
break
|
75
|
+
end
|
76
|
+
if i + @delim.length <= str.length
|
77
|
+
match = true
|
78
|
+
begin
|
79
|
+
_g3 = 1
|
80
|
+
_g2 = @delim.length
|
81
|
+
while(_g3 < _g2)
|
82
|
+
j = _g3
|
83
|
+
_g3+=1
|
84
|
+
if str[i + j] != @delim[j]
|
85
|
+
match = false
|
86
|
+
break
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
if match
|
91
|
+
need_quote = true
|
92
|
+
break
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
62
96
|
end
|
63
97
|
end
|
64
98
|
result = ""
|
@@ -66,8 +100,8 @@ module Coopy
|
|
66
100
|
line_buf = ""
|
67
101
|
begin
|
68
102
|
_g11 = 0
|
69
|
-
|
70
|
-
while(_g11 <
|
103
|
+
_g4 = str.length
|
104
|
+
while(_g11 < _g4)
|
71
105
|
i1 = _g11
|
72
106
|
_g11+=1
|
73
107
|
ch1 = str[i1]
|
@@ -165,14 +199,39 @@ module Coopy
|
|
165
199
|
first_non_underscore = i if ch != 95 && i < first_non_underscore
|
166
200
|
if @has_structure
|
167
201
|
if !quoting
|
168
|
-
|
202
|
+
if ch == (@delim[0].ord rescue nil)
|
203
|
+
break if @delim.length == 1
|
204
|
+
if i + @delim.length <= txt.length
|
205
|
+
match = true
|
206
|
+
begin
|
207
|
+
_g3 = 1
|
208
|
+
_g2 = @delim.length
|
209
|
+
while(_g3 < _g2)
|
210
|
+
j = _g3
|
211
|
+
_g3+=1
|
212
|
+
if txt[i + j] != @delim[j]
|
213
|
+
match = false
|
214
|
+
break
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
if match
|
219
|
+
last_processed += @delim.length - 1
|
220
|
+
break
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
169
224
|
if ch == 13 || ch == 10
|
170
225
|
ch2 = (txt[i + 1].ord rescue nil)
|
171
226
|
if ch2 != nil
|
172
227
|
if ch2 != ch
|
173
|
-
|
228
|
+
if ch2 == 13 || ch2 == 10
|
229
|
+
@discovered_eol = _hx_str([ch].pack("U")) + _hx_str([ch2].pack("U")) if @discovered_eol == nil
|
230
|
+
last_processed+=1
|
231
|
+
end
|
174
232
|
end
|
175
233
|
end
|
234
|
+
@discovered_eol = [ch].pack("U") if @discovered_eol == nil
|
176
235
|
@row_ended = true
|
177
236
|
break
|
178
237
|
end
|
@@ -217,6 +276,14 @@ module Coopy
|
|
217
276
|
self.parse_cell_part(txt)
|
218
277
|
end
|
219
278
|
|
279
|
+
def get_discovered_eol
|
280
|
+
@discovered_eol
|
281
|
+
end
|
282
|
+
|
283
|
+
def set_preferred_eol(eol)
|
284
|
+
@preferred_eol = eol
|
285
|
+
end
|
286
|
+
|
220
287
|
haxe_me ["coopy", "Csv"]
|
221
288
|
end
|
222
289
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class DiffSummary
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_accessor :row_deletes
|
11
|
+
attr_accessor :row_inserts
|
12
|
+
attr_accessor :row_updates
|
13
|
+
attr_accessor :row_reorders
|
14
|
+
attr_accessor :col_deletes
|
15
|
+
attr_accessor :col_inserts
|
16
|
+
attr_accessor :col_updates
|
17
|
+
attr_accessor :col_renames
|
18
|
+
attr_accessor :col_reorders
|
19
|
+
attr_accessor :row_count_initial_with_header
|
20
|
+
attr_accessor :row_count_final_with_header
|
21
|
+
attr_accessor :row_count_initial
|
22
|
+
attr_accessor :row_count_final
|
23
|
+
attr_accessor :col_count_initial
|
24
|
+
attr_accessor :col_count_final
|
25
|
+
haxe_me ["coopy", "DiffSummary"]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/lib/lib/coopy/merger.rb
CHANGED
@@ -26,6 +26,7 @@ module Coopy
|
|
26
26
|
attr_accessor :column_mix_local
|
27
27
|
attr_accessor :column_mix_remote
|
28
28
|
attr_accessor :conflicts
|
29
|
+
attr_accessor :conflict_infos
|
29
30
|
|
30
31
|
def shuffle_dimension(dim_units,len,fate,cl,cr)
|
31
32
|
at = 0
|
@@ -98,6 +99,7 @@ module Coopy
|
|
98
99
|
|
99
100
|
def apply
|
100
101
|
@conflicts = 0
|
102
|
+
@conflict_infos = Array.new
|
101
103
|
ct = ::Coopy::Coopy.compare_tables3(@parent,@local,@remote)
|
102
104
|
align = ct.align
|
103
105
|
@order = align.to_order
|
@@ -130,6 +132,7 @@ module Coopy
|
|
130
132
|
else
|
131
133
|
@local.set_cell(col.l,row.l,::Coopy::Merger.make_conflicted_cell(view,pcell,lcell,rcell))
|
132
134
|
@conflicts+=1
|
135
|
+
self.add_conflict_info(row.l,col.l,view,pcell,lcell,rcell)
|
133
136
|
end
|
134
137
|
end
|
135
138
|
end
|
@@ -174,8 +177,16 @@ module Coopy
|
|
174
177
|
@conflicts
|
175
178
|
end
|
176
179
|
|
180
|
+
def get_conflict_infos
|
181
|
+
@conflict_infos
|
182
|
+
end
|
183
|
+
|
177
184
|
# protected - in ruby this doesn't play well with static/inline methods
|
178
185
|
|
186
|
+
def add_conflict_info(row,col,view,pcell,lcell,rcell)
|
187
|
+
@conflict_infos.push(::Coopy::ConflictInfo.new(row,col,view.to_s(pcell),view.to_s(lcell),view.to_s(rcell)))
|
188
|
+
end
|
189
|
+
|
179
190
|
def Merger.make_conflicted_cell(view,pcell,lcell,rcell)
|
180
191
|
view.to_datum("((( " + _hx_str(view.to_s(pcell)) + " ))) " + _hx_str(view.to_s(lcell)) + " /// " + _hx_str(view.to_s(rcell)))
|
181
192
|
end
|
data/lib/lib/coopy/mover.rb
CHANGED
data/lib/lib/coopy/table_diff.rb
CHANGED
@@ -51,6 +51,16 @@ module Coopy
|
|
51
51
|
attr_accessor :diff_found
|
52
52
|
attr_accessor :schema_diff_found
|
53
53
|
attr_accessor :preserve_columns
|
54
|
+
attr_accessor :row_deletes
|
55
|
+
attr_accessor :row_inserts
|
56
|
+
attr_accessor :row_updates
|
57
|
+
attr_accessor :row_reorders
|
58
|
+
attr_accessor :col_deletes
|
59
|
+
attr_accessor :col_inserts
|
60
|
+
attr_accessor :col_updates
|
61
|
+
attr_accessor :col_renames
|
62
|
+
attr_accessor :col_reorders
|
63
|
+
attr_accessor :column_units_updated
|
54
64
|
attr_accessor :nested
|
55
65
|
attr_accessor :nesting_present
|
56
66
|
|
@@ -267,6 +277,16 @@ module Coopy
|
|
267
277
|
@top_line_done = false
|
268
278
|
@diff_found = false
|
269
279
|
@schema_diff_found = false
|
280
|
+
@row_deletes = 0
|
281
|
+
@row_inserts = 0
|
282
|
+
@row_updates = 0
|
283
|
+
@row_reorders = 0
|
284
|
+
@col_deletes = 0
|
285
|
+
@col_inserts = 0
|
286
|
+
@col_updates = 0
|
287
|
+
@col_renames = 0
|
288
|
+
@col_reorders = 0
|
289
|
+
@column_units_updated = {}
|
270
290
|
end
|
271
291
|
|
272
292
|
def setup_tables
|
@@ -445,6 +465,7 @@ module Coopy
|
|
445
465
|
if @active_column != nil
|
446
466
|
@active_column[j] = 1 if @allow_update
|
447
467
|
end
|
468
|
+
@col_inserts+=1 if @allow_update
|
448
469
|
end
|
449
470
|
if cunit.r < 0 && cunit.lp >= 0
|
450
471
|
@have_schema = true
|
@@ -452,6 +473,7 @@ module Coopy
|
|
452
473
|
if @active_column != nil
|
453
474
|
@active_column[j] = 1 if @allow_update
|
454
475
|
end
|
476
|
+
@col_deletes+=1 if @allow_update
|
455
477
|
end
|
456
478
|
if cunit.r >= 0 && cunit.lp >= 0
|
457
479
|
if @p.get_height >= @rp_header && @b.get_height >= @rb_header
|
@@ -462,7 +484,10 @@ module Coopy
|
|
462
484
|
act = "("
|
463
485
|
act += @v.to_s(pp)
|
464
486
|
act += ")"
|
465
|
-
|
487
|
+
if @active_column != nil
|
488
|
+
@active_column[j] = 1
|
489
|
+
@col_renames+=1
|
490
|
+
end
|
466
491
|
end
|
467
492
|
end
|
468
493
|
end
|
@@ -470,6 +495,7 @@ module Coopy
|
|
470
495
|
act = ":" + _hx_str(act)
|
471
496
|
@have_schema = true
|
472
497
|
@active_column = nil if @active_column != nil
|
498
|
+
@col_reorders+=1
|
473
499
|
end
|
474
500
|
@schema.push(act)
|
475
501
|
end
|
@@ -823,7 +849,8 @@ module Coopy
|
|
823
849
|
[ll_out,rr_out,pp_out]
|
824
850
|
end
|
825
851
|
|
826
|
-
def scan_row(unit,output,at,i)
|
852
|
+
def scan_row(unit,output,at,i,out)
|
853
|
+
row_update = false
|
827
854
|
begin
|
828
855
|
_g1 = 0
|
829
856
|
_g = @column_units.length
|
@@ -898,6 +925,10 @@ module Coopy
|
|
898
925
|
end
|
899
926
|
cell = dd
|
900
927
|
if have_dd_to && @allow_update
|
928
|
+
if !row_update
|
929
|
+
@row_updates+=1 if out == 0
|
930
|
+
row_update = true
|
931
|
+
end
|
901
932
|
@active_column[j] = 1 if @active_column != nil
|
902
933
|
if @sep == ""
|
903
934
|
if @builder.need_separator
|
@@ -926,6 +957,10 @@ module Coopy
|
|
926
957
|
cell = @builder.conflict(dd,dd_to_alt,dd_to)
|
927
958
|
@act = @conflict_sep
|
928
959
|
end
|
960
|
+
if !@column_units_updated.include?(j)
|
961
|
+
@column_units_updated[j] = true
|
962
|
+
@col_updates+=1
|
963
|
+
end
|
929
964
|
end
|
930
965
|
@act = "+" if @act == "" && @have_addition
|
931
966
|
if @act == "+++"
|
@@ -1019,8 +1054,9 @@ module Coopy
|
|
1019
1054
|
@publish = @flags.show_unchanged
|
1020
1055
|
dummy = false
|
1021
1056
|
if out == 1
|
1022
|
-
|
1023
|
-
|
1057
|
+
value = @active_row[i]
|
1058
|
+
@publish = value != nil && value > 0
|
1059
|
+
dummy = value != nil && value == 3
|
1024
1060
|
next if dummy && showed_dummy
|
1025
1061
|
next if !@publish
|
1026
1062
|
end
|
@@ -1046,14 +1082,19 @@ module Coopy
|
|
1046
1082
|
@have_addition = false
|
1047
1083
|
skip = false
|
1048
1084
|
@act = ""
|
1049
|
-
|
1085
|
+
if reordered
|
1086
|
+
@act = ":"
|
1087
|
+
@row_reorders+=1 if out == 0
|
1088
|
+
end
|
1050
1089
|
if unit.p < 0 && unit.l < 0 && unit.r >= 0
|
1051
1090
|
skip = true if !@allow_insert
|
1052
1091
|
@act = "+++"
|
1092
|
+
@row_inserts+=1 if out == 0 && !skip
|
1053
1093
|
end
|
1054
1094
|
if (unit.p >= 0 || !@has_parent) && unit.l >= 0 && unit.r < 0
|
1055
1095
|
skip = true if !@allow_delete
|
1056
1096
|
@act = "---"
|
1097
|
+
@row_deletes+=1 if out == 0 && !skip
|
1057
1098
|
end
|
1058
1099
|
if skip
|
1059
1100
|
if !@publish
|
@@ -1061,7 +1102,7 @@ module Coopy
|
|
1061
1102
|
end
|
1062
1103
|
next
|
1063
1104
|
end
|
1064
|
-
self.scan_row(unit,output,at,i)
|
1105
|
+
self.scan_row(unit,output,at,i,out)
|
1065
1106
|
end
|
1066
1107
|
end
|
1067
1108
|
end
|
@@ -1118,6 +1159,26 @@ module Coopy
|
|
1118
1159
|
@align.comp
|
1119
1160
|
end
|
1120
1161
|
|
1162
|
+
def get_summary
|
1163
|
+
ds = ::Coopy::DiffSummary.new
|
1164
|
+
ds.row_deletes = @row_deletes
|
1165
|
+
ds.row_inserts = @row_inserts
|
1166
|
+
ds.row_updates = @row_updates
|
1167
|
+
ds.row_reorders = @row_reorders
|
1168
|
+
ds.col_deletes = @col_deletes
|
1169
|
+
ds.col_inserts = @col_inserts
|
1170
|
+
ds.col_updates = @col_updates
|
1171
|
+
ds.col_renames = @col_renames
|
1172
|
+
ds.col_reorders = @col_reorders
|
1173
|
+
ds.row_count_initial_with_header = @align.get_source.get_height
|
1174
|
+
ds.row_count_final_with_header = @align.get_target.get_height
|
1175
|
+
ds.row_count_initial = @align.get_source.get_height - @align.get_source_header - 1
|
1176
|
+
ds.row_count_final = @align.get_target.get_height - @align.get_target_header - 1
|
1177
|
+
ds.col_count_initial = @align.get_source.get_width
|
1178
|
+
ds.col_count_final = @align.get_target.get_width
|
1179
|
+
ds
|
1180
|
+
end
|
1181
|
+
|
1121
1182
|
haxe_me ["coopy", "TableDiff"]
|
1122
1183
|
end
|
1123
1184
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
module Coopy
|
5
5
|
class TerminalDiffRender
|
6
6
|
|
7
|
-
def initialize(flags = nil)
|
7
|
+
def initialize(flags = nil,delim = nil,diff = true)
|
8
8
|
@align_columns = true
|
9
9
|
@wide_columns = false
|
10
10
|
@use_glyphs = true
|
@@ -14,6 +14,12 @@ module Coopy
|
|
14
14
|
@wide_columns = true if flags.padding_strategy == "sparse"
|
15
15
|
@use_glyphs = flags.use_glyphs
|
16
16
|
end
|
17
|
+
if delim != nil
|
18
|
+
@delim = delim
|
19
|
+
else
|
20
|
+
@delim = ","
|
21
|
+
end
|
22
|
+
@diff = diff
|
17
23
|
end
|
18
24
|
|
19
25
|
protected
|
@@ -26,6 +32,8 @@ module Coopy
|
|
26
32
|
attr_accessor :wide_columns
|
27
33
|
attr_accessor :use_glyphs
|
28
34
|
attr_accessor :flags
|
35
|
+
attr_accessor :delim
|
36
|
+
attr_accessor :diff
|
29
37
|
|
30
38
|
public
|
31
39
|
|
@@ -43,14 +51,14 @@ module Coopy
|
|
43
51
|
@v = t.get_cell_view
|
44
52
|
@codes = {}
|
45
53
|
@codes["header"] = "\x1B[0;1m"
|
54
|
+
@codes["minor"] = "\x1B[33m"
|
55
|
+
@codes["done"] = "\x1B[0m"
|
46
56
|
@codes["meta"] = "\x1B[0;1m"
|
47
57
|
@codes["spec"] = "\x1B[35;1m"
|
48
58
|
@codes["add"] = "\x1B[32;1m"
|
49
59
|
@codes["conflict"] = "\x1B[33;1m"
|
50
60
|
@codes["modify"] = "\x1B[34;1m"
|
51
61
|
@codes["remove"] = "\x1B[31;1m"
|
52
|
-
@codes["minor"] = "\x1B[2m"
|
53
|
-
@codes["done"] = "\x1B[0m"
|
54
62
|
sizes = nil
|
55
63
|
sizes = self.pick_sizes(t) if @align_columns
|
56
64
|
begin
|
@@ -65,7 +73,6 @@ module Coopy
|
|
65
73
|
while(_g1 < w)
|
66
74
|
x = _g1
|
67
75
|
_g1+=1
|
68
|
-
txt += _hx_str(@codes["minor"]) + "," + _hx_str(@codes["done"]) if x > 0
|
69
76
|
if sizes != nil
|
70
77
|
spaces = target - at
|
71
78
|
begin
|
@@ -78,6 +85,7 @@ module Coopy
|
|
78
85
|
end
|
79
86
|
end
|
80
87
|
end
|
88
|
+
txt += _hx_str(@codes["minor"]) + _hx_str(@delim) + _hx_str(@codes["done"]) if x > 0
|
81
89
|
txt += self.get_text(x,y,true)
|
82
90
|
if sizes != nil
|
83
91
|
bit = self.get_text(x,y,false)
|
@@ -101,7 +109,7 @@ module Coopy
|
|
101
109
|
def get_text(x,y,color)
|
102
110
|
val = @t.get_cell(x,y)
|
103
111
|
cell = ::Coopy::DiffRender.render_cell(@t,@v,x,y)
|
104
|
-
if color
|
112
|
+
if color && @diff
|
105
113
|
code = nil
|
106
114
|
code = @codes[cell.category] if cell.category != nil
|
107
115
|
if cell.category_given_tr != nil
|
@@ -127,6 +135,8 @@ module Coopy
|
|
127
135
|
val = _hx_str(code) + _hx_str(val.to_s) + _hx_str(@codes["done"])
|
128
136
|
end
|
129
137
|
end
|
138
|
+
elsif color && !@diff
|
139
|
+
val = _hx_str(@codes["header"]) + _hx_str(val.to_s) + _hx_str(@codes["done"]) if y == 0
|
130
140
|
elsif @use_glyphs
|
131
141
|
val = cell.pretty_value
|
132
142
|
else
|
@@ -159,7 +169,8 @@ module Coopy
|
|
159
169
|
y = _g1
|
160
170
|
_g1+=1
|
161
171
|
txt = self.get_text(x,y,false)
|
162
|
-
row = y if txt == "@@" && row == -1
|
172
|
+
row = y if txt == "@@" && row == -1 && @diff
|
173
|
+
row = y if row == -1 && !@diff
|
163
174
|
len = txt.length
|
164
175
|
mmin = len if y == row
|
165
176
|
m += len
|
data/lib/lib/rb/boot.rb
CHANGED
@@ -18,10 +18,10 @@ module Rb
|
|
18
18
|
|
19
19
|
def Boot.__instanceof(o,cl)
|
20
20
|
return false if cl == nil
|
21
|
-
if cl ==
|
22
|
-
return o.is_a?
|
21
|
+
if cl == Integer
|
22
|
+
return o.is_a? Integer
|
23
23
|
elsif cl == Float
|
24
|
-
return o.is_a?(Float) || o.is_a?(
|
24
|
+
return o.is_a?(Float) || o.is_a?(Integer)
|
25
25
|
elsif cl == TrueClass
|
26
26
|
return ((o.is_a? TrueClass)||(o.is_a? FalseClass))
|
27
27
|
elsif cl == String
|
data/lib/lib/type.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-08-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Diff and patch tables
|
15
15
|
email:
|
@@ -32,10 +32,12 @@ files:
|
|
32
32
|
- lib/lib/coopy/combined_table_head.rb
|
33
33
|
- lib/lib/coopy/compare_flags.rb
|
34
34
|
- lib/lib/coopy/compare_table.rb
|
35
|
+
- lib/lib/coopy/conflict_info.rb
|
35
36
|
- lib/lib/coopy/coopy.rb
|
36
37
|
- lib/lib/coopy/cross_match.rb
|
37
38
|
- lib/lib/coopy/csv.rb
|
38
39
|
- lib/lib/coopy/diff_render.rb
|
40
|
+
- lib/lib/coopy/diff_summary.rb
|
39
41
|
- lib/lib/coopy/flat_cell_builder.rb
|
40
42
|
- lib/lib/coopy/highlight_patch.rb
|
41
43
|
- lib/lib/coopy/highlight_patch_unit.rb
|
@@ -113,17 +115,17 @@ require_paths:
|
|
113
115
|
- lib
|
114
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
117
|
requirements:
|
116
|
-
- -
|
118
|
+
- - ">="
|
117
119
|
- !ruby/object:Gem::Version
|
118
120
|
version: '0'
|
119
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
122
|
requirements:
|
121
|
-
- -
|
123
|
+
- - ">="
|
122
124
|
- !ruby/object:Gem::Version
|
123
125
|
version: '0'
|
124
126
|
requirements: []
|
125
127
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.6.10
|
127
129
|
signing_key:
|
128
130
|
specification_version: 4
|
129
131
|
summary: '[![Build Status](https://travis-ci.org/paulfitz/daff.svg?branch=master)](https://travis-ci.org/paulfitz/daff)
|