eternity 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7844d5b55ae3bf3ee53f5ffebe730e65c586071
4
- data.tar.gz: 44489d244b55008ab3a484290e5f9e261ee77c2d
3
+ metadata.gz: 9885515399a74eeec844fd7a809855e88b85d212
4
+ data.tar.gz: 2bbb9ff78456c2e88b34b60b59bc7f18294388f4
5
5
  SHA512:
6
- metadata.gz: a478d2902be86a627498d81fa69b6191cb45c9574d26c520be0142b0ac051a533bb6e8a38772eda97d6579b1d987afeca7febc3cf21240b6ff40f5bba9ad8b33
7
- data.tar.gz: 335f532289063578604144fde234b8ec2a62d91fb8ee1a205e9b5aa957f674d987e6307b7f58a614bcbc050d0b0351034350e09baa2cfed224b99432e6be6648
6
+ metadata.gz: f8bd9bb7f5881c0fd6c1228cffad16bd6c7223203d82001d7396ffe51abe41c100afc8c48398c19d4a08a998736089f0abb721b7b4c24724c8549746bd36d1a0
7
+ data.tar.gz: d97f7057417ec2bf6a50285d9061776907648d336b640fc7f9d0252553b0c251219c60b3e20494f4d9bb29c69178bb502945f31f06f3c957d3c99796d04d5ebe
@@ -60,6 +60,8 @@ module Eternity
60
60
  elements.each do |id, change|
61
61
  if change['action'] == UPDATE && current_index[collection][id].sha1 == Blob.digest(Blob.serialize(change['data']))
62
62
  change = nil
63
+ elsif change['action'] == DELETE && !current_index[collection].include?(id)
64
+ change = nil
63
65
  end
64
66
  hash[collection][id] = change if change
65
67
  end
@@ -1,3 +1,3 @@
1
1
  module Eternity
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -4,7 +4,6 @@ describe Repository, 'Merge' do
4
4
 
5
5
  let(:repo_1) { Repository.new :test_1 }
6
6
  let(:repo_2) { Repository.new :test_2 }
7
- let(:repo_3) { Repository.new :test_3 }
8
7
 
9
8
  let(:commits) { Hash.new }
10
9
 
@@ -20,6 +19,10 @@ describe Repository, 'Merge' do
20
19
  delta
21
20
  end
22
21
 
22
+ def checkout(id, repo)
23
+ repo.checkout commit: commits[id].id
24
+ end
25
+
23
26
  def assert_history(id, history_ids)
24
27
  commits[id].history.must_equal history_ids.map { |c| commits[c] }
25
28
  end
@@ -28,6 +31,179 @@ describe Repository, 'Merge' do
28
31
  commits[id].must_equal_index 'countries' => expected
29
32
  end
30
33
 
34
+ describe 'Merge Errors' do
35
+
36
+ it 'case 1' do
37
+ skip
38
+ commit 1, repo_1 do
39
+ insert 'AR', name: 'Argentina'
40
+ end
41
+
42
+ checkout 1, repo_2
43
+
44
+ commit 2, repo_2 do
45
+ insert 'UY', name: 'Uruguay'
46
+ end
47
+
48
+ commit 3, repo_1 do
49
+ update 'AR', name: 'Brasil'
50
+ end
51
+
52
+ commit 4, repo_1 do
53
+ update 'AR', name: 'Argentina'
54
+ end
55
+
56
+ merge 5, repo_2, 4 do |delta|
57
+ #delta['AR'].must_equal => {'action' => 'update', 'data' => {'name' => 'Argentina'}}
58
+ end
59
+
60
+ commits[5].with_index do |index|
61
+ index['countries']['AR'].data['name'].must_equal 'Argentina'
62
+ end
63
+ end
64
+
65
+ it 'case 2' do
66
+ skip
67
+ commit 1, repo_1 do
68
+ insert 'AR', name: 'Argentina'
69
+ end
70
+
71
+ checkout 1, repo_2
72
+
73
+ commit 2, repo_2 do
74
+ insert 'UY', name: 'Uruguay'
75
+ update 'AR', name: 'Brasil'
76
+ end
77
+
78
+ commit 3, repo_2 do
79
+ update 'AR', name: 'Argentina'
80
+ end
81
+
82
+ commit 4, repo_1 do
83
+ update 'AR', name: 'Arg'
84
+ end
85
+
86
+ commit 5, repo_1 do
87
+ update 'AR', name: 'Argentina'
88
+ end
89
+
90
+ merge 6, repo_2, 5 do |delta|
91
+ #delta['AR'].must_equal => {'action' => 'update', 'data' => {'name' => 'Argentina'}}
92
+ end
93
+
94
+ commits[6].with_index do |index|
95
+ index['countries']['AR'].data['name'].must_equal 'Argentina'
96
+ end
97
+ end
98
+
99
+ it 'case 3 (patched)' do
100
+ skip
101
+ commit 1, repo_1 do
102
+ insert 'AR', name: 'Argentina'
103
+ end
104
+
105
+ checkout 1, repo_2
106
+
107
+ commit 2, repo_2 do
108
+ insert 'UY', name: 'Uruguay'
109
+ update 'AR', name: 'Brasil'
110
+ end
111
+
112
+ commit 3, repo_2 do
113
+ update 'AR', name: 'Argentina '
114
+ end
115
+
116
+ commit 4, repo_1 do
117
+ update 'AR', name: 'Arg'
118
+ end
119
+
120
+ commit 5, repo_1 do
121
+ update 'AR', name: 'Argentina'
122
+ end
123
+
124
+ merge 6, repo_2, 5 do |delta|
125
+ #delta['AR'].must_equal => {'action' => 'update', 'data' => {'name' => 'Argentina'}}
126
+ end
127
+
128
+ commits[6].with_index do |index|
129
+ index['countries']['AR'].data['name'].must_equal 'Argentina'
130
+ end
131
+
132
+ merge 7, repo_1, 3 do |delta|
133
+ #delta['AR'].must_equal => {'action' => 'update', 'data' => {'name' => 'Argentina'}}
134
+ end
135
+
136
+ commits[7].with_index do |index|
137
+ index['countries']['AR'].data['name'].must_equal 'Argentina'
138
+ end
139
+
140
+ end
141
+
142
+ end
143
+
144
+ it 'Merge deleted element in two commits' do
145
+ # REPO 1: (*)---(1)----(3)--------(5)
146
+ # \ \ \
147
+ # REPO 2: -(2)---(4)--(6)--(7)
148
+
149
+ commit 1, repo_1 do
150
+ insert 'AR', name: 'Argentina'
151
+ end
152
+
153
+ assert_history 1, []
154
+ assert_index 1, 'AR' => digest(name: 'Argentina')
155
+
156
+ checkout 1, repo_2
157
+
158
+ commit 2, repo_1 do
159
+ insert 'UY', name: 'Uruguay'
160
+ end
161
+
162
+ assert_history 2, [1]
163
+ assert_index 2, 'AR' => digest(name: 'Argentina'),
164
+ 'UY' => digest(name: 'Uruguay')
165
+
166
+ commit 3, repo_2 do
167
+ insert 'BR', name: 'Brasil'
168
+ end
169
+
170
+ assert_history 3, [1]
171
+ assert_index 3, 'AR' => digest(name: 'Argentina'),
172
+ 'BR' => digest(name: 'Brasil')
173
+
174
+ merge 4, repo_2, 2 do |delta|
175
+ delta.must_equal 'UY' => {'action' => 'insert', 'data' => {'name' => 'Uruguay'}}
176
+ end
177
+
178
+ assert_history 4, [3,2,1]
179
+ assert_index 4, 'AR' => digest(name: 'Argentina'),
180
+ 'BR' => digest(name: 'Brasil'),
181
+ 'UY' => digest(name: 'Uruguay')
182
+
183
+ commit 5, repo_1 do
184
+ delete 'UY'
185
+ end
186
+
187
+ assert_history 5, [2,1]
188
+ assert_index 5, 'AR' => digest(name: 'Argentina')
189
+
190
+ commit 6, repo_2 do
191
+ delete 'UY'
192
+ end
193
+
194
+ assert_history 6, [4,3,2,1]
195
+ assert_index 6, 'AR' => digest(name: 'Argentina'),
196
+ 'BR' => digest(name: 'Brasil')
197
+
198
+ merge 7, repo_2, 5 do |delta|
199
+ delta.must_be_nil
200
+ end
201
+
202
+ assert_history 7, [6,4,3,5,2,1]
203
+ assert_index 7, 'AR' => digest(name: 'Argentina'),
204
+ 'BR' => digest(name: 'Brasil')
205
+ end
206
+
31
207
  it 'Delta, index and history' do
32
208
  # REPO 1: (*)---(1)--(2)--(5)---(6)---(9)--(11)
33
209
  # \ / \ /
@@ -49,7 +225,7 @@ describe Repository, 'Merge' do
49
225
  assert_history 2, [1]
50
226
  assert_index 2, 'AR' => digest(name: 'Argentina')
51
227
 
52
- repo_2.checkout commit: commits[1].id
228
+ checkout 1, repo_2
53
229
 
54
230
  commit 3, repo_2 do
55
231
  insert 'UY', name: 'Uruguay'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eternity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-25 00:00:00.000000000 Z
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redic