mercurial/transaction.py
changeset 42963 8502f76dbfd7
parent 41365 876494fd967d
child 43050 a614f26d4897
--- a/mercurial/transaction.py	Tue Sep 17 15:09:25 2019 -0700
+++ b/mercurial/transaction.py	Tue Sep 17 14:01:26 2019 -0700
@@ -54,6 +54,10 @@
             checkambig = checkambigfiles and (f, '') in checkambigfiles
             try:
                 fp = opener(f, 'a', checkambig=checkambig)
+                if fp.tell() < o:
+                    raise error.Abort(_(
+                            "attempted to truncate %s to %d bytes, but it was "
+                            "already %d bytes\n") % (f, o, fp.tell()))
                 fp.truncate(o)
                 fp.close()
             except IOError: