--- a/mercurial/crecord.py Tue Jun 19 13:49:06 2018 -0700
+++ b/mercurial/crecord.py Thu Jun 21 09:32:31 2018 -0700
@@ -403,7 +403,7 @@
if fromline != 0:
if fromlen == 0:
fromline -= 1
- if tolen == 0:
+ if tolen == 0 and toline > 0:
toline -= 1
fromtoline = '@@ -%d,%d +%d,%d @@%s\n' % (