D6867: transaction: detect an attempt to truncate-to-extend on playback, raise error

spectral (Kyle Lippincott) phabricator at mercurial-scm.org
Mon Sep 23 13:15:24 EDT 2019


Closed by commit rHG8502f76dbfd7: transaction: detect an attempt to truncate-to-extend on playback, raise error (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6867?vs=16578&id=16592

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6867/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6867

AFFECTED FILES
  mercurial/transaction.py

CHANGE DETAILS

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -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:



To: spectral, #hg-reviewers
Cc: durin42, mercurial-devel


More information about the Mercurial-devel mailing list