Mercurial > hg
changeset 47284:21ed126bab53
revlog: fix index computation during inline->non-inline transition
The computation in 63edc384d3b7 failed to factor in the index entries
themselve as revlog.start() doesn't count them. Found by Valtenin
Gatienbaron with a more precise test case from me.
Differential Revision: https://phab.mercurial-scm.org/D10724
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Tue, 18 May 2021 02:35:27 +0200 |
parents | 2a9ddc8094c7 |
children | 46b828b85eb7 |
files | mercurial/revlog.py tests/helper-killhook.py tests/test-transaction-rollback-on-revlog-split.t |
diffstat | 3 files changed, 41 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlog.py Wed May 19 13:15:00 2021 +0200 +++ b/mercurial/revlog.py Tue May 18 02:35:27 2021 +0200 @@ -2174,7 +2174,7 @@ with self._indexfp() as read_ifh: for r in self: new_dfh.write(self._getsegmentforrevs(r, r, df=read_ifh)[1]) - if troffset <= self.start(r): + if troffset <= self.start(r) + r * self.index.entry_size: trindex = r new_dfh.flush()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/helper-killhook.py Tue May 18 02:35:27 2021 +0200 @@ -0,0 +1,5 @@ +import os + + +def killme(ui, repo, hooktype, **wkargs): + os._exit(80)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-transaction-rollback-on-revlog-split.t Tue May 18 02:35:27 2021 +0200 @@ -0,0 +1,35 @@ +Test correctness of revlog inline -> non-inline transition +---------------------------------------------------------- + +Test offset computation to correctly factor in the index entries themselve. +Test repo has one small, one moderate and one big change. The clone has +the small and moderate change and will transition to non-inline storage when +adding the big change. + + $ hg init troffset-computation --config format.revlog-compression=none + $ cd troffset-computation + $ printf '% 20d' '1' > file + $ hg commit -Aqm_ + $ printf '% 1024d' '1' > file + $ hg commit -Aqm_ + $ dd if=/dev/zero of=file bs=1k count=128 > /dev/null 2>&1 + $ hg commit -Aqm_ + $ cd .. + + $ hg clone -r 1 troffset-computation troffset-computation-copy --config format.revlog-compression=none -q + $ cd troffset-computation-copy + $ cat > .hg/hgrc <<EOF + > [hooks] + > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme + > EOF +#if chg + $ hg pull ../troffset-computation + pulling from ../troffset-computation + [255] +#else + $ hg pull ../troffset-computation + pulling from ../troffset-computation + [80] +#endif + $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | tail -1 + data/file.i 128