From patchwork Mon Sep 23 17:15:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D6867: transaction: detect an attempt to truncate-to-extend on playback, raise error From: phabricator X-Patchwork-Id: 41736 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 23 Sep 2019 17:15:24 +0000 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 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: