This is an archive of the discontinued Mercurial Phabricator instance.

crecord: avoid duplicating lines when reverting noeol->eol change
ClosedPublic

Authored by spectral on Apr 5 2022, 2:26 PM.

Details

Summary

When reversing a patch that looks like this while using crecord:

@@ -301,4 +302,4 @@ zza
 zzb
 zzc
 zzd
-zze
\ No newline at end of file
+zze

we would previously reverse the -zze line to be an add, encounter the "no
newline" line and stop inspecting lines. This caused us to duplicate the line,
producing zzezze (still without a newline).

break is the correct action if we know there will be no lines afterwards, as
would be the case in an eol -> noeol transition. It is incorrect if there are
lines afterward, such as if both sides are missing the newline or if only the
lhs is missing the newline.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.