You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A sequence diff entry is a list of action, index and argument (except for deletion):
220
+
### Note about the potential addition of a "move" transformation
126
221
127
-
*["-", index]: delete entry at index
128
-
*["+", index, newvalue]: insert single newvalue before index
129
-
*["--", index, n]: delete n entries starting at index
130
-
*["++", index, newvalues]: insert sequence newvalues before index
131
-
*["!", index, diff]: patch value at index with diff
222
+
In the current implementation there is no "move" operation.
223
+
Furthermore we make some assumptions on the structure of the json
224
+
objects and what kind of transformations are meaningful in a diff.
132
225
133
-
Possible simplifications:
226
+
Items swapping position in a list will be considered added and removed
227
+
instead of moved, but in a future iteration adding a "move" operation
228
+
is an option to be considered. The main use case for this would be to
229
+
resolve merges without conflicts when cells in a notebook are
230
+
reordered on one side and modified on the other side.
134
231
135
-
* Remove single-item "-", "+" and rename "--" and "++" to single-letter.
136
-
* OR remove "--" and "++" and stick with just single-item versions.
232
+
Even if we add the move operation, values will never be moved between
233
+
keys in a dict, e.g.:
137
234
235
+
diff({"a":"x", "b":"y"}, {"a":"y", "b":"x"})
138
236
139
-
Note: The currently implemented sequence diff algorithm is
140
-
based on a brute force O(N^2) longest common subsequence (LCS)
141
-
algorithm, this will be rewritten in terms of a faster algorithm
142
-
such as Myers O(ND) LCS based diff algorithm, optionally
143
-
using Pythons difflib for use cases it can handle.
144
-
In particular difflib does not handle custom compare predicate,
145
-
which we need to e.g. identify almost equal cells within sequences
146
-
of cells in a notebook.
237
+
will be:
147
238
239
+
[{"op": "replace", "key": "a", "value": "y"},
240
+
{"op": "replace", "key": "b", "value": "x"}]
148
241
149
-
### Merge format
242
+
In a notebook context this means for example that data will never be
243
+
considered to move across input cells and output cells.
150
244
151
-
The merge process should return two things: The merge result and the conflicts.
152
245
153
-
A format for representing merge conflicts is work in progress.
246
+
## Merge format
154
247
155
-
Each transformation in the base->local and base->remote diffs must either
156
-
end up in the merge result or be recorded in the conflicts representation.
248
+
A merge takes as input a base object (notebook) and local and remote
249
+
objects (notebooks) that are modified versions of base. The merge
250
+
computes the diffs base->local and base->remote and tries to apply all
251
+
changes from each diff to base. The merge returns a merged object
252
+
(notebook) contains all successfully applied changes from both sides,
253
+
and two diff objects merged->local and merged->remote which contain
254
+
the remaining conflicting changes that need manual resolution.
157
255
158
256
159
257
## Pros and Cons
@@ -163,7 +261,7 @@ Pros associated with this implementation include:
163
261
* Possibility to use notebooks for self-documenting regression tests
164
262
165
263
Cons associated with this implementation include:
166
-
* Vanilla git installs will not receive the improved behaviour
264
+
* Vanilla git installs will not receive the improved behaviour, i.e. this will require installation of the package. To reduce the weight of this issue the package should avoid unneeded heavy dependencies.
0 commit comments