--- a/mercurial/crecord.py Wed Jun 13 10:41:20 2018 -0400
+++ b/mercurial/crecord.py Thu Jun 14 14:04:26 2018 -0700
@@ -398,7 +398,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' % (