diff --git a/mercurial/transaction.py b/mercurial/transaction.py --- a/mercurial/transaction.py +++ b/mercurial/transaction.py @@ -65,7 +65,7 @@ raise error.Abort( _( b"attempted to truncate %s to %d bytes, but it was " - b"already %d bytes\n" + b"already %d bytes" ) % (f, o, fp.tell()) ) diff --git a/tests/test-transaction-rollback-on-revlog-split.t b/tests/test-transaction-rollback-on-revlog-split.t new file mode 100644 --- /dev/null +++ b/tests/test-transaction-rollback-on-revlog-split.t @@ -0,0 +1,41 @@ + $ hg init . + +Create a filelog smaller than revlog._maxinlinesize, but larger than +a revlog index entry. + + >>> import os + >>> open('file', 'wb').write(os.urandom(1000)) + 1000 + $ hg commit -Aqm_ + +Now make a transaction that makes the filelog go over _maxinlinesize, +so we get a .d file, and make that transaction rollback: + + $ cat > .hg/hgrc < [hooks] + > pretxnchangegroup = false + > pretxncommit = false + > EOF + + >>> import os + >>> open('file', 'wb').write(os.urandom(300000)) + 300000 + + $ hg commit -m_ + transaction abort! + rollback failed - please run hg recover + (failure reason: attempted to truncate data/file.i to 1065 bytes, but it was already 128 bytes) + abort: pretxncommit hook exited with status 1 + [40] + + $ cat .hg/store/journal | tr -s '\000' ' ' + data/file.i 1065 + data/file.d 0 + data/file.i 0 + 00manifest.i 111 + 00changelog.i 122 + + $ hg recover + rolling back interrupted transaction + abort: attempted to truncate data/file.i to 1065 bytes, but it was already 128 bytes + [255]