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

login
register
mail settings
Submitter phabricator
Date Sept. 23, 2019, 5:15 p.m.
Message ID <ebc68fbb152e708f905afc7b36c3858b@localhost.localdomain>
Download mbox | patch
Permalink /patch/41736/
State Not Applicable
Headers show

Comments

phabricator - Sept. 23, 2019, 5:15 p.m.
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




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

Patch

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: