diff/merge

This commit is contained in:
Amber 2024-01-06 23:07:29 +01:00
parent 6483f11b06
commit 7b1b57dc59
2 changed files with 26 additions and 0 deletions

View File

@ -60,5 +60,31 @@ def compute_diff(path_filea, path_fileb):
return out
def txt_diff(path_filea, path_fileb):
ldiff = compute_diff(path_filea, path_fileb)
tdiff = ''
astart = '<<<<<<< %s\n' % (path_filea,)
sep = '======='
bstart = '>>>>>>> %s\n' % (path_fileb,)
for block in ldiff:
islast_block = True if block == ldiff[-1] else False
if isinstance(block[0], list):
ja = ''.join(block[0])
tdiff += astart + ja + sep + '\n'
jb = ''.join(block[1])
tdiff += bstart + jb + sep
if not islast_block:
tdiff += '\n'
continue
tdiff += ''.join(block)
print(tdiff)
return tdiff
def merge_diff(txt_diff, outfile):
pass