Skip to content

Commit b878d85

Browse files
committed
fixing array diff bug (issue #30)
1 parent 4d9adf1 commit b878d85

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

jsonpatch.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ def make_patch(src, dst):
175175
# TODO: fix patch optimiztion and remove the following check
176176
# fix when patch with optimization is incorrect
177177
patch = JsonPatch.from_diff(src, dst)
178-
new = patch.apply(src)
178+
try:
179+
new = patch.apply(src)
180+
except JsonPatchConflict: # see TODO
181+
return JsonPatch.from_diff(src, dst, False)
182+
179183
if new != dst:
180184
return JsonPatch.from_diff(src, dst, False)
181185

@@ -601,7 +605,6 @@ def _longest_common_subseq(src, dst):
601605
matrix[i][j] = matrix[i-1][j-1] + 1
602606
if matrix[i][j] > z:
603607
z = matrix[i][j]
604-
if matrix[i][j] == z:
605608
range_src = (i-z+1, i+1)
606609
range_dst = (j-z+1, j+1)
607610
else:

0 commit comments

Comments
 (0)